Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 3, 2026

INTL0003 was flagging test methods with underscores (e.g., Method_Scenario_ExpectedResult) as PascalCase violations. Test methods commonly use underscores for readability and should be exempt.

Changes:

  • Added IsTestMethod() check in NamingMethodPascal analyzer to skip methods decorated with test attributes
  • Uses namespace-based detection to automatically recognize test attributes from xUnit, NUnit, MSTest, and TUnit frameworks
  • Any attribute from the Xunit, NUnit.Framework, Microsoft.VisualStudio.TestTools.UnitTesting, or TUnit.Core namespaces is automatically recognized
  • Includes fallback to common test attribute name checking for test environments where namespace metadata may be incomplete
  • Added test coverage for MSTest, xUnit, and NUnit frameworks
  • Updated docs to document the exception

Example:

[TestClass]
public class FooTests
{
    [TestMethod]
    public void FooThing_IsFooThing_HasFooThing() // No longer triggers INTL0003
    {
        Assert.IsTrue(true);
    }
    
    public void myNonTestMethod() // Still triggers INTL0003
    {
    }
}

This namespace-based approach provides better maintainability and automatically supports new test attributes added to these frameworks without requiring code changes to the analyzer.

Original prompt

This section details on the original issue you should resolve

<issue_title>Test Method triggers INTL0003</issue_title>
<issue_description>A Test method like "FooThing_IsFooThing_HasFooThing" Triggers INTL0003 in a test project when I don't think it should</issue_description>

<agent_instructions>FIRST write a test that fails to prove the bug. THEN write a fix, to fix the bug and make sure the test passes.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Fix test method triggering INTL0003 error Skip INTL0003 PascalCase validation for test methods Feb 3, 2026
@BenjaminMichaelis
Copy link
Member

@copilot maybe we should loosen it up a bit more. Maybe we ignore underscores in any method that is decorated by an attribute in the XUnit, NUnit, MSTest, or TUnit namespaces.

Copy link
Contributor Author

Copilot AI commented Feb 3, 2026

@copilot maybe we should loosen it up a bit more. Maybe we ignore underscores in any method that is decorated by an attribute in the XUnit, NUnit, MSTest, or TUnit namespaces.

Updated the implementation to check attribute namespaces instead of specific attribute names. The analyzer now automatically recognizes any test attributes from Xunit, NUnit.Framework, Microsoft.VisualStudio.TestTools.UnitTesting, and TUnit.Core namespaces. This provides better coverage and maintainability.

Implemented in commit 99ba578 with a fallback to attribute name checking for test environments where namespace metadata may be incomplete.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • pe3vsblobprodcus354.vsblob.vsassets.io
    • Triggering command: /usr/share/dotnet/dotnet dotnet restore --no-dependencies /home/REDACTED/work/CodingGuidelines/CodingGuidelines/Tools/XMLtoMD/GuidelineXmlToMD.sln --packages /home/REDACTED/work/CodingGuidelines/.codeql-scratch/dbs/csharp/working/packages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal /p:TargetFrameworkRootPath=/home/REDACTED/work/CodingGuidelines/.codeql-scratch/dbs/csharp/working/emptyFakeDotnetRoot /p:NetCoreTargetingPackRoot=/home/REDACTED/work/CodingGuidelines/.codeql-scratch/dbs/csharp/working/emptyFakeDotnetRoot /p:AllowMissingPrunePackageData=true (dns block)
    • Triggering command: /usr/share/dotnet/dotnet dotnet restore --no-dependencies /home/REDACTED/work/CodingGuidelines/CodingGuidelines/Tools/XMLtoMD/GuidelineXmlToMD/GuidelineXmlToMD.csproj --packages /home/REDACTED/work/CodingGuidelines/.codeql-scratch/dbs/csharp/working/packages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal /p:TargetFrameworkRootPath=/home/REDACTED/work/CodingGuidelines/.codeql-scratch/dbs/csharp/working/emptyFakeDotnetRoot /p:NetCoreTargetingPackRoot=/home/REDACTED/work/CodingGuidelines/.codeql-scratch/dbs/csharp/working/emptyFakeDotnetRoot /p:AllowMissingPrunePackageData=true (dns block)
    • Triggering command: /usr/share/dotnet/dotnet dotnet restore --no-dependencies /home/REDACTED/work/CodingGuidelines/CodingGuidelines/Tools/XMLtoMD/GuidelineXmlToMD.Test/GuidelineXmlToMD.Test.csproj --packages /home/REDACTED/work/CodingGuidelines/.codeql-scratch/dbs/csharp/working/packages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal /p:TargetFrameworkRootPath=/home/REDACTED/work/CodingGuidelines/.codeql-scratch/dbs/csharp/working/emptyFakeDotnetRoot /p:NetCoreTargetingPackRoot=/home/REDACTED/work/CodingGuidelines/.codeql-scratch/dbs/csharp/working/emptyFakeDotnetRoot /p:AllowMissingPrunePackageData=true (dns block)
  • s8mvsblobprodcus38.vsblob.vsassets.io
    • Triggering command: /usr/share/dotnet/dotnet dotnet restore --no-dependencies /home/REDACTED/work/CodingGuidelines/.codeql-scratch/dbs/csharp/working/152969D1C94CACFB2DD8DDFC3D3B91A8/missingpackages_workingdir --packages /home/REDACTED/work/CodingGuidelines/.codeql-scratch/dbs/csharp/working/missingpackages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal --configfile /home/REDACTED/work/CodingGuidelines/.codeql-scratch/dbs/csharp/working/nugetconfig/nuget.config --force (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@BenjaminMichaelis
Copy link
Member

@copilot I don't see the case where we would need Fallback attribute names for test environments where namespace metadata may be incomplete

Copy link
Contributor Author

Copilot AI commented Feb 3, 2026

@copilot I don't see the case where we would need Fallback attribute names for test environments where namespace metadata may be incomplete

You're right that in production code the namespace metadata should always be available. However, the fallback is needed for our test infrastructure - the DiagnosticVerifier test helper doesn't add references to test framework assemblies (MSTest, xUnit, NUnit), so when our tests use [TestMethod] or [Fact] attributes, the ContainingNamespace is null.

We have two options:

  1. Keep the fallback (simple, works now, doesn't hurt production usage)
  2. Update DiagnosticVerifier.Helper.cs to add MetadataReferences for test frameworks (more complex, might have assembly loading issues)

Which approach would you prefer?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test Method triggers INTL0003

2 participants