C
C#17mo ago
kuba_z2

❔ 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
kuba_z2
kuba_z217mo ago
no, it is false even though a method is generated from autoproperty and also for value__ field for enums
Aaron
Aaron17mo ago
the CompilerGenerated attribute?
kuba_z2
kuba_z217mo ago
it's not being added to the symbols by the compiler please, can someone help?
Anton
Anton17mo ago
For IFieldSymbol, there's the AssociatedSymbol For IMethodSymbol there should probably be one as well If that's not null, it's compiler generated
kuba_z2
kuba_z217mo ago
it's null for value__ for enums
kuba_z2
kuba_z217mo ago
it seems to work for autoproperties nice thanks @AntonC, now only handling value__ for enums is left
Anton
Anton17mo ago
you can probably check if the type it's defined in is an enum or something like that make a special case for enums
kuba_z2
kuba_z217mo ago
yeah, I was thinking about it, thanks
Accord
Accord17mo ago
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.