reflection - Invalid compiler-generated .NET Class Name -
I was going (with)
and when I injected PostSharah (this expression was correct ?) An aspect code in the assembly,
I saw this strange named category marked with
It has been named & lt; & Gt; AspectsImplementationDetails_1
.
As far as I know, the class name can not be started with
.
Is
any kind of unknown / internal operator? [Update] I did some tests and it seems that I was able to generate type with interesting names.
The sample code used here is
Using the system; Using the system. Using the system. Reflection.imit; Namespace ReflectionDomo {class program {public static zero main (string [] AGR) {var typename = new [] {"<<", "-", "+", "~", "!", " @ "," # "," $ ","% "," ^ "," & Amp; "," * "," (",") "," = "}; Const String assemblyName = "test"; Leading (name type in type) {PrintTypeName (Buildtype (assembly name, type name). CreateTip ()); }} Private Static Zero PrintTipName (type type) {Console.WriteLine ("TypeName = '{0}'", type.FullName); } Private Static TypeBuilder BuildType (string assembly name, string typename) {var name = new AssemblyName (assemblyName); Var assemblybuilder = appdomain.courtdaman.definadminizap (name, assemblyBuilderAccess.Run); Var modulebuilder = assemblybuilder.defined dynamic module (name.Name, incorrect); Return module builder Type defined (type name, typewriter, public); }}}}
C # source code not in May be & lt; & Gt; Name starting with
but the name of CLR has more freedom, so the compiler (such as C # compiler and PostSHahar) can generate such names. This is very useful because it ensures that compiler-generated names never collide with the names used in your source code. You will also see them generated by the C # compiler, e.g. For anonymous types or for backup areas of auto properties.
Comments
Post a Comment