Uh oh!
There was an error while loading. Please reload this page.
Implement RuntimeHelpers.SizeOf - #100618
Conversation
ghost
commented
Apr 3, 2024
Note regarding the |
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.
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.
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…/Runtime/CompilerServices/RuntimeHelpersTests.cs Co-authored-by: Jan Kotas <jkotas@microsoft.com>
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.
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.
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.
| /// This API has the same behavior as if you were to use the IL sizeof instruction with the passed in type as the operand. | |
| /// This API returns the same value 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.
Or maybe even link to https://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.
Is this a limitation of mono runtime (which doesn't exist in coreclr)?
There was a problem hiding this comment.
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).
jkoritzinsky
commented
Apr 9, 2024
/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
sizeofIL instruction.