C#C
C#3y ago
swagrid

✅ Roslyn analyzer: System.Guid only has _dummyPrimitive field?

I'm currently writing an analyzer that inspects the fields of certain types. One of the tests failed because it analyzed System.Guid and I noticed that, according to this query:
ITypeSymbol type = ... // type is Guid
type.GetMembers().OfType<IFieldSymbol>().Where(f => !f.IsStatic)

System.Guid only has a single field: int _dummyPrimitive. I know that guids are larger than 4 bytes and given the field name, I assume this is a placeholder of some sort. I could just ignore System.Guid but I suspect this is not the only type that behaves this way.

  1. Why is the ITypeSymbol of System.Guid a placeholder (or whatever this is) and not the original definition?
  2. Can I somehow detect when a type is a placeholder?
Was this page helpful?