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

[Proposal]: Caller info attribute for passing caller identity implicitly #9018

Open
jaredpar opened this issue Jan 6, 2025 · 0 comments
Open
Assignees

Comments

@jaredpar
Copy link
Member

jaredpar commented Jan 6, 2025

Caller info attribute for passing caller identity implicitly

Summary

namespace System.Runtime.CompilerServices
{
    [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
    public sealed class CallerIdentityAttribute : Attribute
    {
        public CallerIdentityAttribute();
    }
}

This attribute can be applied to parameters of type System.Reflection.Assembly, System.Reflection.Type, System.Reflection.MethodBase. When the C# compiler sees parameter tagged with this attribute, it will provide default value for it, according to the caller context:

  • System.Reflection.Assembly: typeof(containing_type).Assembly
  • System.Reflection.Type: typeof(containing_type)
  • System.Reflection.MethodBase: MethodBase.GetMethodFromHandle(ldtoken containing_method)

Design meetings

@jaredpar jaredpar self-assigned this Jan 6, 2025
@dotnet dotnet locked and limited conversation to collaborators Jan 6, 2025
@333fred 333fred added this to the Needs More Work milestone Jan 13, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants