format icon indicating copy to clipboard operation
format copied to clipboard

CS0612 propagating obsolete methods

Open vdurante opened this issue 3 years ago • 8 comments

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?

image

vdurante avatar Jul 19 '21 14:07 vdurante

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?

bdukes avatar Sep 11 '21 21:09 bdukes

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).

GalaxiaGuy avatar Oct 04 '21 12:10 GalaxiaGuy

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.

RikkiGibson avatar Oct 04 '21 18:10 RikkiGibson

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.

JoeRobich avatar Oct 05 '21 20:10 JoeRobich

Work well with:

dotnet_diagnostic.CS0618.severity = none
dotnet_diagnostic.CS0612.severity = none

lindexi avatar Nov 16 '21 13:11 lindexi

Was this ever fixed? I'm running into this issue a lot with my project

clicketyclackety avatar Sep 23 '22 17:09 clicketyclackety

exclude-diagnostics option was enough for me

dotnet format --exclude-diagnostics CS0612 CS0618

DosangGu avatar Jun 27 '23 00:06 DosangGu

@DosangGu thanks for highlighting this feature/argument, super helpful

JovialJerboa avatar Jun 27 '23 09:06 JovialJerboa