Summary
CA1416 Helps with identifying platform-API problems. If you decorate a TestMethod/Class with another Un/SupportedOSPlatformAttribute, CA1416 is happy, but the test still runs via MsTest
Background and Motivation
the Attributes are the "correct way"
Proposed Feature
Analyzer+CodeFix who finds dependencies like this:
[SupportedOSPlatform("linux")] -> [OSCondition(OperatingSystems.Linux)]
[UnupportedOSPlatform("linux")] -> [OSCondition(ConditionMode.Exclude, OperatingSystems.Linux)]
in my short thought process, this 1-to-1 mapping should work. But OSCondition is AllowMultiple=False. so there needs to be some clever thinking, or just some restrictions, ie only-exclude or only-include
[SupportedOSPlatform("linux"), SupportedOSPlatform("OSX")] -> [OSCondition(OperatingSystems.Linux | OperatingSystems.OSX)]
[SupportedOSPlatform("linux"), UnsupportedOSPlatform("OSX")] -> can't compute codefix, unless you read containg symbols attributes (class/assembly)
- also, consider the SupportedOSPlatformAttributes may contain a version a la "windows10.0".
- Analyzer should also check existing pairs, so that something like this can't happen:
- [SupportedOSPlatform("windows"), OSCondition(OperatingSystems.Linux)]
Alternative Designs
respect SupportedOSPlatformAttribute in MsTest
- bad, because then OSConditionAttributes are invalid on the same method/class
Summary
CA1416 Helps with identifying platform-API problems. If you decorate a TestMethod/Class with another
Un/SupportedOSPlatformAttribute, CA1416 is happy, but the test still runs via MsTestBackground and Motivation
the Attributes are the "correct way"
Proposed Feature
Analyzer+CodeFix who finds dependencies like this:
[SupportedOSPlatform("linux")] -> [OSCondition(OperatingSystems.Linux)]
[UnupportedOSPlatform("linux")] -> [OSCondition(ConditionMode.Exclude, OperatingSystems.Linux)]
in my short thought process, this 1-to-1 mapping should work. But OSCondition is AllowMultiple=False. so there needs to be some clever thinking, or just some restrictions, ie only-exclude or only-include
[SupportedOSPlatform("linux"), SupportedOSPlatform("OSX")] -> [OSCondition(OperatingSystems.Linux | OperatingSystems.OSX)]
[SupportedOSPlatform("linux"), UnsupportedOSPlatform("OSX")] -> can't compute codefix, unless you read containg symbols attributes (class/assembly)
Alternative Designs
respect SupportedOSPlatformAttribute in MsTest