Skip to content

Fix ApplicationStateGuard filename - rename Class1.cs to ApplicationStateGuard.cs#6298

Merged
nohwnd merged 4 commits intomainfrom
copilot/fix-6297
Aug 4, 2025
Merged

Fix ApplicationStateGuard filename - rename Class1.cs to ApplicationStateGuard.cs#6298
nohwnd merged 4 commits intomainfrom
copilot/fix-6297

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Aug 4, 2025

The ApplicationStateGuard class in the TestFramework project was incorrectly placed in a file named Class1.cs. This violates .NET naming conventions where the filename should match the class name.

Changes Made

  • Renamed src/TestFramework/TestFramework/Internal/Class1.cs to ApplicationStateGuard.cs
  • Added proper namespace declaration: Microsoft.VisualStudio.TestTools.UnitTesting
  • Maintained the exact same class implementation and method signatures

Before

// File: Class1.cs (incorrect filename)
// No namespace declaration

internal static class ApplicationStateGuard
{
    public static UnreachableException Unreachable([CallerFilePath] string? path = null, [CallerLineNumber] int line = 0)
        => new($"This program location is thought to be unreachable. File='{path}' Line={line}");
}

After

// File: ApplicationStateGuard.cs (correct filename)
namespace Microsoft.VisualStudio.TestTools.UnitTesting;

internal static class ApplicationStateGuard
{
    public static UnreachableException Unreachable([CallerFilePath] string? path = null, [CallerLineNumber] int line = 0)
        => new($"This program location is thought to be unreachable. File='{path}' Line={line}");
}

This change brings the TestFramework's ApplicationStateGuard implementation in line with the naming conventions used by other ApplicationStateGuard classes throughout the codebase (in Platform, Analyzers, and Adapter projects). The existing usage in Assert.AreEqual.cs continues to work unchanged since both files are in the same namespace.

Fixes #6297.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: nohwnd <5735905+nohwnd@users.noreply.github.com>
Copilot AI changed the title [WIP] ApplicationStateGuard filename is wrong Fix ApplicationStateGuard filename - rename Class1.cs to ApplicationStateGuard.cs Aug 4, 2025
Copilot AI requested a review from nohwnd August 4, 2025 10:53
Co-authored-by: Youssef1313 <31348972+Youssef1313@users.noreply.github.com>
@nohwnd nohwnd marked this pull request as ready for review August 4, 2025 12:25
@nohwnd nohwnd enabled auto-merge (squash) August 4, 2025 12:42
@nohwnd nohwnd merged commit aed6f05 into main Aug 4, 2025
9 checks passed
@nohwnd nohwnd deleted the copilot/fix-6297 branch August 4, 2025 12:56
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.

ApplicationStateGuard filename is wrong

4 participants