Injectio icon indicating copy to clipboard operation
Injectio copied to clipboard

Nullability issue

Open mrblumi opened this issue 1 year ago • 0 comments

Hi there. First of all thank you for this brilliant library :) Today I discovered the following little issue when trying to register a service like the following

[RegisterScoped]
public class Service : IService<Input, string?>;
public class Input : IInput<string?>;

public interface IService<TInput, TOutput> where TInput : IInput<TOutput>;
public interface IInput<TOutput>;

Usually I am working in an environment with

<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>

And I am getting the following error

Injectio.g.cs(25,45): Error CS8631 : The type 'ServiceType' cannot be used as type parameter 'TIn' in the generic type or method 'IService<TIn, TOut>'. Nullability of type argument 'ServiceType' doesn't match constraint type 'IType<string>'.

Sure enough it can be solved by disabling the TreatWarningsAsErros flag temporary. But I think the problem exists because the used SymbolDisplayFormat.FullyQualifiedFormat is lacking the SymbolDisplayMiscellaneousOptions.IncludeNullableReferenceTypeModifier flag...

mrblumi avatar Apr 20 '24 19:04 mrblumi