Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Docfx.Common/Loggers/WarningCodes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ public static class Build
public const string InvalidTocInclude = "InvalidTocInclude";
}

public static class Metadata
{
public const string FailedToResolveAnalyzer = "FailedToResolveAnalyzer";
public const string FailedToLoadAnalyzer = "FailedToLoadAnalyzer";
}

public static class Markdown
{
public const string InvalidInclude = "InvalidInclude";
Expand Down
17 changes: 16 additions & 1 deletion src/Docfx.Dotnet/DotnetApiCatalog.Compile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,22 @@ await LoadCompilationFromProject(project.AbsolutePath) is { } compilation)
{
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}");
+ $"Try build with `dotnet build -c Release` command before running docfx. Path: {unresolvedAnalyzer.FullPath}",
code: WarningCodes.Metadata.FailedToResolveAnalyzer);
}

foreach (var analyzer in project.AnalyzerReferences.OfType<AnalyzerFileReference>())
{
analyzer.AnalyzerLoadFailed += (sender, e) =>
{
var analyzerName = analyzer.Display;
var errorCode = e.ErrorCode;
var referencedCompilerVersion = e.ReferencedCompilerVersion;

Logger.LogWarning($"Failed to load .NET Analyzer. AnalyzerName: {analyzerName}, ErrorCode: {errorCode}, ReferencedCompilerVersion: {referencedCompilerVersion}",
code: WarningCodes.Metadata.FailedToLoadAnalyzer);
};

}
}

Expand Down