-
Notifications
You must be signed in to change notification settings - Fork 510
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3483 from sharwell/property-pattern
Support extended property patterns in SA1101
- Loading branch information
Showing
6 changed files
with
56 additions
and
10 deletions.
There are no files selected for viewing
31 changes: 29 additions & 2 deletions
31
...op.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1101CSharp10UnitTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,40 @@ | ||
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. | ||
// Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
||
#nullable disable | ||
|
||
namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules | ||
{ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.CodeAnalysis.CSharp; | ||
using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; | ||
using StyleCop.Analyzers.Test.Verifiers; | ||
using Xunit; | ||
using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< | ||
StyleCop.Analyzers.ReadabilityRules.SA1101PrefixLocalCallsWithThis, | ||
StyleCop.Analyzers.ReadabilityRules.SA1101CodeFixProvider>; | ||
|
||
public class SA1101CSharp10UnitTests : SA1101CSharp9UnitTests | ||
{ | ||
[Fact] | ||
[WorkItem(3472, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3472")] | ||
public async Task TestExtendedPropertyPatternAsync() | ||
{ | ||
var testCode = @"public class Test | ||
{ | ||
public Test Inner; | ||
public string Value; | ||
public bool Method(Test arg) | ||
{ | ||
return arg is { Inner.Value: """" }; | ||
} | ||
}"; | ||
|
||
await new CSharpTest(LanguageVersion.CSharp10) | ||
{ | ||
ReferenceAssemblies = GenericAnalyzerTest.ReferenceAssembliesNet60, | ||
TestCode = testCode, | ||
}.RunAsync(CancellationToken.None).ConfigureAwait(false); | ||
} | ||
} | ||
} |
2 changes: 0 additions & 2 deletions
2
...eCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1101CSharp7UnitTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 24 additions & 2 deletions
26
...eCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1101CSharp8UnitTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,35 @@ | ||
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. | ||
// Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
||
#nullable disable | ||
|
||
namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules | ||
{ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.CodeAnalysis.Testing; | ||
using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; | ||
using Xunit; | ||
using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< | ||
StyleCop.Analyzers.ReadabilityRules.SA1101PrefixLocalCallsWithThis, | ||
StyleCop.Analyzers.ReadabilityRules.SA1101CodeFixProvider>; | ||
|
||
public class SA1101CSharp8UnitTests : SA1101CSharp7UnitTests | ||
{ | ||
[Fact] | ||
[WorkItem(3472, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3472")] | ||
public async Task TestPropertyPatternAsync() | ||
{ | ||
var testCode = @"public class Test | ||
{ | ||
public Test Inner; | ||
public string Value; | ||
public bool Method(Test arg) | ||
{ | ||
return arg is { Value: """" }; | ||
} | ||
}"; | ||
|
||
await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); | ||
} | ||
} | ||
} |
2 changes: 0 additions & 2 deletions
2
...eCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1101CSharp9UnitTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1101UnitTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters