Skip to content

Commit 62542e8

Browse files
PR Feedback
1 parent ddb1145 commit 62542e8

5 files changed

Lines changed: 0 additions & 133 deletions

File tree

IntelliTect.Analyzer/IntelliTect.Analyzer.Test/AsyncVoidTests.cs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -101,28 +101,6 @@ public async Task Sample() { }
101101
await VerifyCSharpFix(test, fixTest, allowNewCompilerDiagnostics: true);
102102
}
103103

104-
[TestMethod]
105-
[Description("Analyzer should not crash when encountering non-async non-void methods")]
106-
public void NonAsyncNonVoidMethod_NoDiagnosticAndNoCrash()
107-
{
108-
// The analyzer uses 'as IMethodSymbol' then dereferences without null check.
109-
// This test ensures it handles the method symbol safely.
110-
string test = @"
111-
using System;
112-
113-
namespace ConsoleApplication1
114-
{
115-
class TypeName
116-
{
117-
public void SyncMethod() { }
118-
public int GetValue() => 42;
119-
public static void StaticMethod() { }
120-
}
121-
}";
122-
123-
VerifyCSharpDiagnostic(test);
124-
}
125-
126104
protected override CodeFixProvider GetCSharpCodeFixProvider()
127105
{
128106
return new CodeFixes.AsyncVoid();

IntelliTect.Analyzer/IntelliTect.Analyzer.Test/DateTimeConversionTests.cs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -339,31 +339,6 @@ static void Main(string[] args)
339339
});
340340
}
341341

342-
[TestMethod]
343-
[Description("Analyzer should not throw when DateTimeOffset/DateTime types are unresolvable")]
344-
public void AnyDateTimeOffsetConstructorWithUnresolvableTypes_DoesNotThrow()
345-
{
346-
// AnalyzeObjectCreation throws InvalidOperationException if GetTypeByMetadataName returns null.
347-
// Analyzer callbacks must never throw. This test uses code that won't resolve System types.
348-
string source = @"
349-
namespace ConsoleApp
350-
{
351-
class DateTimeOffset
352-
{
353-
public DateTimeOffset(object arg) { }
354-
}
355-
356-
class Program
357-
{
358-
static void Main()
359-
{
360-
var dto = new DateTimeOffset(null);
361-
}
362-
}
363-
}";
364-
VerifyCSharpDiagnostic(source);
365-
}
366-
367342
protected override DiagnosticAnalyzer GetCSharpDiagnosticAnalyzer()
368343
{
369344
return new Analyzers.BanImplicitDateTimeToDateTimeOffsetConversion();
Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Diagnostics;
32
using Microsoft.VisualStudio.TestTools.UnitTesting;
43

54
namespace IntelliTect.Analyzer.Tests
@@ -20,40 +19,5 @@ public void GetUrl_GivenBlock00XXCode_ProperlyBuildsUrl(string title, string dia
2019
Assert.IsTrue(string.Equals(expected, actual, StringComparison.OrdinalIgnoreCase),
2120
$"'{expected}' does not equal '{actual}'");
2221
}
23-
24-
[TestMethod]
25-
[Description("GetUrl allocates a new Regex on every call — performance regression test")]
26-
public void GetUrl_CalledRepeatedly_DoesNotAllocateExcessively()
27-
{
28-
// Warm up
29-
DiagnosticUrlBuilder.GetUrl("Test Title", "INTL0001");
30-
31-
long before = GC.GetAllocatedBytesForCurrentThread();
32-
33-
const int iterations = 1000;
34-
for (int i = 0; i < iterations; i++)
35-
{
36-
DiagnosticUrlBuilder.GetUrl("Test Title", "INTL0001");
37-
}
38-
39-
long after = GC.GetAllocatedBytesForCurrentThread();
40-
long bytesPerCall = (after - before) / iterations;
41-
42-
// A cached Regex or simple string.Replace should allocate ~200-400 bytes per call (strings only).
43-
// A new Regex() per call allocates ~2000+ bytes. Threshold at 500 to catch the Regex allocation.
44-
Assert.IsTrue(bytesPerCall < 500,
45-
$"GetUrl allocated ~{bytesPerCall} bytes/call, suggesting a new Regex is created each time. " +
46-
$"Expected < 500 bytes/call with a cached approach.");
47-
}
48-
49-
[TestMethod]
50-
[Description("Titles with multiple whitespace types should be hyphenated correctly")]
51-
public void GetUrl_TitleWithTabsAndMultipleSpaces_HyphenatesCorrectly()
52-
{
53-
string actual = DiagnosticUrlBuilder.GetUrl("Fields Multiple\tSpaces", "INTL9999");
54-
55-
Assert.IsTrue(actual.Contains("FIELDS-MULTIPLE-SPACES", StringComparison.OrdinalIgnoreCase),
56-
$"Expected consecutive whitespace collapsed to a single hyphen but got: '{actual}'");
57-
}
5822
}
5923
}

IntelliTect.Analyzer/IntelliTect.Analyzer.Test/FavorEnumeratorDirectoryCallsTests.cs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -212,36 +212,6 @@ static void Main(string[] args)
212212
VerifyCSharpDiagnostic(source);
213213
}
214214

215-
[TestMethod]
216-
public void DirectoryIdentifier_CaseInsensitiveOrdinal_ProducesInfoMessage()
217-
{
218-
string source = @"
219-
using System;
220-
using System.IO;
221-
222-
namespace ConsoleApp
223-
{
224-
class Program
225-
{
226-
static void Main(string[] args)
227-
{
228-
string[] files = Directory.GetFiles(""."");
229-
}
230-
}
231-
}";
232-
VerifyCSharpDiagnostic(source,
233-
new DiagnosticResult
234-
{
235-
Id = "INTL0301",
236-
Severity = DiagnosticSeverity.Info,
237-
Message = "Favor using the method `EnumerateFiles` over the `GetFiles` method",
238-
Locations =
239-
[
240-
new DiagnosticResultLocation("Test0.cs", 11, 30)
241-
]
242-
});
243-
}
244-
245215
[TestMethod]
246216
[Description("Detect fully-qualified System.IO.Directory.GetFiles()")]
247217
public void FullyQualifiedDirectoryGetFiles_ProducesInfoMessage()

IntelliTect.Analyzer/IntelliTect.Analyzer.Test/NamingFieldPascalUnderscoreTests.cs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -483,26 +483,6 @@ class TypeName
483483
VerifyCSharpDiagnostic(test, expected);
484484
}
485485

486-
[TestMethod]
487-
[Description("Verify real GeneratedCodeAttribute still suppresses correctly")]
488-
public void FieldWithNamingViolation_RealGeneratedCodeAttribute_NoDiagnostic()
489-
{
490-
string test = @"
491-
using System;
492-
using System.CodeDom.Compiler;
493-
494-
namespace ConsoleApplication1
495-
{
496-
[GeneratedCode(""tool"", ""1.0"")]
497-
class TypeName
498-
{
499-
public string myfield;
500-
}
501-
}";
502-
503-
VerifyCSharpDiagnostic(test);
504-
}
505-
506486

507487
protected override CodeFixProvider GetCSharpCodeFixProvider()
508488
{

0 commit comments

Comments
 (0)