forked from dotnet/roslynator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check UsedImplicitlyAttribute (RCS1074) (dotnet#968)
- Loading branch information
1 parent
6875799
commit ed98184
Showing
3 changed files
with
66 additions
and
15 deletions.
There are no files selected for viewing
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
53 changes: 53 additions & 0 deletions
53
src/Tests/Analyzers.Tests/RCS1074RemoveRedundantConstructorTests.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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright (c) Josef Pihrt and Contributors. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System.Threading.Tasks; | ||
using Microsoft.CodeAnalysis; | ||
using Roslynator.CSharp.CodeFixes; | ||
using Roslynator.Testing.CSharp; | ||
using Xunit; | ||
|
||
namespace Roslynator.CSharp.Analysis.Tests | ||
{ | ||
public class RCS1074RemoveRedundantConstructorTests : AbstractCSharpDiagnosticVerifier<RemoveRedundantConstructorAnalyzer, ConstructorDeclarationCodeFixProvider> | ||
{ | ||
public override DiagnosticDescriptor Descriptor { get; } = DiagnosticRules.RemoveRedundantConstructor; | ||
|
||
[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.RemoveRedundantConstructor)] | ||
public async Task Test_SingleInstanceConstructor() | ||
{ | ||
await VerifyDiagnosticAndFixAsync(@" | ||
class C | ||
{ | ||
[|public C() | ||
{ | ||
}|] | ||
} | ||
", @" | ||
class C | ||
{ | ||
} | ||
"); | ||
} | ||
|
||
[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.RemoveRedundantConstructor)] | ||
public async Task TestNoDiagnostic_UsedImplicitlyAttribute() | ||
{ | ||
await VerifyNoDiagnosticAsync(@" | ||
class C | ||
{ | ||
[JetBrains.Annotations.UsedImplicitly] | ||
public C() | ||
{ | ||
} | ||
} | ||
namespace JetBrains.Annotations | ||
{ | ||
public class UsedImplicitlyAttribute : System.Attribute | ||
{ | ||
} | ||
} | ||
"); | ||
} | ||
} | ||
} |