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
root = true
[*.cs]# CS0612: Member is obsoletedotnet_diagnostic.CS0612.severity = none
This code is generated by Riok.Mapperly
#nullable enable
internalstaticpartialclassMapper{publicstaticpartialglobal::TargetMapToTarget(thisglobal::Sourcesource){vartarget=newglobal::Target();target.Id=source.Id;// <- a diagnostic is reported herereturntarget;}}
and the CS0612 diagnostic is reported durung accessing obsolete members.
Expected Behavior:
No CS0612 diagnostic is reported.
Actual Behavior:
A diagnostic C:\Users\Hello\source\repos\ConsoleApp2\ConsoleApp2\Riok.Mapperly\Riok.Mapperly.MapperGenerator\Mapper.g.cs(7,21,7,30): warning CS0612: 'Source.Id' is obsolete is reported.
Thanks for raising the issue. tbh I thought editor config applied to generated code as well 🤔
As you suggested I can disable the warning in each generated file, which would fix this issue.
I've considered disabling the warning for each use of an obsolete member if ObsoleteMappingStrategy is set. I decided that it would be too hard to insert the suppression without breaking a lot of code. Unfortunately, there might be some cases where users aren't warned that nested obsolete members are being set even when using ObsoleteMappingStrategy, as it applies to top level member only.
Aside from that I can't think of any other solutions.
latonz
changed the title
Generated mappers should supress warnings about obsolete members
Generated code should suppress warnings about obsolete members
Mar 17, 2024
With the following project
This code is generated by
Riok.Mapperly
and the CS0612 diagnostic is reported durung accessing obsolete members.
Expected Behavior:
No CS0612 diagnostic is reported.
Actual Behavior:
A diagnostic
C:\Users\Hello\source\repos\ConsoleApp2\ConsoleApp2\Riok.Mapperly\Riok.Mapperly.MapperGenerator\Mapper.g.cs(7,21,7,30): warning CS0612: 'Source.Id' is obsolete
is reported.During the discussion in github.com/dotnet/roslyn/issues/69298 @sharwell said this warning should be supressed in
Riok.Mapperly
.The text was updated successfully, but these errors were encountered: