Skip to content

Commit 2da3b30

Browse files
fix: INTL 0003 Failing on Top Level Statements (#268)
Fixes #267
1 parent 8b3eb47 commit 2da3b30

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

IntelliTect.Analyzer/IntelliTect.Analyzer.Test/NamingMethodPascalTests.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@ public string MyMethod()
7777
VerifyCSharpDiagnostic(test);
7878
}
7979

80+
[TestMethod]
81+
public void ProperlyNamedMethod_TopLevelStatements_NoDiagnosticInformationReturned()
82+
{
83+
string test = @"
84+
Console.WriteLine(""Hello World!"");";
85+
86+
VerifyCSharpDiagnostic(test);
87+
}
88+
8089
[TestMethod]
8190
public void AutoProperty_PascalCasedMethod_NoDiagnosticInformationReturned()
8291
{

IntelliTect.Analyzer/IntelliTect.Analyzer/Analyzers/NamingMethodPascal.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System;
33
using System.Collections.Immutable;
44
using System.Linq;
5+
using System.Xml.Linq;
56
using IntelliTect.Analyzer.Naming;
67
using Microsoft.CodeAnalysis;
78
using Microsoft.CodeAnalysis.CSharp;
@@ -77,6 +78,12 @@ private static void AnalyzeSymbol(SymbolAnalysisContext context)
7778
default: return;
7879
}
7980

81+
// Common symbols for generated code to use, including the main method for top-level statements.
82+
if (name.Contains('<') || name.Contains('>'))
83+
{
84+
return;
85+
}
86+
8087
if (Casing.IsPascalCase(name))
8188
{
8289
return;

0 commit comments

Comments
 (0)