Skip to content
Open
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
2 changes: 1 addition & 1 deletion StyleCop.Analyzers/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<PackageReference Include="AsyncUsageAnalyzers" Version="1.0.0-alpha003" PrivateAssets="all" />
<PackageReference Include="DotNetAnalyzers.DocumentationAnalyzers" Version="1.0.0-beta.46" PrivateAssets="all" />
<PackageReference Include="NewStyleCop.Analyzers" Version="1.3.0-alpha.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="5.9.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="5.10.0-1.26417.4" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="5.3.0" PrivateAssets="all" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private static Task<Document> GetTransformedDocumentAsync(Document document, Syn
updatedDeclarationNode = HandleRecordDeclaration((RecordDeclarationSyntaxWrapper)declarationNode);
break;

case SyntaxKindEx.UnionDeclaration when declarationNode is not StructDeclarationSyntax: // TODO: Update when integrating the official c# 15 nuget
case SyntaxKindEx.UnionDeclaration:
updatedDeclarationNode = HandleUnionDeclaration((UnionDeclarationSyntaxWrapper)declarationNode);
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private static TypeDeclarationSyntax ReplaceModifiers(TypeDeclarationSyntax node
case SyntaxKindEx.RecordDeclaration:
case SyntaxKindEx.RecordStructDeclaration:
return ((RecordDeclarationSyntaxWrapper)node).WithModifiers(modifiers);
case SyntaxKindEx.UnionDeclaration when node is not StructDeclarationSyntax: // TODO: Update when integrating official c# 15 nuget
case SyntaxKindEx.UnionDeclaration:
return ((UnionDeclarationSyntaxWrapper)node).WithModifiers(modifiers);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public union TestUnion(string, int)
/// <summary>
/// A summary.
/// </summary>
public static int {|#0:TestProperty|}
public static int [|TestProperty|]
{
get { return 42; }
}
Expand All @@ -45,11 +45,7 @@ public static int TestProperty
}
";

// TODO: Report bug - The compiler calls the registered property declaration action three times
var expectedDiagnostic = Diagnostic().WithLocation(0);
DiagnosticResult[] expected = { expectedDiagnostic, expectedDiagnostic, expectedDiagnostic };

await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true);
await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,14 @@ public union TestUnion(string, int)
/// <value>
///
/// </value>
public static int {|#0:TestProperty|}
public static int [|TestProperty|]
{
get { return 42; }
}
}
";

// TODO: Report bug - The compiler calls the registered property declaration action three times
var expectedDiagnostic = Diagnostic().WithLocation(0);
DiagnosticResult[] expected = { expectedDiagnostic, expectedDiagnostic, expectedDiagnostic };

await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(true);
await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(true);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ public static void TestMethod(int {|#0:value|})
}
";

// TODO: Report bug - The compiler calls the registered method declaration action three times
var expectedDiagnostic = Diagnostic().WithLocation(0).WithArguments("value");
var expected = new[] { expectedDiagnostic, expectedDiagnostic, expectedDiagnostic };
var expected = new[] { Diagnostic().WithLocation(0).WithArguments("value") };

await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,9 @@ public static void TestMethod(int first, int second)
}
";

// TODO: Report bug - The compiler calls the registered method declaration action three times
var expectedDiagnostic1 = Diagnostic().WithMessageFormat("The parameter documentation for '{0}' should be at position {1}").WithLocation(0).WithArguments("second", "2");
var expectedDiagnostic2 = Diagnostic().WithMessageFormat("The parameter documentation for '{0}' should be at position {1}").WithLocation(1).WithArguments("first", "1");
var expected = new[]
{
expectedDiagnostic1, expectedDiagnostic1, expectedDiagnostic1,
expectedDiagnostic2, expectedDiagnostic2, expectedDiagnostic2,
};
var expected = new[] { expectedDiagnostic1, expectedDiagnostic2 };

await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,14 @@ public union TestUnion(string, int)
/// <summary>
/// A summary.
/// </summary>
/// {|#0:<param>A value.</param>|}
/// [|<param>A value.</param>|]
public static void TestMethod(int value)
{
}
}
";

// TODO: Report bug - The compiler calls the registered method declaration action three times
var expectedDiagnostic = Diagnostic().WithLocation(0);
var expected = new[] { expectedDiagnostic, expectedDiagnostic, expectedDiagnostic };

await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(true);
await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(true);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,14 @@ public union TestUnion(string, int)
/// <summary>
/// A summary.
/// </summary>
/// {|#0:<param name=""value""></param>|}
/// [|<param name=""value""></param>|]
public static void TestMethod(int value)
{
}
}
";

// TODO: Report bug - The compiler calls the registered method declaration action three times
var expectedDiagnostic = Diagnostic().WithLocation(0);
var expected = new[] { expectedDiagnostic, expectedDiagnostic, expectedDiagnostic };

await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(true);
await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(true);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace StyleCop.Analyzers.Test.CSharp15.DocumentationRules
{
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Testing;
using Xunit;
using static StyleCop.Analyzers.Test.CSharp6.Verifiers.StyleCopCodeFixVerifier<
StyleCop.Analyzers.DocumentationRules.SA1615ElementReturnValueMustBeDocumented,
Expand All @@ -21,7 +22,7 @@ public union TestUnion(string, int)
/// <summary>
/// A summary.
/// </summary>
public static {|#0:int|} TestMethod()
public static [|int|] TestMethod()
{
return 0;
}
Expand All @@ -42,10 +43,7 @@ public static int TestMethod()
}
";

// TODO: Report bug - The compiler calls the registered method declaration action three times
var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) };

await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true);
await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,17 @@ public union TestUnion(string, int)
/// <summary>
/// A summary.
/// </summary>
/// {|#0:<returns>
/// [|<returns>
///
/// </returns>|}
/// </returns>|]
public static int TestMethod()
{
return 0;
}
}
";

// TODO: Report bug - The compiler calls the registered method declaration action three times
var expectedDiagnostic = Diagnostic().WithLocation(0);
var expected = new[] { expectedDiagnostic, expectedDiagnostic, expectedDiagnostic };

await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(true);
await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(true);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace StyleCop.Analyzers.Test.CSharp15.DocumentationRules
{
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Testing;
using Xunit;
using static StyleCop.Analyzers.Test.CSharp6.Verifiers.StyleCopCodeFixVerifier<
StyleCop.Analyzers.DocumentationRules.SA1617VoidReturnValueMustNotBeDocumented,
Expand All @@ -21,7 +22,7 @@ public union TestUnion(string, int)
/// <summary>
/// A summary.
/// </summary>
/// {|#0:<returns>A value.</returns>|}
/// [|<returns>A value.</returns>|]
public static void TestMethod()
{
}
Expand All @@ -40,10 +41,7 @@ public static void TestMethod()
}
";

// TODO: Report bug - The compiler calls the registered method declaration action three times
var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) };

await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true);
await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,16 @@ public union TestUnion(string, int)
/// <summary>
/// Some documentation.
/// </summary>
/// {|#0:<summary>
/// [|<summary>
/// Some documentation.
/// </summary>|}
/// </summary>|]
public static void TestMethod()
{
}
}
";

// TODO: Report bug - The compiler calls the registered method declaration action three times
var expectedDiagnostic = Diagnostic().WithLocation(0);
var expected = new[] { expectedDiagnostic, expectedDiagnostic, expectedDiagnostic };

await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(true);
await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(true);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,12 @@ static TestUnion()
[Fact]
public async Task TestUnionStaticConstructorWithClassWordingAsync()
{
// TODO: Report bug - The compiler calls the registered constructor action three times
var testCode = @"
public union TestUnion(string, int)
{
/// {|#0:<summary>
/// [|<summary>
/// Initializes static members of the <see cref=""TestUnion""/> class.
/// </summary>|}
/// </summary>|]
static TestUnion()
{
}
Expand All @@ -60,9 +59,7 @@ static TestUnion()
}
";

var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) };

await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true);
await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true);
}

[Fact]
Expand All @@ -87,13 +84,12 @@ public TestUnion()
[Fact]
public async Task TestUnionInstanceConstructorWithClassWordingAsync()
{
// TODO: Report bug - The compiler calls the registered constructor action three times
var testCode = @"
public union TestUnion(string, int)
{
/// {|#0:<summary>
/// [|<summary>
/// Initializes a new instance of the <see cref=""TestUnion""/> class.
/// </summary>|}
/// </summary>|]
public TestUnion()
: this(string.Empty)
{
Expand All @@ -115,21 +111,18 @@ public TestUnion()
}
";

var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) };

await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true);
await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true);
}

[Fact]
public async Task TestGenericUnionStaticConstructorWithClassWordingAsync()
{
// TODO: Report bug - The compiler calls the registered constructor action three times
var testCode = @"
public union TestUnion<T>(T, int)
{
/// {|#0:<summary>
/// [|<summary>
/// Initializes static members of the <see cref=""TestUnion{T}""/> class.
/// </summary>|}
/// </summary>|]
static TestUnion()
{
}
Expand All @@ -149,9 +142,7 @@ static TestUnion()
}
";

var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) };

await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true);
await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace StyleCop.Analyzers.Test.CSharp15.LayoutRules
{
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Testing;
using Xunit;
using static StyleCop.Analyzers.Test.CSharp6.Verifiers.StyleCopCodeFixVerifier<
StyleCop.Analyzers.LayoutRules.SA1501StatementMustNotBeOnASingleLine,
Expand All @@ -20,7 +21,7 @@ public union TestUnion(string, int)
{
public static void TestMethod()
{
lock (new object()) {|#0:{|} System.Diagnostics.Debug.Assert(true); }
lock (new object()) [|{|] System.Diagnostics.Debug.Assert(true); }
}
}
";
Expand All @@ -38,10 +39,7 @@ public static void TestMethod()
}
";

// TODO: Report bug - The compiler calls the registered block action three times
var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) };

await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true);
await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace StyleCop.Analyzers.Test.CSharp15.LayoutRules
{
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Testing;
using Xunit;
using static StyleCop.Analyzers.Test.CSharp6.Verifiers.StyleCopCodeFixVerifier<
StyleCop.Analyzers.LayoutRules.SA1503BracesMustNotBeOmitted,
Expand All @@ -21,7 +22,7 @@ public union TestUnion(string, int)
public static void TestMethod()
{
if (true)
{|#0:System.Diagnostics.Debug.Assert(true);|}
[|System.Diagnostics.Debug.Assert(true);|]
}
}
";
Expand All @@ -39,10 +40,7 @@ public static void TestMethod()
}
";

// TODO: Report bug - The compiler calls the registered if statement action three times
var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) };

await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true);
await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true);
}
}
}
Loading