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

Linker should recognize GetType() on sealed local variables #1218

Open
eerhardt opened this issue May 27, 2020 · 1 comment
Open

Linker should recognize GetType() on sealed local variables #1218

eerhardt opened this issue May 27, 2020 · 1 comment

Comments

@eerhardt
Copy link
Member

When passing in variable.GetType() into a method that is annotated with DynamicallyAccessedMembers, the linker should be able to statically infer the Type if the Type of the variable is sealed. However, the linker is not preserving the correct members on the Type in this situation.

For example,

    public class TraceLoggingEventTypes
    {
        internal TraceLoggingEventTypes(
            string name,
            EventTags tags,
            [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] Type type)
...
    var msg = new { message = msgString };
    var tlet = new TraceLoggingEventTypes(EventName, EventTags.None, msg.GetType());

When linking code like the above, the message property is getting trimmed from the anonymous type.

See my attempted code change for this scenario in EventSource.

cc @vitek-karas @MichalStrehovsky

@vitek-karas
Copy link
Member

This is a very similar problem to dotnet/runtime#93720
If we implement some type of strongly typed stack, then this could be easily added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

3 participants