Roslyn: CSharpFixerWithFixAllAnalyzer throws TypeInitializationException during compile after update to VS2015.1

Created on 7 Dec 2015  路  4Comments  路  Source: dotnet/roslyn

After update to VS2015 Update1, existing analyzer fails to build with error:

1>------ Rebuild All started: Project: CodeContractNullability, Configuration: Debug Any CPU ------
1>CSC : error AD0001: Analyzer 'Microsoft.CodeAnalysis.CSharp.Analyzers.FixAnalyzers.CSharpFixerWithFixAllAnalyzer' threw an exception of type 'System.TypeInitializationException' with message 'The type initializer for 'Microsoft.CodeAnalysis.Analyzers.FixAnalyzers.FixerWithFixAllAnalyzer`1' threw an exception.'.
2>------ Rebuild All started: Project: CodeContractNullability.Vsix, Configuration: Debug Any CPU ------
3>------ Rebuild All started: Project: CodeContractNullability.Test, Configuration: Debug Any CPU ------
2>CSC : error CS0006: Metadata file 'D:\Bart\Source\Repos\ResharperCodeContractNullability\src\CodeContractNullability\CodeContractNullability\bin\Debug\CodeContractNullability.dll' could not be found
3>CSC : error CS0006: Metadata file 'D:\Bart\Source\Repos\ResharperCodeContractNullability\src\CodeContractNullability\CodeContractNullability\bin\Debug\CodeContractNullability.dll' could not be found
========== Rebuild All: 0 succeeded, 3 failed, 0 skipped ==========

Repro: download source from https://github.com/bkoelman/ResharperCodeContractNullability and open src\ResharperCodeContractNullability.sln. Builds without errors in VS2015 RTM.

Area-Analyzers

Most helpful comment

Do you have version 1.0 of Microsoft.CodeAnalysis.Analyzers? There was a bug in that version that's been fixed in 1.1

All 4 comments

Do you have version 1.0 of Microsoft.CodeAnalysis.Analyzers? There was a bug in that version that's been fixed in 1.1

yes, that fixes my problem.
Thanks!

@srivatsn can you share what the problem was? Why would one get a typeinitializaitonexception?

https://github.com/dotnet/roslyn/pull/3708 fixed the issue. The problem always existed but since it was only showing up on commandline builds and AD001 was info and hence not reported on the commandline during RTM, we missed it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MadsTorgersen picture MadsTorgersen  路  120Comments

MadsTorgersen picture MadsTorgersen  路  542Comments

davidroth picture davidroth  路  158Comments

MgSam picture MgSam  路  152Comments

gafter picture gafter  路  147Comments