Skip to content

"Expected a null constant." error when saving assembly with pdb #550

@maxkatz6

Description

@maxkatz6

I noticed this issue only happens when I used "local const" in the code, specifically when const type is an enum from another assembly.
For example, this method:

public static bool IsMatch(string text, string pattern, CompareInfo compareInfo)
{
    const CompareOptions options = CompareOptions.IgnoreSymbols | CompareOptions.StringSort | CompareOptions.IgnoreNonSpace;
    return compareInfo.Compare(text, pattern, options) == 0;
}

Simply replacing const CompareOptions options with CompareOptions options will fix the problem, so we have a workaround, though this bug is confusing.
Repro project (both dll project and executable console app):

ClassLibrary1.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions