- Notifications
You must be signed in to change notification settings - Fork5.1k
Implement RuntimeHelpers.SizeOf#100618
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
ghost commentedApr 3, 2024
Note regarding the
|
...em.Runtime/tests/System.Runtime.Tests/System/Runtime/CompilerServices/RuntimeHelpersTests.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
...coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.CoreCLR.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
...veaot/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.NativeAot.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/mono/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.Mono.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
...em.Runtime/tests/System.Runtime.Tests/System/Runtime/CompilerServices/RuntimeHelpersTests.csShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
...em.Runtime/tests/System.Runtime.Tests/System/Runtime/CompilerServices/RuntimeHelpersTests.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
…/Runtime/CompilerServices/RuntimeHelpersTests.csCo-authored-by: Jan Kotas <jkotas@microsoft.com>
Uh oh!
There was an error while loading.Please reload this page.
...coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.CoreCLR.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
...coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.CoreCLR.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
...em.Runtime/tests/System.Runtime.Tests/System/Runtime/CompilerServices/RuntimeHelpersTests.csShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
...veaot/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.NativeAot.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
...coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.CoreCLR.csShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
/// <returns>The size of instances of the type.</returns> | ||
/// <exception cref="ArgumentException">The passed-in type is not a valid type to get the size of.</exception> | ||
/// <remarks> | ||
/// This API has the same behavior as if you were to use the IL sizeof instruction with the passed in type as the operand. |
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.
/// This APIhas the samebehavior as if you were to use the IL sizeof instruction with the passed in type as the operand. | |
/// This APIreturns the samevalue as the IL sizeof instruction with the passed in type as the operand. |
Nit: It does not have the same behavior for error cases.
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.
Or maybe even link tohttps://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.unsafe.sizeof that has more details.
# Conflicts:#src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.CoreCLR.cs#src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.NativeAot.cs#src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Runtime/CompilerServices/RuntimeHelpersTests.cs#src/mono/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.Mono.cs#src/mono/mono/metadata/icall.c
Type typeObj = Type.GetTypeFromHandle(type)!; | ||
if (typeObj.ContainsGenericParameters || typeObj.IsGenericParameter || typeObj == typeof(void)) | ||
throw new ArgumentException(SR.Arg_TypeNotSupported); |
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.
Is this a limitation of mono runtime (which doesn't exist in coreclr)?
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.
No, this is the same limitation in CoreCLR and NativeAOT (though the implementations are slightly different due to how the different type systems are implemented).
/ba-g Slow mac timeout |
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
Fixes#97344
Implement the SizeOf API with the same behavior as the
sizeof
IL instruction.