❔ Checking if ISymbol was autogenerated
Hello, is there any way to check if
ISymbol
was autogenerated by c# compiler? In this case checking for specialname
attribute should be ok. I want to filter out autogenerated symbols such as methods generated from autoproperties or enums' value__
field.10 Replies
ISymbol.IsImplicitlyDeclared Property (Microsoft.CodeAnalysis)
Returns true if this symbol was automatically created by the compiler, and does not have an explicit corresponding source code declaration.
no, it is false even though a method is generated from autoproperty and also for
value__
field for enumsthe CompilerGenerated attribute?
it's not being added
to the symbols
by the compiler
please, can someone help?
For
IFieldSymbol
, there's the AssociatedSymbol
For IMethodSymbol
there should probably be one as well
If that's not null, it's compiler generatedit's null for
value__
for enumsit seems to work for autoproperties
nice
thanks @AntonC, now only handling
value__
for enums is leftyou can probably check if the type it's defined in is an enum
or something like that
make a special case for enums
yeah, I was thinking about it, thanks
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.