-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Khathawut Chaipraphun <kchaipraphun@gf2vghxc6l.agoda.local>
- Loading branch information
1 parent
088e35d
commit 74e0ffa
Showing
7 changed files
with
155 additions
and
201 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,4 +36,4 @@ public void TestMethod() { | |
await VerifyDiagnosticsAsync(code, new DiagnosticLocation(8, 57)); | ||
} | ||
|
||
} | ||
} |
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,37 @@ | ||
using System.Threading.Tasks; | ||
using System.Web.Mvc; | ||
using Agoda.Analyzers.AgodaCustom; | ||
using Agoda.Analyzers.Test.Helpers; | ||
using Microsoft.CodeAnalysis.Diagnostics; | ||
using NUnit.Framework; | ||
using Microsoft.Playwright; | ||
|
||
namespace Agoda.Analyzers.Test.AgodaCustom; | ||
|
||
[TestFixture] | ||
class AG0040UnitTests : DiagnosticVerifier | ||
{ | ||
protected override DiagnosticAnalyzer DiagnosticAnalyzer => new AG0040DependencyResolverMustNotBeUsed(); | ||
|
||
protected override string DiagnosticId => AG0040DependencyResolverMustNotBeUsed.DIAGNOSTIC_ID; | ||
|
||
[Test] | ||
public async Task TestDependencyResolverUsageAsync() | ||
{ | ||
var code = new CodeDescriptor | ||
{ | ||
References = new[] {typeof(WaitUntilState).Assembly}, | ||
Code = @" | ||
using Microsoft.Playwright; | ||
class MyClass { | ||
public MyClass () { | ||
var a = WaitUntilState.NetworkIdle; | ||
} | ||
} | ||
" | ||
}; | ||
await VerifyDiagnosticsAsync(code, new DiagnosticLocation(6, 51)); | ||
} | ||
|
||
} |
42 changes: 42 additions & 0 deletions
42
src/Agoda.Analyzers/AgodaCustom/AG0040DependencyResolverMustNotBeUsed.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,42 @@ | ||
using System.Collections.Generic; | ||
using Agoda.Analyzers.Helpers; | ||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.Diagnostics; | ||
|
||
namespace Agoda.Analyzers.AgodaCustom | ||
{ | ||
[DiagnosticAnalyzer(LanguageNames.CSharp)] | ||
public class AG0040DependencyResolverMustNotBeUsed : PropertyInvocationAnalyzerBase | ||
{ | ||
public const string DIAGNOSTIC_ID = "AG0040"; | ||
|
||
private static readonly LocalizableString Title = new LocalizableResourceString( | ||
nameof(CustomRulesResources.AG0040Title), | ||
CustomRulesResources.ResourceManager, | ||
typeof(CustomRulesResources)); | ||
|
||
private static readonly LocalizableString MessageFormat = new LocalizableResourceString( | ||
nameof(CustomRulesResources.AG0040MessageFormat), | ||
CustomRulesResources.ResourceManager, | ||
typeof(CustomRulesResources)); | ||
|
||
private static readonly LocalizableString Description | ||
= DescriptionContentLoader.GetAnalyzerDescription(nameof(AG0040DependencyResolverMustNotBeUsed)); | ||
|
||
protected override DiagnosticDescriptor Descriptor => new DiagnosticDescriptor( | ||
DIAGNOSTIC_ID, | ||
Title, | ||
MessageFormat, | ||
AnalyzerCategory.CustomQualityRules, | ||
DiagnosticSeverity.Warning, | ||
AnalyzerConstants.EnabledByDefault, | ||
Description, | ||
"https://playwright.dev/dotnet/docs/api/class-page#page-go-back", | ||
WellKnownDiagnosticTags.EditAndContinue); | ||
|
||
protected override IEnumerable<InvocationRule> Rules => new[] | ||
{ | ||
new BlacklistedInvocationRule("Microsoft.Playwright.WaitUntilState", "NetworkIdle") | ||
}; | ||
} | ||
} |
Oops, something went wrong.