Skip to content
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

UnsafeAccessor works on non-static methods #87881

Closed
vitek-karas opened this issue Jun 21, 2023 · 2 comments · Fixed by #87936
Closed

UnsafeAccessor works on non-static methods #87881

vitek-karas opened this issue Jun 21, 2023 · 2 comments · Fixed by #87936

Comments

@vitek-karas
Copy link
Member

    class InstanceAccessors
    {
        public InstanceAccessors() { }

        [UnsafeAccessor(UnsafeAccessorKind.Constructor)]
        public extern InstanceAccessors UnsafeNonStaticAccessorForConstructor();
    }

   void Test()
   {
       (new InstanceAccessors()).InstanceAccessors(); // Works
   }

Per the proposal #81741, the attribute should only be effective on static methods. It's also not clear what it means on instance methods.

@AaronRobinsonMSFT

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Jun 21, 2023
@ghost
Copy link

ghost commented Jun 21, 2023

Tagging subscribers to this area: @dotnet/area-system-runtime-compilerservices
See info in area-owners.md if you want to be subscribed.

Issue Details
    class InstanceAccessors
    {
        public InstanceAccessors() { }

        [UnsafeAccessor(UnsafeAccessorKind.Constructor)]
        public extern InstanceAccessors UnsafeNonStaticAccessorForConstructor();
    }

   void Test()
   {
       (new InstanceAccessors()).InstanceAccessors(); // Works
   }

Per the proposal #81741, the attribute should only be effective on static methods. It's also not clear what it means on instance methods.

@AaronRobinsonMSFT

Author: vitek-karas
Assignees: -
Labels:

area-System.Runtime.CompilerServices

Milestone: -

@AaronRobinsonMSFT
Copy link
Member

the attribute should only be effective on static methods

Yep. I will add a run-time check for CoreCLR and a compile time check in NativeAOT.

/cc @fanyang-mono @jkotas

@AaronRobinsonMSFT AaronRobinsonMSFT removed the untriaged New issue has not been triaged by the area owner label Jun 22, 2023
@AaronRobinsonMSFT AaronRobinsonMSFT self-assigned this Jun 22, 2023
@AaronRobinsonMSFT AaronRobinsonMSFT added this to the 8.0.0 milestone Jun 22, 2023
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Jun 22, 2023
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Jun 22, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Jul 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants