Skip to content
This repository was archived by the owner on Nov 13, 2026. It is now read-only.

Add an option to only generate metadata for complete types - #6149

Merged
MichalStrehovsky merged 1 commit into
dotnet:masterfrom
MichalStrehovsky:missingMdDiagnostics
Jul 30, 2018
Merged

MichalStrehovsky merged 1 commit into
dotnet:masterfrom
MichalStrehovsky:missingMdDiagnostics

Conversation

@MichalStrehovsky

Copy link
Copy Markdown
Member

When the option is set, metadata generation at the type level becomes all or nothing - either the entire type gets metadata, or none of it gets it. This makes a certain class of missing metadata issues easier to troubleshoot.

In particular, the failure mode of this program:

using System;

internal class Program
{
    public static void Do()
    {
        Console.WriteLine("Hello world");
    }

    private static void Main(string[] args)
    {
        typeof(Program).GetMethod("Do").Invoke(null, Array.Empty<object>());
    }
}

Changes from a NullReferenceException at the .Invoke part to a "This object cannot be invoked because it was metadata-enabled for browsing only: 'Program.Do()' For more information, please visit http://go.microsoft.com/fwlink/?LinkID=616867" message.

Should turn #6142 and similar into a self-service solution.

When the option is set, metadata generation at the type level becomes all or nothing - either the entire type gets metadata, or none of it gets it. This makes a certain class of missing metadata issues easier to troubleshoot.
@MichalStrehovsky
MichalStrehovsky merged commit ba8cd58 into dotnet:master Jul 30, 2018
@MichalStrehovsky
MichalStrehovsky deleted the missingMdDiagnostics branch July 30, 2018 06:33
@MichalStrehovsky

Copy link
Copy Markdown
Member Author

Just for the record, enabling this option causes about 6% size on disk regression for ASP.NET plaintext app. Half of the regression is in the metadata alone, the other half seems to be because we promoted a bunch of C# generated state machine classes to constructed types (I assume because they show up in a typeof of custom attributes).

So while this would be nice to have enabled by default, it probably goes in the same bucket as to why we don't want to enable stack trace metadata by default. Making apps bigger is easy, making them small is hard.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants