Skip to content

Commit 35b12cb

Browse files
committed
Move VSMEF005 no-warning test to NoWarningTests; update copilot instructions
1 parent 45a1f8b commit 35b12cb

File tree

3 files changed

+38
-27
lines changed

3 files changed

+38
-27
lines changed

.github/copilot-instructions.md

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,71 +2,82 @@
22

33
## High level guidance
44

5-
* Review the `CONTRIBUTING.md` file for instructions to build and test the software.
6-
* Set the `NBGV_GitEngine` environment variable to `Disabled` before running any `dotnet` or `msbuild` commands.
5+
- Review the `CONTRIBUTING.md` file for instructions to build and test the software.
6+
- Set the `NBGV_GitEngine` environment variable to `Disabled` before running any `dotnet` or `msbuild` commands.
77

88
## Software Design
99

10-
* Design APIs to be highly testable, and all functionality should be tested.
11-
* Avoid introducing binary breaking changes in public APIs of projects under `src` unless their project files have `IsPackable` set to `false`.
10+
- Design APIs to be highly testable, and all functionality should be tested.
11+
- Avoid introducing binary breaking changes in public APIs of projects under `src` unless their project files have `IsPackable` set to `false`.
1212

1313
## Testing
1414

1515
**IMPORTANT**: This repository uses Microsoft.Testing.Platform (MTP v2) with xunit v3. Traditional `--filter` syntax does NOT work. Use the options below instead.
1616

17-
* There should generally be one test project (under the `test` directory) per shipping project (under the `src` directory). Test projects are named after the project being tested with a `.Tests` suffix.
18-
* Tests use xunit v3 with Microsoft.Testing.Platform (MTP v2). Traditional VSTest `--filter` syntax does NOT work.
19-
* Some tests are known to be unstable. When running tests, you should skip the unstable ones by using `-- --filter-not-trait "FailsInCloudTest=true"`.
17+
- There should generally be one test project (under the `test` directory) per shipping project (under the `src` directory). Test projects are named after the project being tested with a `.Tests` suffix.
18+
- Analyzer tests that validate _no_ diagnostics are emitted should go in `test/Microsoft.VisualStudio.Composition.Analyzers.Tests/MultiAnalyzerTests.cs`, which runs all analyzers simultaneously. Tests for specific diagnostics being emitted go in the per-analyzer test files. Add any new analyzer to the list in `test/Microsoft.VisualStudio.Composition.Analyzers.Tests/Helpers/CSharpMultiAnalyzerVerifier+Test.cs`.
19+
- Tests use xunit v3 with Microsoft.Testing.Platform (MTP v2). Traditional VSTest `--filter` syntax does NOT work.
20+
- Some tests are known to be unstable. When running tests, you should skip the unstable ones by using `-- --filter-not-trait "FailsInCloudTest=true"`.
2021

2122
### Running Tests
2223

2324
**Run all tests**:
25+
2426
```bash
2527
dotnet test --no-build -c Release
2628
```
2729

2830
**Run tests for a specific test project**:
31+
2932
```bash
3033
dotnet test --project test/Library.Tests/Library.Tests.csproj --no-build -c Release
3134
```
3235

3336
**Run a single test method**:
37+
3438
```bash
3539
dotnet test --project test/Library.Tests/Library.Tests.csproj --no-build -c Release -- --filter-method ClassName.MethodName
3640
```
3741

3842
**Run all tests in a test class**:
43+
3944
```bash
4045
dotnet test --project test/Library.Tests/Library.Tests.csproj --no-build -c Release -- --filter-class ClassName
4146
```
4247

4348
**Run tests with wildcard matching** (supports wildcards at beginning and/or end):
49+
4450
```bash
4551
dotnet test --project test/Library.Tests/Library.Tests.csproj --no-build -c Release -- --filter-method "*Pattern*"
4652
```
4753

4854
**Run tests with a specific trait** (equivalent to category filtering):
55+
4956
```bash
5057
dotnet test --project test/Library.Tests/Library.Tests.csproj --no-build -c Release -- --filter-trait "TraitName=value"
5158
```
5259

5360
**Exclude tests with a specific trait** (skip unstable tests):
61+
5462
```bash
5563
dotnet test --project test/Library.Tests/Library.Tests.csproj --no-build -c Release -- --filter-not-trait "TestCategory=FailsInCloudTest"
5664
```
5765

5866
**Run tests for a specific framework only**:
67+
5968
```bash
6069
dotnet test --project test/Library.Tests/Library.Tests.csproj --no-build -c Release --framework net9.0
6170
```
6271

6372
**List all available tests without running them**:
73+
6474
```bash
6575
cd test/Library.Tests
6676
dotnet run --no-build -c Release --framework net9.0 -- --list-tests
6777
```
6878

6979
**Key points about test filtering with MTP v2 / xunit v3**:
80+
7081
- Options after `--` are passed to the test runner, not to `dotnet test`
7182
- Use `--filter-method`, `--filter-class`, `--filter-namespace` for simple filtering
7283
- Use `--filter-trait` and `--filter-not-trait` for trait-based filtering (replaces `--filter "TestCategory=..."`)
@@ -77,6 +88,6 @@ dotnet run --no-build -c Release --framework net9.0 -- --list-tests
7788

7889
## Coding style
7990

80-
* Honor StyleCop rules and fix any reported build warnings *after* getting tests to pass.
81-
* In C# files, use namespace *statements* instead of namespace *blocks* for all new files.
82-
* Add API doc comments to all new public and internal members.
91+
- Honor StyleCop rules and fix any reported build warnings _after_ getting tests to pass.
92+
- In C# files, use namespace _statements_ instead of namespace _blocks_ for all new files.
93+
- Add API doc comments to all new public and internal members.

test/Microsoft.VisualStudio.Composition.Analyzers.Tests/NoWarningTests.cs renamed to test/Microsoft.VisualStudio.Composition.Analyzers.Tests/MultiAnalyzerTests.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/// These tests verify that valid code does not trigger any analyzer diagnostics.
88
/// Each test verifies the source code against all VSMEF analyzers simultaneously.
99
/// </summary>
10-
public class NoWarningTests
10+
public class MultiAnalyzerTests
1111
{
1212
[Fact]
1313
public async Task ClassWithNoConstructors_NoWarning()
@@ -41,6 +41,22 @@ public Foo(string value) { }
4141
await VerifyAll.VerifyAnalyzerAsync(test);
4242
}
4343

44+
[Fact]
45+
public async Task ClassWithSingleDefaultConstructor_NoWarning()
46+
{
47+
string test = """
48+
using System.ComponentModel.Composition;
49+
50+
[Export]
51+
class Foo
52+
{
53+
public Foo() { }
54+
}
55+
""";
56+
57+
await VerifyAll.VerifyAnalyzerAsync(test);
58+
}
59+
4460
[Fact]
4561
public async Task ClassWithMultipleNonImportingConstructors_NoWarning()
4662
{

test/Microsoft.VisualStudio.Composition.Analyzers.Tests/VSMEF005MultipleImportingConstructorsAnalyzerTests.cs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,6 @@
55

66
public class VSMEF005MultipleImportingConstructorsAnalyzerTests
77
{
8-
[Fact]
9-
public async Task ClassWithSingleNonImportingConstructor_NoWarning()
10-
{
11-
string test = """
12-
using System.ComponentModel.Composition;
13-
14-
[Export]
15-
class Foo
16-
{
17-
public Foo(string value) { }
18-
}
19-
""";
20-
21-
await VerifyCS.VerifyAnalyzerAsync(test);
22-
}
23-
248
[Fact]
259
public async Task ClassWithMultipleImportingConstructors_Warning()
2610
{

0 commit comments

Comments
 (0)