未验证 提交 ce784258 编写于 作者: M Manish Vasani 提交者: GitHub

Merge pull request #37609 from jnm2/globalsuppressions_whitespace

Fix trailing whitespace and superfluous blank lines in generated GlobalSuppressions.cs
......@@ -367,10 +367,10 @@ class Class2
</Project>
</Workspace>";
var addedGlobalSuppressions = $@"
// This file is used by Code Analysis to maintain SuppressMessage
var addedGlobalSuppressions =
$@"// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage(""InfoDiagnostic"", ""InfoDiagnostic:InfoDiagnostic"", Justification = ""{FeaturesResources.Pending}"", Scope = ""member"", Target = ""~M:Class1.Method~System.Int32"")]
......@@ -470,10 +470,10 @@ class Class2
</Project>
</Workspace>";
var addedGlobalSuppressions = $@"
// This file is used by Code Analysis to maintain SuppressMessage
var addedGlobalSuppressions =
$@"// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage(""InfoDiagnostic"", ""InfoDiagnostic:InfoDiagnostic"", Justification = ""{FeaturesResources.Pending}"", Scope = ""member"", Target = ""~M:Class1.Method~System.Int32"")]
......@@ -574,10 +574,10 @@ class Class2
</Project>
</Workspace>";
var addedGlobalSuppressionsProject1 = $@"
// This file is used by Code Analysis to maintain SuppressMessage
var addedGlobalSuppressionsProject1 =
$@"// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage(""InfoDiagnostic"", ""InfoDiagnostic:InfoDiagnostic"", Justification = ""{FeaturesResources.Pending}"", Scope = ""member"", Target = ""~M:Class1.Method~System.Int32"")]
......@@ -587,10 +587,10 @@ class Class2
".Replace("<", "&lt;").Replace(">", "&gt;");
var addedGlobalSuppressionsProject2 = $@"
// This file is used by Code Analysis to maintain SuppressMessage
var addedGlobalSuppressionsProject2 =
$@"// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage(""InfoDiagnostic"", ""InfoDiagnostic:InfoDiagnostic"", Justification = ""{FeaturesResources.Pending}"", Scope = ""member"", Target = ""~M:Class1.Method~System.Int32"")]
......@@ -697,10 +697,10 @@ class Class2
</Project>
</Workspace>";
var addedGlobalSuppressions = $@"
// This file is used by Code Analysis to maintain SuppressMessage
var addedGlobalSuppressions =
$@"// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage(""NoLocationDiagnostic"", ""NoLocationDiagnostic:NoLocationDiagnostic"", Justification = ""{FeaturesResources.Pending}"")]"
......
......@@ -980,10 +980,10 @@ Imports System
Dim x
End Sub
End Class]]>
Dim expected = $"
' This file is used by Code Analysis to maintain SuppressMessage
Dim expected =
$"' This file is used by Code Analysis to maintain SuppressMessage
' attributes that are applied to this project.
' Project-level suppressions either have no target or are given
' Project-level suppressions either have no target or are given
' a specific target and scoped to a namespace, type, member, etc.
<Assembly: System.Diagnostics.CodeAnalysis.SuppressMessage(""InfoDiagnostic"", ""InfoDiagnostic:InfoDiagnostic"", Justification:=""{FeaturesResources.Pending}"", Scope:=""type"", Target:=""~T:Class1"")>
......@@ -1018,10 +1018,10 @@ Imports System
End Sub
End Class
End Namespace]]>
Dim expected = $"
' This file is used by Code Analysis to maintain SuppressMessage
Dim expected =
$"' This file is used by Code Analysis to maintain SuppressMessage
' attributes that are applied to this project.
' Project-level suppressions either have no target or are given
' Project-level suppressions either have no target or are given
' a specific target and scoped to a namespace, type, member, etc.
<Assembly: System.Diagnostics.CodeAnalysis.SuppressMessage(""InfoDiagnostic"", ""InfoDiagnostic:InfoDiagnostic"", Justification:=""{FeaturesResources.Pending}"", Scope:=""namespace"", Target:=""~N:N"")>
......@@ -1060,10 +1060,10 @@ Namespace N1
End Class
End Namespace
End Namespace]]>
Dim expected = $"
' This file is used by Code Analysis to maintain SuppressMessage
Dim expected =
$"' This file is used by Code Analysis to maintain SuppressMessage
' attributes that are applied to this project.
' Project-level suppressions either have no target or are given
' Project-level suppressions either have no target or are given
' a specific target and scoped to a namespace, type, member, etc.
<Assembly: System.Diagnostics.CodeAnalysis.SuppressMessage(""InfoDiagnostic"", ""InfoDiagnostic:InfoDiagnostic"", Justification:=""{FeaturesResources.Pending}"", Scope:=""type"", Target:=""~T:N1.N2.Class1"")>
......@@ -1104,10 +1104,10 @@ Namespace N
End Class
End Class
End Namespace]]>
Dim expected = $"
' This file is used by Code Analysis to maintain SuppressMessage
Dim expected =
$"' This file is used by Code Analysis to maintain SuppressMessage
' attributes that are applied to this project.
' Project-level suppressions either have no target or are given
' Project-level suppressions either have no target or are given
' a specific target and scoped to a namespace, type, member, etc.
<Assembly: System.Diagnostics.CodeAnalysis.SuppressMessage(""InfoDiagnostic"", ""InfoDiagnostic:InfoDiagnostic"", Justification:=""{FeaturesResources.Pending}"", Scope:=""type"", Target:=""~T:N.Generic`1.Class1"")>
......@@ -1148,10 +1148,10 @@ Namespace N
End Class
End Class
End Namespace]]>
Dim expected = $"
' This file is used by Code Analysis to maintain SuppressMessage
Dim expected =
$"' This file is used by Code Analysis to maintain SuppressMessage
' attributes that are applied to this project.
' Project-level suppressions either have no target or are given
' Project-level suppressions either have no target or are given
' a specific target and scoped to a namespace, type, member, etc.
<Assembly: System.Diagnostics.CodeAnalysis.SuppressMessage(""InfoDiagnostic"", ""InfoDiagnostic:InfoDiagnostic"", Justification:=""{FeaturesResources.Pending}"", Scope:=""member"", Target:=""~M:N.Generic`1.Class1.Method"")>
......@@ -1196,10 +1196,10 @@ Namespace N
End Class
End Class
End Namespace]]>
Dim expected = $"
' This file is used by Code Analysis to maintain SuppressMessage
Dim expected =
$"' This file is used by Code Analysis to maintain SuppressMessage
' attributes that are applied to this project.
' Project-level suppressions either have no target or are given
' Project-level suppressions either have no target or are given
' a specific target and scoped to a namespace, type, member, etc.
<Assembly: System.Diagnostics.CodeAnalysis.SuppressMessage(""InfoDiagnostic"", ""InfoDiagnostic:InfoDiagnostic"", Justification:=""{FeaturesResources.Pending}"", Scope:=""member"", Target:=""~M:N.Generic`1.Class1.Method(System.Int32,System.Int32@)"")>
......@@ -1248,10 +1248,10 @@ Namespace N
End Class
End Class
End Namespace]]>
Dim expected = $"
' This file is used by Code Analysis to maintain SuppressMessage
Dim expected =
$"' This file is used by Code Analysis to maintain SuppressMessage
' attributes that are applied to this project.
' Project-level suppressions either have no target or are given
' Project-level suppressions either have no target or are given
' a specific target and scoped to a namespace, type, member, etc.
<Assembly: System.Diagnostics.CodeAnalysis.SuppressMessage(""InfoDiagnostic"", ""InfoDiagnostic:InfoDiagnostic"", Justification:=""{FeaturesResources.Pending}"", Scope:=""member"", Target:=""~M:N.Generic`1.Class1.Method``1(``0,System.Int32@)"")>
......@@ -1298,10 +1298,10 @@ Namespace N
End Class
End Class
End Namespace]]>
Dim expected = $"
' This file is used by Code Analysis to maintain SuppressMessage
Dim expected =
$"' This file is used by Code Analysis to maintain SuppressMessage
' attributes that are applied to this project.
' Project-level suppressions either have no target or are given
' Project-level suppressions either have no target or are given
' a specific target and scoped to a namespace, type, member, etc.
<Assembly: System.Diagnostics.CodeAnalysis.SuppressMessage(""InfoDiagnostic"", ""InfoDiagnostic:InfoDiagnostic"", Justification:=""{FeaturesResources.Pending}"", Scope:=""member"", Target:=""~P:N.Generic.C.P"")>
......@@ -1338,10 +1338,10 @@ Imports System
Class C
[|Private ReadOnly F As Integer|]
End Class]]>
Dim expected = $"
' This file is used by Code Analysis to maintain SuppressMessage
Dim expected =
$"' This file is used by Code Analysis to maintain SuppressMessage
' attributes that are applied to this project.
' Project-level suppressions either have no target or are given
' Project-level suppressions either have no target or are given
' a specific target and scoped to a namespace, type, member, etc.
<Assembly: System.Diagnostics.CodeAnalysis.SuppressMessage(""InfoDiagnostic"", ""InfoDiagnostic:InfoDiagnostic"", Justification:=""{FeaturesResources.Pending}"", Scope:=""member"", Target:=""~F:C.F"")>
......@@ -1394,10 +1394,10 @@ Class C
End RemoveHandler
End Event
End Class]]>
Dim expected = $"
' This file is used by Code Analysis to maintain SuppressMessage
Dim expected =
$"' This file is used by Code Analysis to maintain SuppressMessage
' attributes that are applied to this project.
' Project-level suppressions either have no target or are given
' Project-level suppressions either have no target or are given
' a specific target and scoped to a namespace, type, member, etc.
<Assembly: System.Diagnostics.CodeAnalysis.SuppressMessage(""InfoDiagnostic"", ""InfoDiagnostic:InfoDiagnostic"", Justification:=""{FeaturesResources.Pending}"", Scope:=""member"", Target:=""~E:C.SampleEvent"")>
......@@ -1456,10 +1456,9 @@ End Class
[|Class Class2|]
End Class]]>
</Document>
<Document FilePath="GlobalSuppressions.vb"><![CDATA[
' This file is used by Code Analysis to maintain SuppressMessage
<Document FilePath="GlobalSuppressions.vb"><![CDATA[' This file is used by Code Analysis to maintain SuppressMessage
' attributes that are applied to this project.
' Project-level suppressions either have no target or are given
' Project-level suppressions either have no target or are given
' a specific target and scoped to a namespace, type, member, etc.
<Assembly: Diagnostics.CodeAnalysis.SuppressMessage("InfoDiagnostic", "InfoDiagnostic:InfoDiagnostic", Justification:="<Pending>", Scope:="type", Target:="Class1")>
......@@ -1468,10 +1467,10 @@ End Class]]>
</Project>
</Workspace>
Dim expected = $"
' This file is used by Code Analysis to maintain SuppressMessage
Dim expected =
$"' This file is used by Code Analysis to maintain SuppressMessage
' attributes that are applied to this project.
' Project-level suppressions either have no target or are given
' Project-level suppressions either have no target or are given
' a specific target and scoped to a namespace, type, member, etc.
<Assembly: Diagnostics.CodeAnalysis.SuppressMessage(""InfoDiagnostic"", ""InfoDiagnostic:InfoDiagnostic"", Justification:=""<Pending>"", Scope:=""type"", Target:=""Class1"")>
......@@ -1505,10 +1504,10 @@ End Class
</Project>
</Workspace>
Dim expected = $"
' This file is used by Code Analysis to maintain SuppressMessage
Dim expected =
$"' This file is used by Code Analysis to maintain SuppressMessage
' attributes that are applied to this project.
' Project-level suppressions either have no target or are given
' Project-level suppressions either have no target or are given
' a specific target and scoped to a namespace, type, member, etc.
<Assembly: Diagnostics.CodeAnalysis.SuppressMessage(""InfoDiagnostic"", ""InfoDiagnostic:InfoDiagnostic"", Justification:=""{FeaturesResources.Pending}"", Scope:=""type"", Target:=""~T:Class2"")>
......@@ -1538,10 +1537,9 @@ Class Class3
End Class
]]>
</Document>
<Document FilePath="GlobalSuppressions2.vb"><![CDATA[
' This file is used by Code Analysis to maintain SuppressMessage
<Document FilePath="GlobalSuppressions2.vb"><![CDATA[' This file is used by Code Analysis to maintain SuppressMessage
' attributes that are applied to this project.
' Project-level suppressions either have no target or are given
' Project-level suppressions either have no target or are given
' a specific target and scoped to a namespace, type, member, etc.
<Assembly: Diagnostics.CodeAnalysis.SuppressMessage("InfoDiagnostic", "InfoDiagnostic:InfoDiagnostic", Justification:="<Pending>", Scope:="type", Target:="Class1")>
......@@ -1550,10 +1548,10 @@ End Class
</Project>
</Workspace>
Dim expected = $"
' This file is used by Code Analysis to maintain SuppressMessage
Dim expected =
$"' This file is used by Code Analysis to maintain SuppressMessage
' attributes that are applied to this project.
' Project-level suppressions either have no target or are given
' Project-level suppressions either have no target or are given
' a specific target and scoped to a namespace, type, member, etc.
<Assembly: Diagnostics.CodeAnalysis.SuppressMessage(""InfoDiagnostic"", ""InfoDiagnostic:InfoDiagnostic"", Justification:=""<Pending>"", Scope:=""type"", Target:=""Class1"")>
......
......@@ -20,10 +20,9 @@ internal abstract partial class AbstractSuppressionCodeFixProvider : IConfigurat
public const string SuppressMessageAttributeName = "System.Diagnostics.CodeAnalysis.SuppressMessage";
private const string s_globalSuppressionsFileName = "GlobalSuppressions";
private const string s_suppressionsFileCommentTemplate =
@"
{0} This file is used by Code Analysis to maintain SuppressMessage
@"{0} This file is used by Code Analysis to maintain SuppressMessage
{0} attributes that are applied to this project.
{0} Project-level suppressions either have no target or are given
{0} Project-level suppressions either have no target or are given
{0} a specific target and scoped to a namespace, type, member, etc.
";
......
......@@ -233,7 +233,7 @@ public override AdjustSpacesOperation GetAdjustSpacesOperation(SyntaxToken previ
{
// current implementation of engine gives higher priority on new line operations over space operations if
// two are conflicting.
// ex) new line operation says add 1 line between tokens, and
// ex) new line operation says add 1 line between tokens, and
// space operation says give 1 space between two tokens (basically means remove new lines)
// then, engine will pick new line operation and ignore space operation
......@@ -276,15 +276,15 @@ private int LineBreaksAfter(SyntaxToken previousToken, SyntaxToken currentToken)
|| currentToken.Kind() == SyntaxKind.OpenBraceToken) ? 1 : 0;
case SyntaxKind.CloseBracketToken:
// Assembly and module-level attributes followed by non-attributes should have
// a blank line after them.
// Assembly and module-level attributes followed by non-attributes should have a blank line after
// them, unless it's the end of the file which will already have a blank line.
if (previousToken.Parent is AttributeListSyntax parent)
{
if (parent.Target != null &&
(parent.Target.Identifier.IsKindOrHasMatchingText(SyntaxKind.AssemblyKeyword) ||
parent.Target.Identifier.IsKindOrHasMatchingText(SyntaxKind.ModuleKeyword)))
{
if (!(currentToken.Parent is AttributeListSyntax))
if (!currentToken.IsKind(SyntaxKind.EndOfFileToken) && !(currentToken.Parent is AttributeListSyntax))
{
return 2;
}
......
......@@ -60,7 +60,6 @@ public async Task TestAddAssemblyAttributeListToEmptyDocument()
await TestAsync(
string.Empty,
@"[assembly: System.Reflection.AssemblyVersion(""1.0.0.0"")]
");
}
......@@ -71,7 +70,6 @@ public async Task TestAddAssemblyAttributeListToDocumentWithOtherAssemblyAttribu
@"[assembly: System.Reflection.AssemblyName(""Test"")]",
@"[assembly: System.Reflection.AssemblyName(""Test"")]
[assembly: System.Reflection.AssemblyVersion(""1.0.0.0"")]
");
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册