Annotating System.Formats.Asn1 library for Aot#72533
Conversation
|
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
|
Tagging subscribers to this area: @dotnet/area-system-formats-asn1, @vcsjones Issue DetailsPropagated RequiresDynamicCode warning for the Marshal.SizeOf API for the library to be warning free The generic APIs version of these APIs could be made to use the generic version and be safe but currently they are generating warnings since they go through the non-generic APIs.
|
|
Tagging subscribers to this area: @dotnet/area-system-formats-asn1, @vcsjones Issue DetailsPropagated RequiresDynamicCode warning for the Marshal.SizeOf API for the library to be warning free The generic APIs version of these APIs could be made to use the generic version and be safe but currently they are generating warnings since they go through the non-generic APIs.
|
src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnDecoder.Enumerated.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Marshal.SizeOf API for the library to be warning free
This is easy to change to not use Marshal.SizeOf. For example, define following method somewhere:
static int GetPrimitiveIntegerSize(Type primitiveType)
{
if (primitiveType == typeof(byte) || primitiveType == typeof(sbyte))
return 1;
if (primitiveType == typeof(short) || primitiveType == typeof(ushort))
return 2;
if (primitiveType == typeof(int) || primitiveType == typeof(uint))
return 4;
if (primitiveType == typeof(long) || primitiveType == typeof(ulong))
return 8;
return 0;
}
and use it instead of Marshal.SizeOf.
I recommend approximately ish |
src/libraries/System.Formats.Asn1/src/System.Formats.Asn1.csproj
Outdated
Show resolved
Hide resolved
|
/azp run runtime-extra-platforms |
|
Azure Pipelines successfully started running 1 pipeline(s). |
src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs
Outdated
Show resolved
Hide resolved
bartonjs
left a comment
There was a problem hiding this comment.
Rescinding approval based on unresolved feedback in new changes.
src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs
Outdated
Show resolved
Hide resolved
|
/azp run runtime-extra-platforms |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run runtime-extra-platforms |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Instead of using Marshal.SizeOf API which causes an AOT warning, wrote a separate implementation as suggested in feedback below to read the size of an enum's underlying type
Enabled the test project to run in AOT rolling run by excluding test scenarios that rely on creating a delegate that has a boxed by-ref parameter, issue #72548 tracks this failure