Biohazrd icon indicating copy to clipboard operation
Biohazrd copied to clipboard

Consider replacing the declaration context in `GetTypeAsString` and associated methods with a proper context enum

Open PathogenDavid opened this issue 2 years ago • 0 comments

Historically we've had the declaration associated with the type being written available in the context of getting a type as a string.

This is somewhat problematic because it doesn't actually tell us what the context we're emitting to is. For instance, a temporary local being written for a in T parameter should be written as ref readonly T but we have no way to know that in ByRefTypeReference. Another weird case is writing the implicit parameters for functions, which are associated with the function its self since no actual parameter exists.

We also actually rarely use it for context beyond debugging, it'd be better to only use it for debugging, remove it from public API locations like ICustomCSharpTypeReference, and replace it with an EmitContext enum.

Additionally it's actually somewhat annoying to determine in some situations. For instance, we have to do a lot of extra work in Trampoline for very little gain in order to figure out which parameter is indirectly associated with an adapter.

PathogenDavid avatar Feb 15 '22 18:02 PathogenDavid