[API Proposal]: TypeName.MakeSimpleTypeName(AssemblyNameInfo) to avoid type name reparsing #106022
Labels
api-approved
API was approved in API review, it can be implemented
area-System.Reflection.Metadata
binaryformatter-migration
Issues related to the removal of BinaryFormatter and migrations away from it
blocking
Marks issues that we want to fast track in order to unblock other important work
in-pr
There is an active PR which will close this issue when it is merged
Milestone
Background and motivation
In #102263, we have approved a set of APIs for creating new
TypeName
instances without reparsing the input again.I took a stab at it in #103713 and realized that I can not use the approved
TypeName.CreateSimpleTypeName
because it expects unescaped input. It's also supposed to escape such input (#102263 (comment)). In order to find out whether it needs to escape the input, it needs to reparse the input (search for multiple characters that need to be escaped). It's exactly what I need to avoid in NRBF, so I need a new method.API Proposal
namespace System.Reflection.Metadata; public partial class TypeName { public TypeName MakeSZArrayTypeName(); public TypeName MakeArrayTypeName(int rank); public TypeName MakePointerTypeName(); public TypeName MakeByRefTypeName(); public TypeName MakeGenericTypeName(ImmutableArray<TypeName> typeArguments); + public TypeName MakeSimpleTypeName(AssemblyNameInfo? assemblyInfo); public static TypeName CreateSimpleTypeName( string metadataName, TypeName? declaringType = null, AssemblyNameInfo? assemblyInfo = null); }
API Usage
Alternative Designs
No response
Risks
Having two methods with similar names:
MakeSimpleTypeName
andCreateSimpleTypeName
may be confusing to the end users.The text was updated successfully, but these errors were encountered: