MetadataName and Nested Classes

Topics: APIs
Jun 18, 2014 at 10:48 PM
Edited Jun 18, 2014 at 10:51 PM
When retrieving a nested class using Compilation.GetTypeByMetadataName(), one must make sure to delimit it with '+' instead of '.'.

For example: compilation.GetTypeByMetadataName("Namespace.OuterClass+InnerClass") retrieves the nested class "InnerClass".

While one can go from fully qualified metadata name to ISymbol, I can't seem to figure out how to go the other direction.

The INamedTypeSymbol.MetadataName property does not return the fully qualified metadata name, and in most cases is identical to INamedTypeSymbol.Name.

How can one go from INamedTypeSymbol to fully qualified metadata name? The various ToString() methods don't properly retain the '+' when dealing with nested classes. It seems to me it would make sense for MetadataName to provide this.