From 643f73a98a8de96c4cce1ac4a2bf2c345702af3a Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Sat, 20 Jan 2024 17:35:15 +0900 Subject: [PATCH] chore: Add warnings for UnresolvedAnalyzerReference (#9623) --- src/Docfx.Dotnet/DotnetApiCatalog.Compile.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Docfx.Dotnet/DotnetApiCatalog.Compile.cs b/src/Docfx.Dotnet/DotnetApiCatalog.Compile.cs index ebc70691622..efd5b9e36e9 100644 --- a/src/Docfx.Dotnet/DotnetApiCatalog.Compile.cs +++ b/src/Docfx.Dotnet/DotnetApiCatalog.Compile.cs @@ -7,6 +7,7 @@ using Microsoft.Build.Framework; using Microsoft.Build.Logging; using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.MSBuild; #nullable enable @@ -132,6 +133,13 @@ await LoadCompilationFromProject(project.AbsolutePath) is { } compilation) await Process.Start("dotnet", $"restore \"{path}\"").WaitForExitAsync(); } project = await workspace.OpenProjectAsync(path, msbuildLogger); + + foreach (var unresolvedAnalyzer in project.AnalyzerReferences.OfType()) + { + Logger.LogWarning($"There is .NET Analyzer that can't be resolved. " + + $"If this analyzer is .NET Source Generator project. " + + $"Try build with `dotnet build -c Release` command before running docfx. Path: {unresolvedAnalyzer.FullPath}"); + } } if (!project.SupportsCompilation)