-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Annotating System.Formats.Asn1 library for Aot #72533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 runtime/src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnDecoder.cs Lines 467 to 469 in 62eb291
ish |
src/libraries/System.Formats.Asn1/src/System.Formats.Asn1.csproj
Outdated
Show resolved
Hide resolved
jkotas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks!
|
/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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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). |
jkotas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM otherwise
|
/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