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

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

Closed
Haarmees opened this issue Nov 24, 2021 · 1 comment · Fixed by #62013
Labels
untriaged New issue has not been triaged by the area owner

Comments

@Haarmees
Copy link
Contributor

Haarmees commented Nov 24, 2021

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

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Nov 24, 2021
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@Haarmees Haarmees changed the title [ilverify] Using --include-file, --exclude-file or --ignore-error-file gives a System.NullReferenceException [ilverify] Using ilverify with --include-file, --exclude-file or --ignore-error-file gives a System.NullReferenceException Nov 24, 2021
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Nov 24, 2021
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Nov 24, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Dec 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
untriaged New issue has not been triaged by the area owner
Projects
None yet
1 participant