format
format copied to clipboard
CS0612 propagating obsolete methods
dotnet-format
's fix for CS0612 is propagating the Obsolete
attributes, making all my methods that uses an Obsolete
method also Obsolete
. I wasn't able to find any documentation on fixes for CS0612 and what would be the expected behavior in this situation.
Is this expected? If so, where can I find info on this fix?
I disabled CS0612 via .editorconfig
:
# CS0618: Type or member is obsolete
dotnet_diagnostic.CS0618.severity = none
However, this didn't stop the Obsolete
attributes from appearing. Were you able to find any information about the code fix?
I think there needs to be some way to control the behavior of the formatter for this.
In my case I definitely want the warnings produced by CS0618, but marking members of my code that use Obsolete
code as also Obsolete
is incorrect (it's not obsolete, but does need need updating to use non-obsolete code, hence why I still need CS0618 enabled).
Perhaps we need to make a pass over the existing code fixers and decide which are not appropriate to run automatically. It also sounds like being able to have format skip fixing certain diagnostics while still reporting the diagnostics during build would be useful.
It also sounds like being able to have format skip fixing certain diagnostics while still reporting the diagnostics during build would be useful.
I think adding a --skip-diagnostics
option is an excellent idea.
Work well with:
dotnet_diagnostic.CS0618.severity = none
dotnet_diagnostic.CS0612.severity = none
Was this ever fixed? I'm running into this issue a lot with my project
exclude-diagnostics
option was enough for me
dotnet format --exclude-diagnostics CS0612 CS0618
@DosangGu thanks for highlighting this feature/argument, super helpful