AssemblyBuilder.Save add custom attributes handling. (#84580)
authorBuyaa Namnan <bunamnan@microsoft.com>
Wed, 26 Apr 2023 16:28:25 +0000 (09:28 -0700)
committerGitHub <noreply@github.com>
Wed, 26 Apr 2023 16:28:25 +0000 (09:28 -0700)
commit2a75e65fe2439071a17ae012b8d3e2baf0e49f7a
treea4f41ff84ef982e94dce6562a126080442c0486d
parent184d17dc6b24144f81fae71e1a848698d8097ee4
AssemblyBuilder.Save add custom attributes handling. (#84580)

* Initial custom attributes handling

* Pseudo custom attributes handling and tests

* Use ReadOnlySpan for CustomAttribute binaryData

* Update some pseudo attributes handling and apply feedback

* Add one more pseudo attribute and a few small changes

* Move pseudo attributes handling

* Remove type loading logic from CustomAttributes parsing, use constants for some values

* Add MarshalAsAttribute handling and apply other feedbacks

---------

Co-authored-by: Aaron Robinson <arobins@microsoft.com>
48 files changed:
src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/CustomAttributeBuilder.cs
src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/RuntimeAssemblyBuilder.cs
src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/RuntimeConstructorBuilder.cs
src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/RuntimeEnumBuilder.cs
src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/RuntimeEventBuilder.cs
src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/RuntimeFieldBuilder.cs
src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/RuntimeGenericTypeParameterBuilder.cs
src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/RuntimeMethodBuilder.cs
src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/RuntimeModuleBuilder.cs
src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/RuntimePropertyBuilder.cs
src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/RuntimeTypeBuilder.cs
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Emit/CustomAttributeBuilder.cs
src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.cs
src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/ConstructorBuilder.cs
src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/EnumBuilder.cs
src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/EventBuilder.cs
src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/FieldBuilder.cs
src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs
src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilder.cs
src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/ModuleBuilder.cs
src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/PropertyBuilder.cs
src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.cs
src/libraries/System.Reflection.Emit/ref/System.Reflection.Emit.cs
src/libraries/System.Reflection.Emit/src/Resources/Strings.resx
src/libraries/System.Reflection.Emit/src/System.Reflection.Emit.csproj
src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/AssemblyBuilderImpl.cs
src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/CustomAttributeWrapper.cs [new file with mode: 0644]
src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/FieldBuilderImpl.cs
src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/MethodBuilderImpl.cs
src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/ModuleBuilderImpl.cs
src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/SignatureHelper.cs
src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/TypeBuilderImpl.cs
src/libraries/System.Reflection.Emit/tests/GenericTypeParameterBuilder/GenericTypeParameterBuilderSetCustomAttribute.cs
src/libraries/System.Reflection.Emit/tests/PersistableAssemblyBuilder/AssemblySaveCustomAttributeTests.cs [new file with mode: 0644]
src/libraries/System.Reflection.Emit/tests/PersistableAssemblyBuilder/AssemblySaveWithVariousMembersTests.cs [moved from src/libraries/System.Reflection.Emit/tests/PersistableAssemblyBuilder/AssemblySaveTestsWithVariousTypes.cs with 62% similarity]
src/libraries/System.Reflection.Emit/tests/PersistableAssemblyBuilder/AssemblyTools.cs
src/libraries/System.Reflection.Emit/tests/System.Reflection.Emit.Tests.csproj
src/mono/System.Private.CoreLib/src/System/Reflection/Emit/CustomAttributeBuilder.Mono.cs
src/mono/System.Private.CoreLib/src/System/Reflection/Emit/RuntimeAssemblyBuilder.Mono.cs
src/mono/System.Private.CoreLib/src/System/Reflection/Emit/RuntimeConstructorBuilder.Mono.cs
src/mono/System.Private.CoreLib/src/System/Reflection/Emit/RuntimeEnumBuilder.Mono.cs
src/mono/System.Private.CoreLib/src/System/Reflection/Emit/RuntimeEventBuilder.Mono.cs
src/mono/System.Private.CoreLib/src/System/Reflection/Emit/RuntimeFieldBuilder.Mono.cs
src/mono/System.Private.CoreLib/src/System/Reflection/Emit/RuntimeGenericTypeParameterBuilder.cs
src/mono/System.Private.CoreLib/src/System/Reflection/Emit/RuntimeMethodBuilder.Mono.cs
src/mono/System.Private.CoreLib/src/System/Reflection/Emit/RuntimeModuleBuilder.Mono.cs
src/mono/System.Private.CoreLib/src/System/Reflection/Emit/RuntimePropertyBuilder.Mono.cs
src/mono/System.Private.CoreLib/src/System/Reflection/Emit/RuntimeTypeBuilder.Mono.cs