Skip to content

[ilverify] Using ilverify with --include-file, --exclude-file or --ignore-error-file gives a System.NullReferenceException #62012

@Haarmees

Description

@Haarmees

Description

When using any of the "file" options (--include-file, --exclude-file or --ignore-error-file) with the ilverify tool a System.NullReferenceException is thrown. I looked into it and this happens because the code tries to get the length on the "non-file" variants of these options:

string[] includePatterns = options.Include;
if (options.IncludeFile != null)
{
    if (options.Include.Length != 0)
        WriteLine("[Warning] --include-file takes precedence over --include");
    includePatterns = File.ReadAllLines(options.IncludeFile.FullName);
}

Here options.Include is null, because the option is not given when running the command.

Reproduction Steps

Run ILVerify with either --include-file, --exclude-file or --ignore-error-file, but not --include, --exclude or --ignore-error. For example:

ilverify .\MyCode.dll --include-file .\include.txt
ilverify .\MyCode.dll --exclude-file .\exclude.txt
ilverify .\MyCode.dll --ignore-error-file .\ignore.txt

Expected behavior

Expected behavior is that the tool gives no System.NullReferenceException and uses the entries in the file.

Actual behavior

Actual behavior is that a System.NullReferenceException is thrown:

Error: System.NullReferenceException: Object reference not set to an instance of an object.
   at ILVerify.Program..ctor(Options options)
   at ILVerify.Program.Run(Options options)

Regression?

No response

Known Workarounds

A workaround is to also define the 'non-file' options, when using a 'file' option. For example:

ilverify .\MyCode.dll --include-file .\include.txt --include DummyInclude
ilverify .\MyCode.dll --exclude-file .\exclude.txt --exclude DummyExclude
ilverify .\MyCode.dll --ignore-error-file .\ignore.txt --ignore-error DummyIgnore

Configuration

Version 6.0.0 of the ilverify tool: https://www.nuget.org/packages/dotnet-ilverify/

Other information

Created PR that should fixe this: #62013

Metadata

Metadata

Assignees

No one assigned

    Labels

    untriagedNew issue has not been triaged by the area owner

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions