Found while working on: #26325
Right now the symbol model has IEnumerable<string> INamedTypeSymbo.MemberNames { get; }. However, both the VB and C# implementations implement that member with a simple string[] that is passed directly out to the caller. This means the caller can trivially cast this to the real type and mutate the array, corrupting the internal data of the compiler.
This returned value needs to be a true immutable value that cannot be changed by the caller in order to preserve hte important immutability invariants of the compiler API.
Found while working on: #26325
Right now the symbol model has
IEnumerable<string> INamedTypeSymbo.MemberNames { get; }. However, both the VB and C# implementations implement that member with a simplestring[]that is passed directly out to the caller. This means the caller can trivially cast this to the real type and mutate the array, corrupting the internal data of the compiler.This returned value needs to be a true immutable value that cannot be changed by the caller in order to preserve hte important immutability invariants of the compiler API.