You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In 4.1.0, the generated code relies on some stdlib types being available, like Stream, ReadOnlyMemory, IDictionary etc. without having a using statement for the corresponding namespaces.
This means that the generated code only compiles if the consuming project sets global usings for those namespaces, e. g. by declaring Microsoft.NET.Sdk as the project SDK and setting ImplicitUsings to true.
Generated code should IMHO not put this burden on the consumer (and restrict consumers to a C# version where global usings are available in the first place).
Please generate the necessary using statements in the code requiring them.
The text was updated successfully, but these errors were encountered:
If we do generate those usings, then you get warnings for the duplicate usings in what is the default situation when you do adotnet new or new project. We decided to default to the "do not add usings" case.
However, there is no reason this could not be another option.
I don't think any complication or option is needed here:
Which diagnostic are you referring to? If you mean IDE0005, then I cannot reproduce with the dotnet tool. I do not get such diagnostics from either the CLI build or VS on code marked with <auto-generated>, as it should be.
If you really want to only generate the usings when actually necessary, the source generator should already know if there is a global using. No need for an option IMHO.
In 4.1.0, the generated code relies on some stdlib types being available, like
Stream
,ReadOnlyMemory
,IDictionary
etc. without having ausing
statement for the corresponding namespaces.This means that the generated code only compiles if the consuming project sets global usings for those namespaces, e. g. by declaring
Microsoft.NET.Sdk
as the project SDK and settingImplicitUsings
to true.Generated code should IMHO not put this burden on the consumer (and restrict consumers to a C# version where global usings are available in the first place).
Please generate the necessary using statements in the code requiring them.
The text was updated successfully, but these errors were encountered: