From a9326facbac727feff6f9b32bdb6b98d3b2feba0 Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Mon, 8 Aug 2022 21:14:11 +0200 Subject: [PATCH 1/6] Produce warning on duplicate analyzer references --- .../CSharp/Portable/CSharpResources.resx | 17 +++++------ .../CSharp/Portable/Errors/ErrorCode.cs | 1 + .../CSharp/Portable/Errors/ErrorFacts.cs | 2 ++ .../CSharp/Portable/Errors/MessageProvider.cs | 1 + .../Generated/ErrorFacts.Generated.cs | 1 + .../Portable/xlf/CSharpResources.cs.xlf | 10 +++++++ .../Portable/xlf/CSharpResources.de.xlf | 10 +++++++ .../Portable/xlf/CSharpResources.es.xlf | 10 +++++++ .../Portable/xlf/CSharpResources.fr.xlf | 10 +++++++ .../Portable/xlf/CSharpResources.it.xlf | 10 +++++++ .../Portable/xlf/CSharpResources.ja.xlf | 10 +++++++ .../Portable/xlf/CSharpResources.ko.xlf | 10 +++++++ .../Portable/xlf/CSharpResources.pl.xlf | 10 +++++++ .../Portable/xlf/CSharpResources.pt-BR.xlf | 10 +++++++ .../Portable/xlf/CSharpResources.ru.xlf | 10 +++++++ .../Portable/xlf/CSharpResources.tr.xlf | 10 +++++++ .../Portable/xlf/CSharpResources.zh-Hans.xlf | 10 +++++++ .../Portable/xlf/CSharpResources.zh-Hant.xlf | 10 +++++++ .../Test/Syntax/Diagnostics/DiagnosticTest.cs | 1 + .../Analyzers/AnalyzerFileReferenceTests.cs | 30 +++++++++++++++++++ .../CommandLine/CommandLineArguments.cs | 16 ++++++---- .../Diagnostic/CommonMessageProvider.cs | 1 + .../Test/Core/Mocks/TestMessageProvider.cs | 2 ++ .../VisualBasic/Portable/Errors/ErrorFacts.vb | 3 +- .../VisualBasic/Portable/Errors/Errors.vb | 1 + .../Portable/Errors/MessageProvider.vb | 6 ++++ .../Generated/ErrorFacts.Generated.vb | 3 +- .../VisualBasic/Portable/VBResources.resx | 6 ++++ .../Portable/xlf/VBResources.cs.xlf | 10 +++++++ .../Portable/xlf/VBResources.de.xlf | 10 +++++++ .../Portable/xlf/VBResources.es.xlf | 10 +++++++ .../Portable/xlf/VBResources.fr.xlf | 10 +++++++ .../Portable/xlf/VBResources.it.xlf | 10 +++++++ .../Portable/xlf/VBResources.ja.xlf | 10 +++++++ .../Portable/xlf/VBResources.ko.xlf | 10 +++++++ .../Portable/xlf/VBResources.pl.xlf | 10 +++++++ .../Portable/xlf/VBResources.pt-BR.xlf | 10 +++++++ .../Portable/xlf/VBResources.ru.xlf | 10 +++++++ .../Portable/xlf/VBResources.tr.xlf | 10 +++++++ .../Portable/xlf/VBResources.zh-Hans.xlf | 10 +++++++ .../Portable/xlf/VBResources.zh-Hant.xlf | 10 +++++++ 41 files changed, 334 insertions(+), 17 deletions(-) diff --git a/src/Compilers/CSharp/Portable/CSharpResources.resx b/src/Compilers/CSharp/Portable/CSharpResources.resx index 3af8b3b440c0c..ca3b0b6311028 100644 --- a/src/Compilers/CSharp/Portable/CSharpResources.resx +++ b/src/Compilers/CSharp/Portable/CSharpResources.resx @@ -6781,63 +6781,54 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ A ref field can only be declared in a ref struct. - Auto-implemented property '{0}' is read before being explicitly assigned, causing a preceding implicit assignment of 'default'. Auto-implemented property is read before being explicitly assigned, causing a preceding implicit assignment of 'default'. - Field '{0}' is read before being explicitly assigned, causing a preceding implicit assignment of 'default'. Field is read before being explicitly assigned, causing a preceding implicit assignment of 'default'. - The 'this' object is read before all of its fields have been assigned, causing preceding implicit assignments of 'default' to non-explicitly assigned fields. The 'this' object is read before all of its fields have been assigned, causing preceding implicit assignments of 'default' to non-explicitly assigned fields. - Control is returned to caller before auto-implemented property '{0}' is explicitly assigned, causing a preceding implicit assignment of 'default'. Control is returned to caller before auto-implemented property is explicitly assigned, causing a preceding implicit assignment of 'default'. - Control is returned to caller before field '{0}' is explicitly assigned, causing a preceding implicit assignment of 'default'. Control is returned to caller before field is explicitly assigned, causing a preceding implicit assignment of 'default'. - Use of possibly unassigned field '{0}'. Consider updating to language version '{1}' to auto-default the field. Use of possibly unassigned auto-implemented property '{0}'. Consider updating to language version '{1}' to auto-default the property. - Use of possibly unassigned field '{0}'. Consider updating to language version '{1}' to auto-default the field. Use of possibly unassigned field. Consider updating the language version to auto-default the field. - Use of possibly unassigned auto-implemented property '{0}'. Consider updating to language version '{1}' to auto-default the property. Use of possibly unassigned auto-implemented property. Consider updating the language version to auto-default the property. - Slice patterns may not be used for a value of type '{0}'. @@ -7211,4 +7202,10 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ Target runtime doesn't support ref fields. - + + Analyzer reference '{0}' specified multiple times + + + Analyzer reference specified multiple times + + \ No newline at end of file diff --git a/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs b/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs index 8d5f54c049765..e15ed901c9b4b 100644 --- a/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs +++ b/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs @@ -2113,6 +2113,7 @@ internal enum ErrorCode ERR_ScopedTypeNameDisallowed = 9062, ERR_UnscopedRefAttributeUnsupportedTarget = 9063, ERR_RuntimeDoesNotSupportRefFields = 9064, + WRN_DuplicateAnalyzerReference = 9065, #endregion diff --git a/src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs b/src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs index 0dd4cea8d679b..72d7dd6c26b6e 100644 --- a/src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs +++ b/src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs @@ -501,6 +501,7 @@ internal static int GetWarningLevel(ErrorCode code) case ErrorCode.WRN_UnassignedThisSupportedVersion: case ErrorCode.WRN_ObsoleteMembersShouldNotBeRequired: case ErrorCode.WRN_AnalyzerReferencesNewerCompiler: + case ErrorCode.WRN_DuplicateAnalyzerReference: return 1; default: return 0; @@ -2214,6 +2215,7 @@ internal static bool IsBuildOnlyDiagnostic(ErrorCode code) case ErrorCode.ERR_ScopedTypeNameDisallowed: case ErrorCode.ERR_UnscopedRefAttributeUnsupportedTarget: case ErrorCode.ERR_RuntimeDoesNotSupportRefFields: + case ErrorCode.WRN_DuplicateAnalyzerReference: return false; default: // NOTE: All error codes must be explicitly handled in this switch statement diff --git a/src/Compilers/CSharp/Portable/Errors/MessageProvider.cs b/src/Compilers/CSharp/Portable/Errors/MessageProvider.cs index 5d387d84cc7e1..77e11ba58781c 100644 --- a/src/Compilers/CSharp/Portable/Errors/MessageProvider.cs +++ b/src/Compilers/CSharp/Portable/Errors/MessageProvider.cs @@ -179,6 +179,7 @@ internal override bool ShouldAssertExpectedMessageArgumentsLength(int errorCode) public override int WRN_UnableToLoadAnalyzer => (int)ErrorCode.WRN_UnableToLoadAnalyzer; public override int WRN_AnalyzerReferencesFramework => (int)ErrorCode.WRN_AnalyzerReferencesFramework; public override int WRN_AnalyzerReferencesNewerCompiler => (int)ErrorCode.WRN_AnalyzerReferencesNewerCompiler; + public override int WRN_DuplicateAnalyzerReference => (int)ErrorCode.WRN_DuplicateAnalyzerReference; public override int INF_UnableToLoadSomeTypesInAnalyzer => (int)ErrorCode.INF_UnableToLoadSomeTypesInAnalyzer; public override int ERR_CantReadRulesetFile => (int)ErrorCode.ERR_CantReadRulesetFile; public override int ERR_CompileCancelled => (int)ErrorCode.ERR_CompileCancelled; diff --git a/src/Compilers/CSharp/Portable/Generated/ErrorFacts.Generated.cs b/src/Compilers/CSharp/Portable/Generated/ErrorFacts.Generated.cs index bfeeddf2c9fb3..39a4daaa377aa 100644 --- a/src/Compilers/CSharp/Portable/Generated/ErrorFacts.Generated.cs +++ b/src/Compilers/CSharp/Portable/Generated/ErrorFacts.Generated.cs @@ -289,6 +289,7 @@ public static bool IsWarning(ErrorCode code) case ErrorCode.WRN_UnassignedThisSupportedVersion: case ErrorCode.WRN_ObsoleteMembersShouldNotBeRequired: case ErrorCode.WRN_AnalyzerReferencesNewerCompiler: + case ErrorCode.WRN_DuplicateAnalyzerReference: return true; default: return false; diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf index 4b10b6adff435..f141cb157b47b 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf @@ -1917,6 +1917,16 @@ Neporovnávat hodnoty ukazatelů funkcí + + Analyzer reference '{0}' specified multiple times + Analyzer reference '{0}' specified multiple times + + + + Analyzer reference specified multiple times + Analyzer reference specified multiple times + + InterpolatedStringHandlerArgument has no effect when applied to lambda parameters and will be ignored at the call site. Argument InterpolatedStringHandlerArgument nemá při použití u parametrů lambda žádný účinek a bude se ignorovat v lokalitě volání. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf index 60708c1b525b1..3b7e6d947026e 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf @@ -1917,6 +1917,16 @@ Funktionszeigerwerte nicht vergleichen + + Analyzer reference '{0}' specified multiple times + Analyzer reference '{0}' specified multiple times + + + + Analyzer reference specified multiple times + Analyzer reference specified multiple times + + InterpolatedStringHandlerArgument has no effect when applied to lambda parameters and will be ignored at the call site. Das InterpolatedStringHandlerArgument hat bei Anwendung auf Lambdaparameter keine Auswirkungen und wird am Aufrufstandort ignoriert. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf index 81890a02c038a..609c0b0f92c06 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf @@ -1917,6 +1917,16 @@ No comparar los valores de los punteros de función + + Analyzer reference '{0}' specified multiple times + Analyzer reference '{0}' specified multiple times + + + + Analyzer reference specified multiple times + Analyzer reference specified multiple times + + InterpolatedStringHandlerArgument has no effect when applied to lambda parameters and will be ignored at the call site. El argumento InterpolatedStringHandlerArgument no tiene ningún efecto cuando se aplica a parámetros lambda y se omitirá en el sitio de llamada. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf index 40467cea5ae52..930d8f083ecd4 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf @@ -1917,6 +1917,16 @@ Ne pas comparer les valeurs des pointeurs de fonction + + Analyzer reference '{0}' specified multiple times + Analyzer reference '{0}' specified multiple times + + + + Analyzer reference specified multiple times + Analyzer reference specified multiple times + + InterpolatedStringHandlerArgument has no effect when applied to lambda parameters and will be ignored at the call site. InterpolatedStringHandlerArgument n’a aucun effet lorsqu’il est appliqué aux paramètres lambda et qu’il est ignoré sur le site d’appel. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf index b3cd5b7fbc8b4..3242bc5e738e0 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf @@ -1917,6 +1917,16 @@ Non confrontare valori del puntatore a funzione + + Analyzer reference '{0}' specified multiple times + Analyzer reference '{0}' specified multiple times + + + + Analyzer reference specified multiple times + Analyzer reference specified multiple times + + InterpolatedStringHandlerArgument has no effect when applied to lambda parameters and will be ignored at the call site. InterpolatedStringHandlerArgument non ha alcun effetto se viene applicato ai parametri lambda e verrà ignorato nel sito di chiamata. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf index 76708eecf5a05..cb740845f65fb 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf @@ -1917,6 +1917,16 @@ 関数ポインター値を比較しない + + Analyzer reference '{0}' specified multiple times + Analyzer reference '{0}' specified multiple times + + + + Analyzer reference specified multiple times + Analyzer reference specified multiple times + + InterpolatedStringHandlerArgument has no effect when applied to lambda parameters and will be ignored at the call site. ラムダ パラメーターに適用しても InterpolatedStringHandlerArgument は効果がありません。呼び出しサイトでは無視されます。 diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf index 95f8717f48446..176096986e6ae 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf @@ -1917,6 +1917,16 @@ 함수 포인터 값을 비교하지 마세요 + + Analyzer reference '{0}' specified multiple times + Analyzer reference '{0}' specified multiple times + + + + Analyzer reference specified multiple times + Analyzer reference specified multiple times + + InterpolatedStringHandlerArgument has no effect when applied to lambda parameters and will be ignored at the call site. InterpolatedStringHandlerArgument는 람다 매개 변수에 적용할 때 효과가 없으며 호출 사이트에서 무시됩니다. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf index 484df970aad97..b432b16e9b097 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf @@ -1917,6 +1917,16 @@ Nie porównuj wartości wskaźników funkcji + + Analyzer reference '{0}' specified multiple times + Analyzer reference '{0}' specified multiple times + + + + Analyzer reference specified multiple times + Analyzer reference specified multiple times + + InterpolatedStringHandlerArgument has no effect when applied to lambda parameters and will be ignored at the call site. Argument InterpolatedStringHandlerArgument nie odniesie żadnego skutku po zastosowaniu do parametrów lambda i zostanie zignorowany w lokacji wywołania. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf index 3b3ef126eb32b..d9d106803cf05 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf @@ -1917,6 +1917,16 @@ Não comparar valores de ponteiro de função + + Analyzer reference '{0}' specified multiple times + Analyzer reference '{0}' specified multiple times + + + + Analyzer reference specified multiple times + Analyzer reference specified multiple times + + InterpolatedStringHandlerArgument has no effect when applied to lambda parameters and will be ignored at the call site. InterpolatedStringHandlerArgument não tem efeito quando aplicado a parâmetros lambda e será ignorado no local de chamada. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf index c6b90f3d74643..54ba71dc8cea5 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf @@ -1917,6 +1917,16 @@ Не сравнивайте значения указателей на функции + + Analyzer reference '{0}' specified multiple times + Analyzer reference '{0}' specified multiple times + + + + Analyzer reference specified multiple times + Analyzer reference specified multiple times + + InterpolatedStringHandlerArgument has no effect when applied to lambda parameters and will be ignored at the call site. Атрибут InterpolatedStringHandlerArgument не действует при применении к лямбда-параметрам и будет проигнорирован на сайте вызова. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf index be1d4fc1e43cd..8fe393a8202da 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf @@ -1917,6 +1917,16 @@ İşlev işaretçisi değerlerini karşılaştırma + + Analyzer reference '{0}' specified multiple times + Analyzer reference '{0}' specified multiple times + + + + Analyzer reference specified multiple times + Analyzer reference specified multiple times + + InterpolatedStringHandlerArgument has no effect when applied to lambda parameters and will be ignored at the call site. InterpolatedStringHandlerArgument, lambda parametrelerine uygulandığında hiçbir etkiye sahip değildir ve çağrı sitesinde yok sayılır. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf index 0ae73f3306964..d06e619068758 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf @@ -1917,6 +1917,16 @@ 不比较函数指针值 + + Analyzer reference '{0}' specified multiple times + Analyzer reference '{0}' specified multiple times + + + + Analyzer reference specified multiple times + Analyzer reference specified multiple times + + InterpolatedStringHandlerArgument has no effect when applied to lambda parameters and will be ignored at the call site. 应用于 lambda 参数时,InterpolatedStringHandlerArgument 不起任何作用,并将在调用站点被忽略。 diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf index c1608c075a6cc..23b2de8c0592f 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf @@ -1917,6 +1917,16 @@ 不要比較函式指標值 + + Analyzer reference '{0}' specified multiple times + Analyzer reference '{0}' specified multiple times + + + + Analyzer reference specified multiple times + Analyzer reference specified multiple times + + InterpolatedStringHandlerArgument has no effect when applied to lambda parameters and will be ignored at the call site. InterpolatedStringHandlerArgument 在套用至 Lambda 參數時沒有效果,將於呼叫網站忽略。 diff --git a/src/Compilers/CSharp/Test/Syntax/Diagnostics/DiagnosticTest.cs b/src/Compilers/CSharp/Test/Syntax/Diagnostics/DiagnosticTest.cs index 4db9910725ac4..81500827aae1f 100644 --- a/src/Compilers/CSharp/Test/Syntax/Diagnostics/DiagnosticTest.cs +++ b/src/Compilers/CSharp/Test/Syntax/Diagnostics/DiagnosticTest.cs @@ -354,6 +354,7 @@ public void WarningLevel_2() case ErrorCode.WRN_UseDefViolationFieldSupportedVersion: case ErrorCode.WRN_UseDefViolationThisSupportedVersion: case ErrorCode.WRN_AnalyzerReferencesNewerCompiler: + case ErrorCode.WRN_DuplicateAnalyzerReference: Assert.Equal(1, ErrorFacts.GetWarningLevel(errorCode)); break; case ErrorCode.WRN_InvalidVersionFormat: diff --git a/src/Compilers/Core/CodeAnalysisTest/Analyzers/AnalyzerFileReferenceTests.cs b/src/Compilers/Core/CodeAnalysisTest/Analyzers/AnalyzerFileReferenceTests.cs index 52645d1999638..8fb954b176123 100644 --- a/src/Compilers/Core/CodeAnalysisTest/Analyzers/AnalyzerFileReferenceTests.cs +++ b/src/Compilers/Core/CodeAnalysisTest/Analyzers/AnalyzerFileReferenceTests.cs @@ -323,6 +323,36 @@ public void AssemblyLoading_ReferencesLaterFakeCompiler_EndToEnd_CSharp() """, writer.ToString()); } + [ConditionalFact(typeof(IsEnglishLocal))] + public void DuplicateAnalyzerReference() + { + var directory = Temp.CreateDirectory(); + + TempFile corlib = directory.CreateFile("mscorlib.dll"); + corlib.WriteAllBytes(TestResources.NetFX.Minimal.mincorlib); + + TempFile source = directory.CreateFile("in.cs"); + source.WriteAllText("int x = 0;"); + + var compiler = new AnalyzerLoaderMockCSharpCompiler( + CSharpCommandLineParser.Default, + responseFile: null, + args: new[] { "/nologo", $@"/analyzer:""{_testFixture.AnalyzerWithFakeCompilerDependency.Path}""", $@"/analyzer:""{_testFixture.AnalyzerWithFakeCompilerDependency.Path}""", "/nostdlib", $@"/r:""{corlib.Path}""", "/out:something.dll", source.Path }, + new BuildPaths(clientDir: directory.Path, workingDir: directory.Path, sdkDir: null, tempDir: null), + additionalReferenceDirectories: null, + new DefaultAnalyzerAssemblyLoader()); + + var writer = new StringWriter(); + var result = compiler.Run(writer); + Assert.Equal(0, result); + AssertEx.Equal($""" + warning CS9065: Analyzer reference '{_testFixture.AnalyzerWithFakeCompilerDependency.Path}' specified multiple times + warning CS8032: An instance of analyzer Analyzer cannot be created from {_testFixture.AnalyzerWithFakeCompilerDependency.Path} : Method 'get_SupportedDiagnostics' in type 'Analyzer' from assembly 'AnalyzerWithFakeCompilerDependency, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.. + in.cs(1,5): warning CS0219: The variable 'x' is assigned but its value is never used + + """, writer.ToString()); + } + [ConditionalFact(typeof(CoreClrOnly), Reason = "Can't load a framework targeting generator, which these are in desktop")] public void TestLoadGenerators() { diff --git a/src/Compilers/Core/Portable/CommandLine/CommandLineArguments.cs b/src/Compilers/Core/Portable/CommandLine/CommandLineArguments.cs index 97d8125d4e6ee..ecbd67134cb8f 100644 --- a/src/Compilers/Core/Portable/CommandLine/CommandLineArguments.cs +++ b/src/Compilers/Core/Portable/CommandLine/CommandLineArguments.cs @@ -510,16 +510,22 @@ internal void ResolveAnalyzersFromArguments( } }; - var resolvedReferences = ArrayBuilder.GetInstance(); + var resolvedReferences = PooledHashSet.GetInstance(); foreach (var reference in AnalyzerReferences) { var resolvedReference = ResolveAnalyzerReference(reference, analyzerLoader); if (resolvedReference != null) { - resolvedReferences.Add(resolvedReference); - - // register the reference to the analyzer loader: - analyzerLoader.AddDependencyLocation(resolvedReference.FullPath); + var isAdded = resolvedReferences.Add(resolvedReference); + if (isAdded) + { + // register the reference to the analyzer loader: + analyzerLoader.AddDependencyLocation(resolvedReference.FullPath); + } + else + { + diagnostics.Add(new DiagnosticInfo(messageProvider, messageProvider.WRN_DuplicateAnalyzerReference, reference.FilePath)); + } } else { diff --git a/src/Compilers/Core/Portable/Diagnostic/CommonMessageProvider.cs b/src/Compilers/Core/Portable/Diagnostic/CommonMessageProvider.cs index 1f85e41c78dc5..2717d26c3edd4 100644 --- a/src/Compilers/Core/Portable/Diagnostic/CommonMessageProvider.cs +++ b/src/Compilers/Core/Portable/Diagnostic/CommonMessageProvider.cs @@ -176,6 +176,7 @@ public string GetIdForErrorCode(int errorCode) public abstract int WRN_NoAnalyzerInAssembly { get; } public abstract int WRN_AnalyzerReferencesFramework { get; } public abstract int WRN_AnalyzerReferencesNewerCompiler { get; } + public abstract int WRN_DuplicateAnalyzerReference { get; } public abstract int ERR_CantReadRulesetFile { get; } public abstract int ERR_CompileCancelled { get; } diff --git a/src/Compilers/Test/Core/Mocks/TestMessageProvider.cs b/src/Compilers/Test/Core/Mocks/TestMessageProvider.cs index 199597b962a06..85bad66eabac1 100644 --- a/src/Compilers/Test/Core/Mocks/TestMessageProvider.cs +++ b/src/Compilers/Test/Core/Mocks/TestMessageProvider.cs @@ -465,5 +465,7 @@ public override int ERR_InvalidDebugInfo public override int WRN_AnalyzerReferencesFramework => throw new NotImplementedException(); public override int WRN_AnalyzerReferencesNewerCompiler => throw new NotImplementedException(); + + public override int WRN_DuplicateAnalyzerReference => throw new NotImplementedException(); } } diff --git a/src/Compilers/VisualBasic/Portable/Errors/ErrorFacts.vb b/src/Compilers/VisualBasic/Portable/Errors/ErrorFacts.vb index 2b43089ba88fa..a3ae0f83aac11 100644 --- a/src/Compilers/VisualBasic/Portable/Errors/ErrorFacts.vb +++ b/src/Compilers/VisualBasic/Portable/Errors/ErrorFacts.vb @@ -1526,7 +1526,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic ERRID.WRN_AnalyzerReferencesFramework, ERRID.WRN_CallerArgumentExpressionAttributeSelfReferential, ERRID.WRN_CallerArgumentExpressionAttributeHasInvalidParameterName, - ERRID.WRN_AnalyzerReferencesNewerCompiler + ERRID.WRN_AnalyzerReferencesNewerCompiler, + ERRID.WRN_DuplicateAnalyzerReference Return False Case Else ' NOTE: All error codes must be explicitly handled in the below select case statement diff --git a/src/Compilers/VisualBasic/Portable/Errors/Errors.vb b/src/Compilers/VisualBasic/Portable/Errors/Errors.vb index fdf78f60a2cce..74959580a6ffb 100644 --- a/src/Compilers/VisualBasic/Portable/Errors/Errors.vb +++ b/src/Compilers/VisualBasic/Portable/Errors/Errors.vb @@ -1998,6 +1998,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic WRN_CallerArgumentExpressionAttributeHasInvalidParameterName = 42505 WRN_AnalyzerReferencesNewerCompiler = 42506 + WRN_DuplicateAnalyzerReference = 42507 ' // AVAILABLE 42600 - 49998 WRN_NextAvailable = 42600 diff --git a/src/Compilers/VisualBasic/Portable/Errors/MessageProvider.vb b/src/Compilers/VisualBasic/Portable/Errors/MessageProvider.vb index ab4a1560ebebc..682f5b00d2097 100644 --- a/src/Compilers/VisualBasic/Portable/Errors/MessageProvider.vb +++ b/src/Compilers/VisualBasic/Portable/Errors/MessageProvider.vb @@ -252,6 +252,12 @@ Namespace Microsoft.CodeAnalysis.VisualBasic End Get End Property + Public Overrides ReadOnly Property WRN_DuplicateAnalyzerReference As Integer + Get + Return ERRID.WRN_DuplicateAnalyzerReference + End Get + End Property + Public Overrides ReadOnly Property INF_UnableToLoadSomeTypesInAnalyzer As Integer Get Return ERRID.INF_UnableToLoadSomeTypesInAnalyzer diff --git a/src/Compilers/VisualBasic/Portable/Generated/ErrorFacts.Generated.vb b/src/Compilers/VisualBasic/Portable/Generated/ErrorFacts.Generated.vb index 692bd1bc4c5d5..aabe4cb5ddb3d 100644 --- a/src/Compilers/VisualBasic/Portable/Generated/ErrorFacts.Generated.vb +++ b/src/Compilers/VisualBasic/Portable/Generated/ErrorFacts.Generated.vb @@ -176,7 +176,8 @@ ERRID.WRN_AnalyzerReferencesFramework, ERRID.WRN_CallerArgumentExpressionAttributeSelfReferential, ERRID.WRN_CallerArgumentExpressionAttributeHasInvalidParameterName, - ERRID.WRN_AnalyzerReferencesNewerCompiler + ERRID.WRN_AnalyzerReferencesNewerCompiler, + ERRID.WRN_DuplicateAnalyzerReference Return True Case Else Return False diff --git a/src/Compilers/VisualBasic/Portable/VBResources.resx b/src/Compilers/VisualBasic/Portable/VBResources.resx index 8ee01b4786c39..f762dc010c9bb 100644 --- a/src/Compilers/VisualBasic/Portable/VBResources.resx +++ b/src/Compilers/VisualBasic/Portable/VBResources.resx @@ -5662,4 +5662,10 @@ 'System.Runtime.CompilerServices.CompilerFeatureRequiredAttribute' is reserved for compiler usage only. + + Analyzer reference '{0}' specified multiple times + + + Analyzer reference specified multiple times + \ No newline at end of file diff --git a/src/Compilers/VisualBasic/Portable/xlf/VBResources.cs.xlf b/src/Compilers/VisualBasic/Portable/xlf/VBResources.cs.xlf index b3d7452a1e13b..29da03c2a67aa 100644 --- a/src/Compilers/VisualBasic/Portable/xlf/VBResources.cs.xlf +++ b/src/Compilers/VisualBasic/Portable/xlf/VBResources.cs.xlf @@ -558,6 +558,16 @@ CallerArgumentExpressionAttribute použitý u parametru nebude mít žádný vliv, protože odkazuje sám na sebe. + + Analyzer reference '{0}' specified multiple times + Analyzer reference '{0}' specified multiple times + + + + Analyzer reference specified multiple times + Analyzer reference specified multiple times + + Generator '{0}' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type '{1}' with message '{2}' Generátor {0} nemohl vygenerovat zdroj. V důsledku toho může docházet k chybám kompilace a generátor nebude přispívat na výstup. Výjimka měla typ {1} se zprávou {2}. diff --git a/src/Compilers/VisualBasic/Portable/xlf/VBResources.de.xlf b/src/Compilers/VisualBasic/Portable/xlf/VBResources.de.xlf index 0d022d3efc15f..d2a38a097e051 100644 --- a/src/Compilers/VisualBasic/Portable/xlf/VBResources.de.xlf +++ b/src/Compilers/VisualBasic/Portable/xlf/VBResources.de.xlf @@ -558,6 +558,16 @@ Das auf den Parameter angewendete CallerArgumentExpressionAttribute hat keine Auswirkungen, da es selbstreferenziell ist. + + Analyzer reference '{0}' specified multiple times + Analyzer reference '{0}' specified multiple times + + + + Analyzer reference specified multiple times + Analyzer reference specified multiple times + + Generator '{0}' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type '{1}' with message '{2}' Fehler beim Generieren der Quelle durch den Generator "{0}". Dieser wird bei der Ausgabe nicht berücksichtigt, deshalb kann es zu Kompilierungsfehlern kommen. Ausnahmetyp: {1}. Meldung: {2} diff --git a/src/Compilers/VisualBasic/Portable/xlf/VBResources.es.xlf b/src/Compilers/VisualBasic/Portable/xlf/VBResources.es.xlf index 25281fe6fc096..9cd16aec13487 100644 --- a/src/Compilers/VisualBasic/Portable/xlf/VBResources.es.xlf +++ b/src/Compilers/VisualBasic/Portable/xlf/VBResources.es.xlf @@ -558,6 +558,16 @@ El atributo CallerArgumentExpressionAttribute aplicado al parámetro no tendrá ningún efecto porque es autorreferencial. + + Analyzer reference '{0}' specified multiple times + Analyzer reference '{0}' specified multiple times + + + + Analyzer reference specified multiple times + Analyzer reference specified multiple times + + Generator '{0}' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type '{1}' with message '{2}' Error del generador "{0}" al crear código fuente. No contribuirá a la salida y pueden producirse errores de compilación como resultado. Se produjo la excepción de tipo "{1}" con el mensaje "{2}" diff --git a/src/Compilers/VisualBasic/Portable/xlf/VBResources.fr.xlf b/src/Compilers/VisualBasic/Portable/xlf/VBResources.fr.xlf index 9127ce1c0284a..9fc5f6c4ae90d 100644 --- a/src/Compilers/VisualBasic/Portable/xlf/VBResources.fr.xlf +++ b/src/Compilers/VisualBasic/Portable/xlf/VBResources.fr.xlf @@ -558,6 +558,16 @@ Le CallerArgumentExpressionAttribute appliqué au paramètre n’aura aucun effet, car il est auto-référentiel. + + Analyzer reference '{0}' specified multiple times + Analyzer reference '{0}' specified multiple times + + + + Analyzer reference specified multiple times + Analyzer reference specified multiple times + + Generator '{0}' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type '{1}' with message '{2}' Le générateur '{0}' n'a pas pu générer la source. Dans la mesure où il ne va pas contribuer à la sortie, des erreurs de compilation peuvent se produire. Exception levée de type '{1}' avec le message '{2}' diff --git a/src/Compilers/VisualBasic/Portable/xlf/VBResources.it.xlf b/src/Compilers/VisualBasic/Portable/xlf/VBResources.it.xlf index 3489fa4c968a8..1074b8b681b94 100644 --- a/src/Compilers/VisualBasic/Portable/xlf/VBResources.it.xlf +++ b/src/Compilers/VisualBasic/Portable/xlf/VBResources.it.xlf @@ -558,6 +558,16 @@ CallerArgumentExpressionAttribute applicato al parametro non avrà alcun effetto perché è autoreferenziale. + + Analyzer reference '{0}' specified multiple times + Analyzer reference '{0}' specified multiple times + + + + Analyzer reference specified multiple times + Analyzer reference specified multiple times + + Generator '{0}' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type '{1}' with message '{2}' Il generatore '{0}' non è riuscito a generare l'origine. Non verrà aggiunto come contributo all'output e potrebbero verificarsi errori di compilazione. Eccezione di tipo '{1}'. Messaggio '{2}' diff --git a/src/Compilers/VisualBasic/Portable/xlf/VBResources.ja.xlf b/src/Compilers/VisualBasic/Portable/xlf/VBResources.ja.xlf index 49bbd4fe2f60d..b89ae209ae556 100644 --- a/src/Compilers/VisualBasic/Portable/xlf/VBResources.ja.xlf +++ b/src/Compilers/VisualBasic/Portable/xlf/VBResources.ja.xlf @@ -558,6 +558,16 @@ パラメーターに適用された CallerArgumentExpressionAttribute は自己参照であるため、無効となります。 + + Analyzer reference '{0}' specified multiple times + Analyzer reference '{0}' specified multiple times + + + + Analyzer reference specified multiple times + Analyzer reference specified multiple times + + Generator '{0}' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type '{1}' with message '{2}' ジェネレーター '{0}' でソースを生成できませんでした。出力には寄与しません。結果として、コンパイル エラーが発生する可能性があります。例外の型: '{1}'。メッセージ: '{2}' diff --git a/src/Compilers/VisualBasic/Portable/xlf/VBResources.ko.xlf b/src/Compilers/VisualBasic/Portable/xlf/VBResources.ko.xlf index 504fb5ad54b5d..5be0ce05b724e 100644 --- a/src/Compilers/VisualBasic/Portable/xlf/VBResources.ko.xlf +++ b/src/Compilers/VisualBasic/Portable/xlf/VBResources.ko.xlf @@ -558,6 +558,16 @@ 매개 변수에 적용된 CallerArgumentExpressionAttribute는 자체 참조이기 때문에 효과가 없습니다. + + Analyzer reference '{0}' specified multiple times + Analyzer reference '{0}' specified multiple times + + + + Analyzer reference specified multiple times + Analyzer reference specified multiple times + + Generator '{0}' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type '{1}' with message '{2}' 생성기 '{0}'이(가) 소스를 생성하지 못했습니다. 출력에 기여하지 않으므로 컴파일 오류가 발생할 수 있습니다. 예외의 형식은 '{1}'이고 메시지는 '{2}'입니다. diff --git a/src/Compilers/VisualBasic/Portable/xlf/VBResources.pl.xlf b/src/Compilers/VisualBasic/Portable/xlf/VBResources.pl.xlf index fec494f8efc88..babf4bb086825 100644 --- a/src/Compilers/VisualBasic/Portable/xlf/VBResources.pl.xlf +++ b/src/Compilers/VisualBasic/Portable/xlf/VBResources.pl.xlf @@ -558,6 +558,16 @@ Atrybut CallerArgumentExpressionAttribute zastosowany do parametru nie będzie działać, ponieważ jest to odwołanie samodzielne. + + Analyzer reference '{0}' specified multiple times + Analyzer reference '{0}' specified multiple times + + + + Analyzer reference specified multiple times + Analyzer reference specified multiple times + + Generator '{0}' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type '{1}' with message '{2}' Generator „{0}” nie mógł wygenerować źródła. W rezultacie nie będzie on współtworzyć danych wyjściowych i mogą wystąpić błędy kompilacji. Typ wyjątku: „{1}”, komunikat: „{2}” diff --git a/src/Compilers/VisualBasic/Portable/xlf/VBResources.pt-BR.xlf b/src/Compilers/VisualBasic/Portable/xlf/VBResources.pt-BR.xlf index ad95c964e8256..7160cbe4dd720 100644 --- a/src/Compilers/VisualBasic/Portable/xlf/VBResources.pt-BR.xlf +++ b/src/Compilers/VisualBasic/Portable/xlf/VBResources.pt-BR.xlf @@ -558,6 +558,16 @@ O CallerArgumentExpressionAttribute aplicado ao parâmetro não terá efeito porque é de autorreferência. + + Analyzer reference '{0}' specified multiple times + Analyzer reference '{0}' specified multiple times + + + + Analyzer reference specified multiple times + Analyzer reference specified multiple times + + Generator '{0}' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type '{1}' with message '{2}' O gerador '{0}' não pôde gerar a origem. Ele não contribuirá com a saída e poderão ocorrer erros de compilação como resultado. A exceção foi do tipo '{1}', com a mensagem '{2}' diff --git a/src/Compilers/VisualBasic/Portable/xlf/VBResources.ru.xlf b/src/Compilers/VisualBasic/Portable/xlf/VBResources.ru.xlf index 3cbc4c84b160c..daa1955d61fe9 100644 --- a/src/Compilers/VisualBasic/Portable/xlf/VBResources.ru.xlf +++ b/src/Compilers/VisualBasic/Portable/xlf/VBResources.ru.xlf @@ -558,6 +558,16 @@ Применение класса CallerArgumentExpressionAttribute к параметру не подействует, так как он ссылается сам на себя. + + Analyzer reference '{0}' specified multiple times + Analyzer reference '{0}' specified multiple times + + + + Analyzer reference specified multiple times + Analyzer reference specified multiple times + + Generator '{0}' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type '{1}' with message '{2}' Генератору "{0}" не удалось создать источник. Это не повлияет на выходные данные и ошибки компиляции, которые могут возникнуть в результате. Тип возникшего исключения: "{1}", сообщение: "{2}" diff --git a/src/Compilers/VisualBasic/Portable/xlf/VBResources.tr.xlf b/src/Compilers/VisualBasic/Portable/xlf/VBResources.tr.xlf index fec367a2b54a7..235d9f3ee5093 100644 --- a/src/Compilers/VisualBasic/Portable/xlf/VBResources.tr.xlf +++ b/src/Compilers/VisualBasic/Portable/xlf/VBResources.tr.xlf @@ -558,6 +558,16 @@ Parametre kendini işaret ettiğinden, parametreye uygulanan CallerArgumentExpressionAttribute hiçbir etkiye sahip olmaz. + + Analyzer reference '{0}' specified multiple times + Analyzer reference '{0}' specified multiple times + + + + Analyzer reference specified multiple times + Analyzer reference specified multiple times + + Generator '{0}' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type '{1}' with message '{2}' '{0}' oluşturucusu kaynak oluşturamadı. Oluşturucu çıkışa katkıda bulunmayacağından, bunun sonucunda derleme hataları oluşabilir. Özel durum '{2}' iletisi ile '{1}' türündeydi diff --git a/src/Compilers/VisualBasic/Portable/xlf/VBResources.zh-Hans.xlf b/src/Compilers/VisualBasic/Portable/xlf/VBResources.zh-Hans.xlf index 8b0bfdf794da1..df1b81a187dcd 100644 --- a/src/Compilers/VisualBasic/Portable/xlf/VBResources.zh-Hans.xlf +++ b/src/Compilers/VisualBasic/Portable/xlf/VBResources.zh-Hans.xlf @@ -558,6 +558,16 @@ 应用于参数的 CallerArgumentExpressionAttribute 将不起任何作用,因为它是自引用的。 + + Analyzer reference '{0}' specified multiple times + Analyzer reference '{0}' specified multiple times + + + + Analyzer reference specified multiple times + Analyzer reference specified multiple times + + Generator '{0}' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type '{1}' with message '{2}' 生成器“{0}”未能生成源。它不会影响输出,因此可能会造成编译错误。异常的类型为“{1}”,显示消息“{2}” diff --git a/src/Compilers/VisualBasic/Portable/xlf/VBResources.zh-Hant.xlf b/src/Compilers/VisualBasic/Portable/xlf/VBResources.zh-Hant.xlf index bbdc6aa66cfb4..d95c345d8501d 100644 --- a/src/Compilers/VisualBasic/Portable/xlf/VBResources.zh-Hant.xlf +++ b/src/Compilers/VisualBasic/Portable/xlf/VBResources.zh-Hant.xlf @@ -558,6 +558,16 @@ 套用到參數的 CallerArgumentExpressionAttribute 將沒有效果,因為它是自我參考。 + + Analyzer reference '{0}' specified multiple times + Analyzer reference '{0}' specified multiple times + + + + Analyzer reference specified multiple times + Analyzer reference specified multiple times + + Generator '{0}' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type '{1}' with message '{2}' 產生器 '{0}' 無法產生來源。其不會提供給輸出,並可能導致編譯錯誤。例外狀況的類型為 '{1}',訊息為 '{2}' From df591aad805eb1d0b051a80919837d176b2f922c Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Thu, 11 Aug 2022 08:05:09 +0200 Subject: [PATCH 2/6] Fix test --- .../CodeAnalysisTest/Analyzers/AnalyzerFileReferenceTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Compilers/Core/CodeAnalysisTest/Analyzers/AnalyzerFileReferenceTests.cs b/src/Compilers/Core/CodeAnalysisTest/Analyzers/AnalyzerFileReferenceTests.cs index 8fb954b176123..e39540ef87477 100644 --- a/src/Compilers/Core/CodeAnalysisTest/Analyzers/AnalyzerFileReferenceTests.cs +++ b/src/Compilers/Core/CodeAnalysisTest/Analyzers/AnalyzerFileReferenceTests.cs @@ -346,7 +346,7 @@ public void DuplicateAnalyzerReference() var result = compiler.Run(writer); Assert.Equal(0, result); AssertEx.Equal($""" - warning CS9065: Analyzer reference '{_testFixture.AnalyzerWithFakeCompilerDependency.Path}' specified multiple times + warning CS9066: Analyzer reference '{_testFixture.AnalyzerWithFakeCompilerDependency.Path}' specified multiple times warning CS8032: An instance of analyzer Analyzer cannot be created from {_testFixture.AnalyzerWithFakeCompilerDependency.Path} : Method 'get_SupportedDiagnostics' in type 'Analyzer' from assembly 'AnalyzerWithFakeCompilerDependency, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.. in.cs(1,5): warning CS0219: The variable 'x' is assigned but its value is never used From 237e9008f28b88d6717eb13956dff23211e7b3f5 Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Thu, 11 Aug 2022 09:11:53 +0200 Subject: [PATCH 3/6] Workaround --- .../Microsoft.CodeAnalysis.EditorFeatures.Wpf.csproj | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/EditorFeatures/Core.Wpf/Microsoft.CodeAnalysis.EditorFeatures.Wpf.csproj b/src/EditorFeatures/Core.Wpf/Microsoft.CodeAnalysis.EditorFeatures.Wpf.csproj index ad0ccef2273e9..28819ff8eafe4 100644 --- a/src/EditorFeatures/Core.Wpf/Microsoft.CodeAnalysis.EditorFeatures.Wpf.csproj +++ b/src/EditorFeatures/Core.Wpf/Microsoft.CodeAnalysis.EditorFeatures.Wpf.csproj @@ -78,4 +78,14 @@ + + + + + + + + + + From 4010a8d316feed563946473b7e9f7b32ced10bc4 Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Thu, 11 Aug 2022 10:41:43 +0200 Subject: [PATCH 4/6] Move to Imports.targets --- eng/targets/Imports.targets | 9 +++++++++ .../Microsoft.CodeAnalysis.EditorFeatures.Wpf.csproj | 10 ---------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/eng/targets/Imports.targets b/eng/targets/Imports.targets index 6d5cdf2df9bfd..9649eb2eb828a 100644 --- a/eng/targets/Imports.targets +++ b/eng/targets/Imports.targets @@ -367,6 +367,15 @@ + + + + + + + + + diff --git a/src/EditorFeatures/Core.Wpf/Microsoft.CodeAnalysis.EditorFeatures.Wpf.csproj b/src/EditorFeatures/Core.Wpf/Microsoft.CodeAnalysis.EditorFeatures.Wpf.csproj index 28819ff8eafe4..ad0ccef2273e9 100644 --- a/src/EditorFeatures/Core.Wpf/Microsoft.CodeAnalysis.EditorFeatures.Wpf.csproj +++ b/src/EditorFeatures/Core.Wpf/Microsoft.CodeAnalysis.EditorFeatures.Wpf.csproj @@ -78,14 +78,4 @@ - - - - - - - - - - From ed095d146f4cdc61e041fe90c97e22d8f66dc959 Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Sun, 21 Aug 2022 15:16:44 +0200 Subject: [PATCH 5/6] Address feedback --- eng/targets/Imports.targets | 2 +- .../Portable/CommandLine/CommandLineArguments.cs | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/eng/targets/Imports.targets b/eng/targets/Imports.targets index 9649eb2eb828a..0320ff6eb4dd0 100644 --- a/eng/targets/Imports.targets +++ b/eng/targets/Imports.targets @@ -367,7 +367,7 @@ - + diff --git a/src/Compilers/Core/Portable/CommandLine/CommandLineArguments.cs b/src/Compilers/Core/Portable/CommandLine/CommandLineArguments.cs index ecbd67134cb8f..28c916e166af2 100644 --- a/src/Compilers/Core/Portable/CommandLine/CommandLineArguments.cs +++ b/src/Compilers/Core/Portable/CommandLine/CommandLineArguments.cs @@ -510,17 +510,20 @@ internal void ResolveAnalyzersFromArguments( } }; - var resolvedReferences = PooledHashSet.GetInstance(); + var resolvedReferencesSet = PooledHashSet.GetInstance(); + var resolvedReferencesList = ArrayBuilder.GetInstance(); foreach (var reference in AnalyzerReferences) { var resolvedReference = ResolveAnalyzerReference(reference, analyzerLoader); if (resolvedReference != null) { - var isAdded = resolvedReferences.Add(resolvedReference); + var isAdded = resolvedReferencesSet.Add(resolvedReference); if (isAdded) { // register the reference to the analyzer loader: analyzerLoader.AddDependencyLocation(resolvedReference.FullPath); + + resolvedReferencesList.Add(resolvedReference); } else { @@ -534,7 +537,7 @@ internal void ResolveAnalyzersFromArguments( } // All analyzer references are registered now, we can start loading them. - foreach (var resolvedReference in resolvedReferences) + foreach (var resolvedReference in resolvedReferencesList) { resolvedReference.AnalyzerLoadFailed += errorHandler; resolvedReference.AddAnalyzers(analyzerBuilder, language, shouldIncludeAnalyzer); @@ -542,7 +545,8 @@ internal void ResolveAnalyzersFromArguments( resolvedReference.AnalyzerLoadFailed -= errorHandler; } - resolvedReferences.Free(); + resolvedReferencesList.Free(); + resolvedReferencesSet.Free(); generators = generatorBuilder.ToImmutable(); analyzers = analyzerBuilder.ToImmutable(); From 9f607843d37052f3ea2c2a885aa5a8710e2923d0 Mon Sep 17 00:00:00 2001 From: Youssef Victor Date: Wed, 24 Aug 2022 10:10:58 +0200 Subject: [PATCH 6/6] Update test --- .../CodeAnalysisTest/Analyzers/AnalyzerFileReferenceTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Compilers/Core/CodeAnalysisTest/Analyzers/AnalyzerFileReferenceTests.cs b/src/Compilers/Core/CodeAnalysisTest/Analyzers/AnalyzerFileReferenceTests.cs index e39540ef87477..5e7cc365e2287 100644 --- a/src/Compilers/Core/CodeAnalysisTest/Analyzers/AnalyzerFileReferenceTests.cs +++ b/src/Compilers/Core/CodeAnalysisTest/Analyzers/AnalyzerFileReferenceTests.cs @@ -346,7 +346,7 @@ public void DuplicateAnalyzerReference() var result = compiler.Run(writer); Assert.Equal(0, result); AssertEx.Equal($""" - warning CS9066: Analyzer reference '{_testFixture.AnalyzerWithFakeCompilerDependency.Path}' specified multiple times + warning CS9067: Analyzer reference '{_testFixture.AnalyzerWithFakeCompilerDependency.Path}' specified multiple times warning CS8032: An instance of analyzer Analyzer cannot be created from {_testFixture.AnalyzerWithFakeCompilerDependency.Path} : Method 'get_SupportedDiagnostics' in type 'Analyzer' from assembly 'AnalyzerWithFakeCompilerDependency, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.. in.cs(1,5): warning CS0219: The variable 'x' is assigned but its value is never used