Skip to content

Commit

Permalink
Disable LC003 and LC005 for DotNet var/param names (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
rvanbekkum authored and StefanMaron committed Jan 5, 2022
1 parent 9d53c6b commit 1dad3f8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Design/Rule0003DoNotUseObjectIDsInVariablesOrProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ private void CheckForObjectIDsInVariablesOrProperties(SyntaxNodeAnalysisContext

foreach (IParameterSymbol parameter in method.Parameters)
{
if (parameter.ParameterType.NavTypeKind == NavTypeKind.DotNet)
{
continue;
}

if (ctx.Node.GetLocation().SourceSpan.End == parameter.DeclaringSyntaxReference.GetSyntax(CancellationToken.None).Span.End)
{
correctName = GetCorrectName(parameter.ParameterType.NavTypeKind.ToString(), parameter.ParameterType.ToString());
Expand All @@ -98,7 +103,11 @@ private void CheckForObjectIDsInVariablesOrProperties(SyntaxNodeAnalysisContext
}
try
{
IReturnValueSymbol returnValue = (IReturnValueSymbol)method.ReturnValueSymbol;
IReturnValueSymbol returnValue = method.ReturnValueSymbol;
if (returnValue.ReturnType.NavTypeKind == NavTypeKind.DotNet)
{
return;
}

if (ctx.Node.GetLocation().SourceSpan.End == returnValue.DeclaringSyntaxReference.GetSyntax(CancellationToken.None).Span.End)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ private void CheckForBuiltInTypeCasingMismatch(SymbolAnalysisContext ctx)
{
foreach (var node in ctx.Symbol.DeclaringSyntaxReference.GetSyntax().DescendantNodesAndTokens().Where(n => IsValidToken(n)))
{
if (node.Kind.ToString().StartsWith("DotNet"))
{
continue;
}

if (node.IsToken)
if (SyntaxFactory.Token(node.Kind).ToString() != node.ToString())
ctx.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.Rule0005VariableCasingShouldNotDIfferFromDeclaration, node.GetLocation(), new object[] { SyntaxFactory.Token(node.Kind), "" }));
Expand Down

0 comments on commit 1dad3f8

Please sign in to comment.