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

AD0001: Occasional InvalidOperationException error in analyzer in IDE #794

Closed
zlepper opened this issue Nov 20, 2024 · 5 comments · Fixed by #805
Closed

AD0001: Occasional InvalidOperationException error in analyzer in IDE #794

zlepper opened this issue Nov 20, 2024 · 5 comments · Fixed by #805
Milestone

Comments

@zlepper
Copy link

zlepper commented Nov 20, 2024

I'm not entirely sure what reproduces this, however I do occasionally get a ton of these analyzer errors in the same file:

AD0001: Analyzer 'NUnit.Analyzers.ConstActualValueUsage.ConstActualValueUsageAnalyzer' threw an exception of type 'System.InvalidOperationException' with message 'Sequence contains more than one matching element'. Exception occurred with following context: Compilation: ConfigService.Tests System.InvalidOperationException: Sequence contains more than one matching element at System.Linq.ThrowHelper.ThrowMoreThanOneMatchException() at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found) at NUnit.Analyzers.BaseAssertionAnalyzer.AnalyzeCompilationStart(CompilationStartAnalysisContext context) at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info, CancellationToken cancellationToken) in Z:\BuildAgent\work\3b7ce003563d6f8f\src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 1191 ----- Suppress the following diagnostics to disable this analyzer: NUnit2007

It only seems to happen in my IDE (At least I have never seen it happen when doing dotnet build), and it usually goes away pretty fast. I would guess it happens because of some code that is invalid for a short moment. When the error occurs the entire screen overflows with errors at once.

I can't send you a file it happens on, as I cannot share code from work, but it seems to usually be larger test files.

NUnit version: 4.2.2
NUnit.Analyzers version: 4.4.0

Using JetBrains Rider with dotnet version 8.0.303.

I'm sorry that it's not a whole lot to work from :(

@zlepper
Copy link
Author

zlepper commented Nov 20, 2024

Here's a larger chunk of errors:

AD0001: Analyzer 'NUnit.Analyzers.NullConstraintUsage.NullConstraintUsageAnalyzer' threw an exception of type 'System.InvalidOperationException' with message 'Sequence contains more than one matching element'. Exception occurred with following context: Compilation: Digizuite.ConfigurationManagementService.Tests System.InvalidOperationException: Sequence contains more than one matching element at System.Linq.ThrowHelper.ThrowMoreThanOneMatchException() at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found) at NUnit.Analyzers.BaseAssertionAnalyzer.AnalyzeCompilationStart(CompilationStartAnalysisContext context) at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info, CancellationToken cancellationToken) in Z:\BuildAgent\work\3b7ce003563d6f8f\src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 1191 ----- Suppress the following diagnostics to disable this analyzer: NUnit2023
AD0001: Analyzer 'NUnit.Analyzers.IgnoreCaseUsage.IgnoreCaseUsageAnalyzer' threw an exception of type 'System.InvalidOperationException' with message 'Sequence contains more than one matching element'. Exception occurred with following context: Compilation: Digizuite.ConfigurationManagementService.Tests System.InvalidOperationException: Sequence contains more than one matching element at System.Linq.ThrowHelper.ThrowMoreThanOneMatchException() at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found) at NUnit.Analyzers.BaseAssertionAnalyzer.AnalyzeCompilationStart(CompilationStartAnalysisContext context) at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info, CancellationToken cancellationToken) in Z:\BuildAgent\work\3b7ce003563d6f8f\src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 1191 ----- Suppress the following diagnostics to disable this analyzer: NUnit2008
AD0001: Analyzer 'NUnit.Analyzers.ConstraintUsage.EqualConstraintUsageAnalyzer' threw an exception of type 'System.InvalidOperationException' with message 'Sequence contains more than one matching element'. Exception occurred with following context: Compilation: Digizuite.ConfigurationManagementService.Tests System.InvalidOperationException: Sequence contains more than one matching element at System.Linq.ThrowHelper.ThrowMoreThanOneMatchException() at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found) at NUnit.Analyzers.BaseAssertionAnalyzer.AnalyzeCompilationStart(CompilationStartAnalysisContext context) at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info, CancellationToken cancellationToken) in Z:\BuildAgent\work\3b7ce003563d6f8f\src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 1191 ----- Suppress the following diagnostics to disable this analyzer: NUnit2010
AD0001: Analyzer 'NUnit.Analyzers.WithinUsage.WithinUsageAnalyzer' threw an exception of type 'System.InvalidOperationException' with message 'Sequence contains more than one matching element'. Exception occurred with following context: Compilation: Digizuite.ConfigurationManagementService.Tests System.InvalidOperationException: Sequence contains more than one matching element at System.Linq.ThrowHelper.ThrowMoreThanOneMatchException() at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found) at NUnit.Analyzers.BaseAssertionAnalyzer.AnalyzeCompilationStart(CompilationStartAnalysisContext context) at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info, CancellationToken cancellationToken) in Z:\BuildAgent\work\3b7ce003563d6f8f\src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 1191 ----- Suppress the following diagnostics to disable this analyzer: NUnit2047
AD0001: Analyzer 'NUnit.Analyzers.SameActualExpectedValue.SameActualExpectedValueAnalyzer' threw an exception of type 'System.InvalidOperationException' with message 'Sequence contains more than one matching element'. Exception occurred with following context: Compilation: Digizuite.ConfigurationManagementService.Tests System.InvalidOperationException: Sequence contains more than one matching element at System.Linq.ThrowHelper.ThrowMoreThanOneMatchException() at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found) at NUnit.Analyzers.BaseAssertionAnalyzer.AnalyzeCompilationStart(CompilationStartAnalysisContext context) at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info, CancellationToken cancellationToken) in Z:\BuildAgent\work\3b7ce003563d6f8f\src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 1191 ----- Suppress the following diagnostics to disable this analyzer: NUnit2009
AD0001: Analyzer 'NUnit.Analyzers.ClassicModelAssertUsage.ClassicModelAssertUsageAnalyzer' threw an exception of type 'System.InvalidOperationException' with message 'Sequence contains more than one matching element'. Exception occurred with following context: Compilation: Digizuite.ConfigurationManagementService.Tests System.InvalidOperationException: Sequence contains more than one matching element at System.Linq.ThrowHelper.ThrowMoreThanOneMatchException() at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found) at NUnit.Analyzers.BaseAssertionAnalyzer.AnalyzeCompilationStart(CompilationStartAnalysisContext context) at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info, CancellationToken cancellationToken) in Z:\BuildAgent\work\3b7ce003563d6f8f\src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 1191 ----- Suppress the following diagnostics to disable this analyzer: NUnit2001, NUnit2002, NUnit2003, NUnit2004, NUnit2005, NUnit2006, NUnit2015, NUnit2016, NUnit2017, NUnit2018, NUnit2019, NUnit2027, NUnit2028, NUnit2029, NUnit2030, NUnit2031, NUnit2032, NUnit2033, NUnit2034, NUnit2035, NUnit2036, NUnit2037, NUnit2038, NUnit2039
AD0001: Analyzer 'NUnit.Analyzers.SameAsIncompatibleTypes.SameAsIncompatibleTypesAnalyzer' threw an exception of type 'System.InvalidOperationException' with message 'Sequence contains more than one matching element'. Exception occurred with following context: Compilation: Digizuite.ConfigurationManagementService.Tests System.InvalidOperationException: Sequence contains more than one matching element at System.Linq.ThrowHelper.ThrowMoreThanOneMatchException() at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found) at NUnit.Analyzers.BaseAssertionAnalyzer.AnalyzeCompilationStart(CompilationStartAnalysisContext context) at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info, CancellationToken cancellationToken) in Z:\BuildAgent\work\3b7ce003563d6f8f\src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 1191 ----- Suppress the following diagnostics to disable this analyzer: NUnit2020
AD0001: Analyzer 'NUnit.Analyzers.StringAssertUsage.StringAssertUsageAnalyzer' threw an exception of type 'System.InvalidOperationException' with message 'Sequence contains more than one matching element'. Exception occurred with following context: Compilation: Digizuite.ConfigurationManagementService.Tests System.InvalidOperationException: Sequence contains more than one matching element at System.Linq.ThrowHelper.ThrowMoreThanOneMatchException() at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found) at NUnit.Analyzers.BaseAssertionAnalyzer.AnalyzeCompilationStart(CompilationStartAnalysisContext context) at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info, CancellationToken cancellationToken) in Z:\BuildAgent\work\3b7ce003563d6f8f\src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 1191 ----- Suppress the following diagnostics to disable this analyzer: NUnit2048
AD0001: Analyzer 'NUnit.Analyzers.ConstraintUsage.StringConstraintUsageAnalyzer' threw an exception of type 'System.InvalidOperationException' with message 'Sequence contains more than one matching element'. Exception occurred with following context: Compilation: Digizuite.ConfigurationManagementService.Tests System.InvalidOperationException: Sequence contains more than one matching element at System.Linq.ThrowHelper.ThrowMoreThanOneMatchException() at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found) at NUnit.Analyzers.BaseAssertionAnalyzer.AnalyzeCompilationStart(CompilationStartAnalysisContext context) at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info, CancellationToken cancellationToken) in Z:\BuildAgent\work\3b7ce003563d6f8f\src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 1191 ----- Suppress the following diagnostics to disable this analyzer: NUnit2011, NUnit2012, NUnit2013
AD0001: Analyzer 'NUnit.Analyzers.EqualToIncompatibleTypes.EqualToIncompatibleTypesAnalyzer' threw an exception of type 'System.InvalidOperationException' with message 'Sequence contains more than one matching element'. Exception occurred with following context: Compilation: Digizuite.ConfigurationManagementService.Tests System.InvalidOperationException: Sequence contains more than one matching element at System.Linq.ThrowHelper.ThrowMoreThanOneMatchException() at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found) at NUnit.Analyzers.BaseAssertionAnalyzer.AnalyzeCompilationStart(CompilationStartAnalysisContext context) at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info, CancellationToken cancellationToken) in Z:\BuildAgent\work\3b7ce003563d6f8f\src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 1191 ----- Suppress the following diagnostics to disable this analyzer: NUnit2021
AD0001: Analyzer 'NUnit.Analyzers.SameAsOnValueTypes.SameAsOnValueTypesAnalyzer' threw an exception of type 'System.InvalidOperationException' with message 'Sequence contains more than one matching element'. Exception occurred with following context: Compilation: Digizuite.ConfigurationManagementService.Tests System.InvalidOperationException: Sequence contains more than one matching element at System.Linq.ThrowHelper.ThrowMoreThanOneMatchException() at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found) at NUnit.Analyzers.BaseAssertionAnalyzer.AnalyzeCompilationStart(CompilationStartAnalysisContext context) at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info, CancellationToken cancellationToken) in Z:\BuildAgent\work\3b7ce003563d6f8f\src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 1191 ----- Suppress the following diagnostics to disable this analyzer: NUnit2040
AD0001: Analyzer 'NUnit.Analyzers.ConstraintUsage.SomeItemsConstraintUsageAnalyzer' threw an exception of type 'System.InvalidOperationException' with message 'Sequence contains more than one matching element'. Exception occurred with following context: Compilation: Digizuite.ConfigurationManagementService.Tests System.InvalidOperationException: Sequence contains more than one matching element at System.Linq.ThrowHelper.ThrowMoreThanOneMatchException() at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found) at NUnit.Analyzers.BaseAssertionAnalyzer.AnalyzeCompilationStart(CompilationStartAnalysisContext context) at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info, CancellationToken cancellationToken) in Z:\BuildAgent\work\3b7ce003563d6f8f\src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 1191 ----- Suppress the following diagnostics to disable this analyzer: NUnit2014
AD0001: Analyzer 'NUnit.Analyzers.StringConstraintWrongActualType.StringConstraintWrongActualTypeAnalyzer' threw an exception of type 'System.InvalidOperationException' with message 'Sequence contains more than one matching element'. Exception occurred with following context: Compilation: Digizuite.ConfigurationManagementService.Tests System.InvalidOperationException: Sequence contains more than one matching element at System.Linq.ThrowHelper.ThrowMoreThanOneMatchException() at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found) at NUnit.Analyzers.BaseAssertionAnalyzer.AnalyzeCompilationStart(CompilationStartAnalysisContext context) at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info, CancellationToken cancellationToken) in Z:\BuildAgent\work\3b7ce003563d6f8f\src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 1191 ----- Suppress the following diagnostics to disable this analyzer: NUnit2024
AD0001: Analyzer 'NUnit.Analyzers.SomeItemsIncompatibleTypes.SomeItemsIncompatibleTypesAnalyzer' threw an exception of type 'System.InvalidOperationException' with message 'Sequence contains more than one matching element'. Exception occurred with following context: Compilation: Digizuite.ConfigurationManagementService.Tests System.InvalidOperationException: Sequence contains more than one matching element at System.Linq.ThrowHelper.ThrowMoreThanOneMatchException() at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found) at NUnit.Analyzers.BaseAssertionAnalyzer.AnalyzeCompilationStart(CompilationStartAnalysisContext context) at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info, CancellationToken cancellationToken) in Z:\BuildAgent\work\3b7ce003563d6f8f\src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 1191 ----- Suppress the following diagnostics to disable this analyzer: NUnit2026
AD0001: Analyzer 'NUnit.Analyzers.ClassicModelAssertUsage.ClassicModelAssertUsageAnalyzer' threw an exception of type 'System.InvalidOperationException' with message 'Sequence contains more than one matching element'. Exception occurred with following context: Compilation: Digizuite.ConfigurationManagementService.Tests System.InvalidOperationException: Sequence contains more than one matching element at System.Linq.ThrowHelper.ThrowMoreThanOneMatchException() at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found) at NUnit.Analyzers.BaseAssertionAnalyzer.AnalyzeCompilationStart(CompilationStartAnalysisContext context) at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info, CancellationToken cancellationToken) in Z:\BuildAgent\work\3b7ce003563d6f8f\src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 1191 ----- Suppress the following diagnostics to disable this analyzer: NUnit2001, NUnit2002, NUnit2003, NUnit2004, NUnit2005, NUnit2006, NUnit2015, NUnit2016, NUnit2017, NUnit2018, NUnit2019, NUnit2027, NUnit2028, NUnit2029, NUnit2030, NUnit2031, NUnit2032, NUnit2033, NUnit2034, NUnit2035, NUnit2036, NUnit2037, NUnit2038, NUnit2039, NUnit2051, NUnit2052, NUnit2053, NUnit2054
AD0001: Analyzer 'NUnit.Analyzers.ComparableTypes.ComparableTypesAnalyzer' threw an exception of type 'System.InvalidOperationException' with message 'Sequence contains more than one matching element'. Exception occurred with following context: Compilation: Digizuite.ConfigurationManagementService.Tests System.InvalidOperationException: Sequence contains more than one matching element at System.Linq.ThrowHelper.ThrowMoreThanOneMatchException() at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found) at NUnit.Analyzers.BaseAssertionAnalyzer.AnalyzeCompilationStart(CompilationStartAnalysisContext context) at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info, CancellationToken cancellationToken) in Z:\BuildAgent\work\3b7ce003563d6f8f\src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 1191 ----- Suppress the following diagnostics to disable this analyzer: NUnit2041, NUnit2042
AD0001: Analyzer 'NUnit.Analyzers.DelegateRequired.DelegateRequiredAnalyzer' threw an exception of type 'System.InvalidOperationException' with message 'Sequence contains more than one matching element'. Exception occurred with following context: Compilation: Digizuite.ConfigurationManagementService.Tests System.InvalidOperationException: Sequence contains more than one matching element at System.Linq.ThrowHelper.ThrowMoreThanOneMatchException() at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found) at NUnit.Analyzers.BaseAssertionAnalyzer.AnalyzeCompilationStart(CompilationStartAnalysisContext context) at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info, CancellationToken cancellationToken) in Z:\BuildAgent\work\3b7ce003563d6f8f\src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 1191 ----- Suppress the following diagnostics to disable this analyzer: NUnit2044
AD0001: Analyzer 'NUnit.Analyzers.MissingProperty.MissingPropertyAnalyzer' threw an exception of type 'System.InvalidOperationException' with message 'Sequence contains more than one matching element'. Exception occurred with following context: Compilation: Digizuite.ConfigurationManagementService.Tests System.InvalidOperationException: Sequence contains more than one matching element at System.Linq.ThrowHelper.ThrowMoreThanOneMatchException() at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found) at NUnit.Analyzers.BaseAssertionAnalyzer.AnalyzeCompilationStart(CompilationStartAnalysisContext context) at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info, CancellationToken cancellationToken) in Z:\BuildAgent\work\3b7ce003563d6f8f\src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 1191 ----- Suppress the following diagnostics to disable this analyzer: NUnit2022
AD0001: Analyzer 'NUnit.Analyzers.UpdateStringFormatToInterpolatableString.UpdateStringFormatToInterpolatableStringAnalyzer' threw an exception of type 'System.InvalidOperationException' with message 'Sequence contains more than one matching element'. Exception occurred with following context: Compilation: Digizuite.ConfigurationManagementService.Tests System.InvalidOperationException: Sequence contains more than one matching element at System.Linq.ThrowHelper.ThrowMoreThanOneMatchException() at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found) at NUnit.Analyzers.BaseAssertionAnalyzer.AnalyzeCompilationStart(CompilationStartAnalysisContext context) at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info, CancellationToken cancellationToken) in Z:\BuildAgent\work\3b7ce003563d6f8f\src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 1191 ----- Suppress the following diagnostics to disable this analyzer: NUnit2050
AD0001: Analyzer 'NUnit.Analyzers.CollectionAssertUsage.CollectionAssertUsageAnalyzer' threw an exception of type 'System.InvalidOperationException' with message 'Sequence contains more than one matching element'. Exception occurred with following context: Compilation: Digizuite.ConfigurationManagementService.Tests System.InvalidOperationException: Sequence contains more than one matching element at System.Linq.ThrowHelper.ThrowMoreThanOneMatchException() at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found) at NUnit.Analyzers.BaseAssertionAnalyzer.AnalyzeCompilationStart(CompilationStartAnalysisContext context) at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info, CancellationToken cancellationToken) in Z:\BuildAgent\work\3b7ce003563d6f8f\src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 1191 ----- Suppress the following diagnostics to disable this analyzer: NUnit2049
AD0001: Analyzer 'NUnit.Analyzers.UseCollectionConstraint.UseCollectionConstraintAnalyzer' threw an exception of type 'System.InvalidOperationException' with message 'Sequence contains more than one matching element'. Exception occurred with following context: Compilation: Digizuite.ConfigurationManagementService.Tests System.InvalidOperationException: Sequence contains more than one matching element at System.Linq.ThrowHelper.ThrowMoreThanOneMatchException() at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found) at NUnit.Analyzers.BaseAssertionAnalyzer.AnalyzeCompilationStart(CompilationStartAnalysisContext context) at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info, CancellationToken cancellationToken) in Z:\BuildAgent\work\3b7ce003563d6f8f\src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 1191 ----- Suppress the following diagnostics to disable this analyzer: NUnit2046
AD0001: Analyzer 'NUnit.Analyzers.ConstActualValueUsage.ConstActualValueUsageAnalyzer' threw an exception of type 'System.InvalidOperationException' with message 'Sequence contains more than one matching element'. Exception occurred with following context: Compilation: Digizuite.ConfigurationManagementService.Tests System.InvalidOperationException: Sequence contains more than one matching element at System.Linq.ThrowHelper.ThrowMoreThanOneMatchException() at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found) at NUnit.Analyzers.BaseAssertionAnalyzer.AnalyzeCompilationStart(CompilationStartAnalysisContext context) at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info, CancellationToken cancellationToken) in Z:\BuildAgent\work\3b7ce003563d6f8f\src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 1191 ----- Suppress the following diagnostics to disable this analyzer: NUnit2007
AD0001: Analyzer 'NUnit.Analyzers.ConstraintUsage.ComparisonConstraintUsageAnalyzer' threw an exception of type 'System.InvalidOperationException' with message 'Sequence contains more than one matching element'. Exception occurred with following context: Compilation: Digizuite.ConfigurationManagementService.Tests System.InvalidOperationException: Sequence contains more than one matching element at System.Linq.ThrowHelper.ThrowMoreThanOneMatchException() at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found) at NUnit.Analyzers.BaseAssertionAnalyzer.AnalyzeCompilationStart(CompilationStartAnalysisContext context) at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info, CancellationToken cancellationToken) in Z:\BuildAgent\work\3b7ce003563d6f8f\src\Compilers\Core\Portable\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 1191 ----- Suppress the following diagnostics to disable this analyzer: NUnit2043

@zlepper zlepper changed the title AD0001: Occasional InvalidOperationException when NUnit2007 analyzer in IDE AD0001: Occasional InvalidOperationException error in analyzer in IDE Nov 20, 2024
@manfred-brands
Copy link
Member

Looking at the stack trace and code, this could indicate that you reference nunit.framework more than once.

I agree it shouldn't throw an exception, so I will change the code to not use .Single

@zlepper
Copy link
Author

zlepper commented Nov 20, 2024

Through using (import) statements? That might be the case, but I'm not seeing any particular duplicates there in our files, we are generally adding the using statements through "global using".

@manfred-brands
Copy link
Member

manfred-brands commented Nov 20, 2024

No, multiple Package reference of the NUnit nuget package.

Possible error source line

@zlepper
Copy link
Author

zlepper commented Nov 20, 2024

We are having projects that depends on projects where both reference nunit directly, so that is certainly possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants