diff --git a/src/CodeFormatter.cs b/src/CodeFormatter.cs index ec2ddd9549..d9ecbeb8dd 100644 --- a/src/CodeFormatter.cs +++ b/src/CodeFormatter.cs @@ -219,7 +219,11 @@ await GeneratedCodeUtilities.IsGeneratedCodeAsync(syntaxTree, cancellationToken) var analyzerConfigOptions = document.Project.AnalyzerOptions.AnalyzerConfigOptionsProvider.GetOptions(syntaxTree); if (analyzerConfigOptions != null) { - documentsCoveredByEditorConfig.Add(document.Id); + if (formatOptions.IncludeGeneratedFiles || + GeneratedCodeUtilities.GetIsGeneratedCodeFromOptions(analyzerConfigOptions) != true) + { + documentsCoveredByEditorConfig.Add(document.Id); + } } else { diff --git a/src/Utilities/GeneratedCodeUtilities.cs b/src/Utilities/GeneratedCodeUtilities.cs index 848e5132a7..e725931000 100644 --- a/src/Utilities/GeneratedCodeUtilities.cs +++ b/src/Utilities/GeneratedCodeUtilities.cs @@ -4,6 +4,7 @@ using System.IO; using System.Threading; using System.Threading.Tasks; +using Microsoft.CodeAnalysis.Diagnostics; namespace Microsoft.CodeAnalysis.Tools.Utilities { @@ -91,5 +92,19 @@ private static bool BeginsWithAutoGeneratedComment(SyntaxNode syntaxRoot, Func, IClassFixture + + + Exe + netcoreapp3.0 + + +