Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 8, 2026

MSTest 4.0+ provides OSCondition attribute for platform-specific tests, making the custom TestMethodForPlatformAttribute obsolete (MSTEST0061).

Changes

  • Replaced custom attribute usage across 6 test files (14 test methods total):

    // Before
    [TestMethodForPlatform(nameof(OSPlatform.Windows))]
    public void TestMethod() { }
    
    // After
    [TestMethod]
    [OSCondition(OperatingSystems.Windows)]
    public void TestMethod() { }
  • Removed test/Renci.SshNet.Tests/Common/TestMethodForPlatformAttribute.cs

  • Cleaned up unused imports: System.Runtime.InteropServices and Renci.SshNet.Tests.Common

Affected Test Classes

  • ForwardedPortDynamicTest_*_PortStarted_ChannelNotBound (2 files)
  • *ConnectorTest_Connect_TimeoutConnectingToProxy (4 files: Direct, Http, Socks4, Socks5)
Original prompt

This section details on the original issue you should resolve

<issue_title>TestMethodForPlatformAttribute can be replaced with [OSCondition(OperatingSystems.Windows)]</issue_title>
<issue_description>According to https://learn.microsoft.com/dotnet/core/testing/mstest-analyzers/mstest0061 the

public sealed class TestMethodForPlatformAttribute : TestMethodAttribute

can be replaced with e.g.:

[TestMethod]
[OSCondition(OperatingSystems.Windows)]

</issue_description>

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


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: Rob-Hague <5132141+Rob-Hague@users.noreply.github.com>
Copilot AI changed the title [WIP] Replace TestMethodForPlatformAttribute with OSCondition for Windows Replace custom TestMethodForPlatformAttribute with MSTest OSCondition Feb 8, 2026
Copilot AI requested a review from Rob-Hague February 8, 2026 16:39
@Rob-Hague Rob-Hague marked this pull request as ready for review February 10, 2026 18:48
Copy link
Member

@drieseng drieseng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx!

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.

TestMethodForPlatformAttribute can be replaced with [OSCondition(OperatingSystems.Windows)]

3 participants