I have a class as shown below,
public class AccessToken : IAuthToken
{
/// <summary>
/// Initializes a new instance of the <see cref="AccessToken"/> class.
/// </summary>
/// <param name="token">The token.</param>
/// <param name="validTo">The valid to.</param>
public AccessToken(string token, DateTimeOffset validTo)
{
ValidTo = validTo;
Token = token;
}
///<inheritdoc />
public DateTimeOffset ValidTo { get; private set; }
/// <summary>
/// Gets the RAW Jwt token value.
/// This value is encoded and represents the Jwt token.
/// </summary>
/// <value>
/// The token.
/// </value>
public string Token { get; private set; }
}
The DI code goes like this,
return services
.AddTransient<IAuthToken, AccessToken>()
.AddTransient<IAuthTokenService, AuthTokenService>()
.AddSingleton<IIdentityDiscovery, IdentityDiscovery>()
.AddTransient<IIdentityTokenClient, IdentityTokenClient>()
.AddTransient<IDiscoveryClientRetryPolicy, DiscoveryClientRetryPolicy>()
.AddTransient<ITokenClientRetryPolicy, TokenClientRetryPolicy>()
.AddSingleton<IRetryPolicyOptions>(provider => retryOptions);
The whole thing is packaged as a nuget. When this DI code is called from .net461 it works fine but when used in net core 6, I get an error stating it's unable to resolve type string and DateTimeOffset. I tried to inject a dummy string and the string error vanished but the struct DateTimeOffset persisted. Does .net6 interpret this DI in a different way?