Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
jkoritzinsky merged 17 commits intodotnet:mainfromjkoritzinsky:sizeof
Apr 9, 2024
Merged

Conversation

jkoritzinsky
Copy link
Member

Fixes#97344

Implement the SizeOf API with the same behavior as thesizeof IL instruction.

0xfeeddeadbeef reacted with hooray emoji
@ghost
Copy link

Note regarding thenew-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, 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.

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
…/Runtime/CompilerServices/RuntimeHelpersTests.csCo-authored-by: Jan Kotas <jkotas@microsoft.com>
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
/// 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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

# 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);
Copy link
Member

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)?

Copy link
MemberAuthor

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).

am11 reacted with thumbs up emoji
@jkoritzinsky
Copy link
MemberAuthor

/ba-g Slow mac timeout

@jkoritzinskyjkoritzinsky merged commitf54c778 intodotnet:mainApr 9, 2024
@jkoritzinskyjkoritzinsky deleted the sizeof branchApril 9, 2024 19:55
matouskozak pushed a commit to matouskozak/runtime that referenced this pull requestApr 30, 2024
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsMay 10, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@am11am11am11 left review comments

@jkotasjkotasjkotas approved these changes

@lambdageeklambdageekAwaiting requested review from lambdageek

@thaystgthaystgAwaiting requested review from thaystgthaystg is a code owner

@marek-safarmarek-safarAwaiting requested review from marek-safar

@MichalStrehovskyMichalStrehovskyAwaiting requested review from MichalStrehovskyMichalStrehovsky is a code owner

Assignees

@jkoritzinskyjkoritzinsky

Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

[API Proposal]: Get the managed size of a System.Type instance
3 participants
@jkoritzinsky@am11@jkotas

[8]ページ先頭

©2009-2025 Movatter.jp