Skip to content
This repository has been archived by the owner. It is now read-only.

The type initializer for 'RefactoringEssentials.TypeExtensions' threw an exception #165

Closed
vgrigoriu opened this issue Jan 18, 2016 · 6 comments
Assignees
Labels
Milestone

Comments

@vgrigoriu
Copy link

For this project, the build in VS 2015 Update 1 fails with the following errors:

1>CSC : error AD0001: Analyzer 'RefactoringEssentials.CSharp.Diagnostics.ReplaceWithSingleCallToSingleOrDefaultAnalyzer' threw an exception of type 'System.TypeInitializationException' with message 'The type initializer for 'RefactoringEssentials.TypeExtensions' threw an exception.'.
1>CSC : error AD0001: Analyzer 'RefactoringEssentials.CSharp.Diagnostics.ReplaceWithOfTypeWhereAnalyzer' threw an exception of type 'System.TypeInitializationException' with message 'The type initializer for 'RefactoringEssentials.TypeExtensions' threw an exception.'.
1>CSC : error AD0001: Analyzer 'RefactoringEssentials.CSharp.Diagnostics.ReplaceWithSingleCallToLastAnalyzer' threw an exception of type 'System.TypeInitializationException' with message 'The type initializer for 'RefactoringEssentials.TypeExtensions' threw an exception.'.
1>CSC : error AD0001: Analyzer 'RefactoringEssentials.CSharp.Diagnostics.ReplaceWithOfTypeSingleOrDefaultAnalyzer' threw an exception of type 'System.TypeInitializationException' with message 'The type initializer for 'RefactoringEssentials.TypeExtensions' threw an exception.'.
1>CSC : error AD0001: Analyzer 'RefactoringEssentials.CSharp.Diagnostics.ReplaceWithOfTypeLongCountAnalyzer' threw an exception of type 'System.TypeInitializationException' with message 'The type initializer for 'RefactoringEssentials.TypeExtensions' threw an exception.'.
1>CSC : error AD0001: Analyzer 'RefactoringEssentials.CSharp.Diagnostics.ReplaceWithSingleCallToFirstOrDefaultAnalyzer' threw an exception of type 'System.TypeInitializationException' with message 'The type initializer for 'RefactoringEssentials.TypeExtensions' threw an exception.'.
1>CSC : error AD0001: Analyzer 'RefactoringEssentials.CSharp.Diagnostics.ReplaceWithOfTypeSingleAnalyzer' threw an exception of type 'System.TypeInitializationException' with message 'The type initializer for 'RefactoringEssentials.TypeExtensions' threw an exception.'.
1>CSC : error AD0001: Analyzer 'RefactoringEssentials.CSharp.Diagnostics.ConvertConditionalTernaryToNullCoalescingAnalyzer' threw an exception of type 'System.IO.FileNotFoundException' with message 'Could not load file or assembly 'Microsoft.CodeAnalysis.Workspaces, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.'.
1>CSC : error AD0001: Analyzer 'RefactoringEssentials.CSharp.Diagnostics.ReplaceWithSingleCallToLongCountAnalyzer' threw an exception of type 'System.TypeInitializationException' with message 'The type initializer for 'RefactoringEssentials.TypeExtensions' threw an exception.'.
1>CSC : error AD0001: Analyzer 'RefactoringEssentials.CSharp.Diagnostics.ReplaceWithOfTypeLastAnalyzer' threw an exception of type 'System.TypeInitializationException' with message 'The type initializer for 'RefactoringEssentials.TypeExtensions' threw an exception.'.
1>CSC : error AD0001: Analyzer 'RefactoringEssentials.CSharp.Diagnostics.ReplaceWithOfTypeFirstAnalyzer' threw an exception of type 'System.TypeInitializationException' with message 'The type initializer for 'RefactoringEssentials.TypeExtensions' threw an exception.'.
1>CSC : error AD0001: Analyzer 'RefactoringEssentials.CSharp.Diagnostics.ReplaceWithOfTypeLastOrDefaultAnalyzer' threw an exception of type 'System.TypeInitializationException' with message 'The type initializer for 'RefactoringEssentials.TypeExtensions' threw an exception.'.
1>CSC : error AD0001: Analyzer 'RefactoringEssentials.CSharp.Diagnostics.ReplaceWithSingleCallToCountAnalyzer' threw an exception of type 'System.TypeInitializationException' with message 'The type initializer for 'RefactoringEssentials.TypeExtensions' threw an exception.'.
1>CSC : error AD0001: Analyzer 'RefactoringEssentials.CSharp.Diagnostics.ReplaceWithSingleCallToLastOrDefaultAnalyzer' threw an exception of type 'System.TypeInitializationException' with message 'The type initializer for 'RefactoringEssentials.TypeExtensions' threw an exception.'.
1>CSC : error AD0001: Analyzer 'RefactoringEssentials.CSharp.Diagnostics.ReplaceWithOfTypeFirstOrDefaultAnalyzer' threw an exception of type 'System.TypeInitializationException' with message 'The type initializer for 'RefactoringEssentials.TypeExtensions' threw an exception.'.
1>CSC : error AD0001: Analyzer 'RefactoringEssentials.CSharp.Diagnostics.SimplifyConditionalTernaryExpressionAnalyzer' threw an exception of type 'System.IO.FileNotFoundException' with message 'Could not load file or assembly 'Microsoft.CodeAnalysis.Workspaces, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.'.
1>CSC : error AD0001: Analyzer 'RefactoringEssentials.CSharp.Diagnostics.ReplaceWithSingleCallToAnyAnalyzer' threw an exception of type 'System.TypeInitializationException' with message 'The type initializer for 'RefactoringEssentials.TypeExtensions' threw an exception.'.
1>CSC : error AD0001: Analyzer 'RefactoringEssentials.CSharp.Diagnostics.ReplaceWithOfTypeCountAnalyzer' threw an exception of type 'System.TypeInitializationException' with message 'The type initializer for 'RefactoringEssentials.TypeExtensions' threw an exception.'.
1>CSC : error AD0001: Analyzer 'RefactoringEssentials.CSharp.Diagnostics.ReplaceWithSingleCallToFirstAnalyzer' threw an exception of type 'System.TypeInitializationException' with message 'The type initializer for 'RefactoringEssentials.TypeExtensions' threw an exception.'.
1>CSC : error AD0001: Analyzer 'RefactoringEssentials.CSharp.Diagnostics.ReplaceWithSingleCallToSingleAnalyzer' threw an exception of type 'System.TypeInitializationException' with message 'The type initializer for 'RefactoringEssentials.TypeExtensions' threw an exception.'.
1>CSC : error AD0001: Analyzer 'RefactoringEssentials.CSharp.Diagnostics.ReplaceWithOfTypeAnyAnalyzer' threw an exception of type 'System.TypeInitializationException' with message 'The type initializer for 'RefactoringEssentials.TypeExtensions' threw an exception.'.
1>CSC : error AD0001: Analyzer 'RefactoringEssentials.CSharp.Diagnostics.RedundantExplicitNullableCreationAnalyzer' threw an exception of type 'System.TypeInitializationException' with message 'The type initializer for 'RefactoringEssentials.TypeExtensions' threw an exception.'.

Let me know if there are additional info I can provide you.

@Rpinski
Copy link
Member

Rpinski commented Jan 19, 2016

Which version of RefactoringEssentials is installed?

@vgrigoriu
Copy link
Author

3.1.0, the latest from nuget. I didn't install the vsix.
În Mar, 19 ian. 2016 la 07:43 Andreas Weizel [email protected] a
scris:

Which version of RefactoringEssentials is installed?


Reply to this email directly or view it on GitHub
#165 (comment)
.

@Rpinski Rpinski added the bug label Jan 20, 2016
@Rpinski Rpinski self-assigned this Jan 21, 2016
@Rpinski
Copy link
Member

Rpinski commented Jan 22, 2016

Reproducible with any simple project and the NuGet analyzer package. The only difference is that with a new empty project I see those messages as warnings, not as errors. It only affects compiling, analyzers work inside of VS code editor (means that the VSIX doesn't suffer that problem).

It looks like the reason is related to what is described here:
dotnet/roslyn#7929 (comment)
"Microsoft.CodeAnalysis.Workspaces" and "Microsoft.CodeAnalysis.CSharp.Workspaces" don't seem to be loaded by command-line compiler.

I'll review those code parts to assure nothing from the *Workspaces assemblies is accessed by analyzers and hope that it will solve this issue.

@vgrigoriu
Copy link
Author

I have Treat Warnings as Errors set to true for the project. One workaround is to add an exception for just this error:

<WarningsNotAsErrors>AD0001</WarningsNotAsErrors>

@Rpinski Rpinski modified the milestone: 3.x Feb 3, 2016
@JabX
Copy link

JabX commented Feb 23, 2016

Hello,
I have the latest version (3.2) and I still get those same warnings when adding RefactoringEssentials as an analyser on my projects.
Wasn't it fixed ?
Thanks.

@Rpinski
Copy link
Member

Rpinski commented Feb 23, 2016

Most of them were fixed, but some warnings remained and needed additional work. See #170.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants