-
Notifications
You must be signed in to change notification settings - Fork 0
Update dependencies and copilot instructions #140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,134 +1,26 @@ | ||
| # Workleap.Extensions.MediatR | ||
|
|
||
| Workleap.Extensions.MediatR is a .NET library that provides MediatR extensions, behaviors, and Roslyn analyzers for CQRS conventions. The library targets netstandard2.0 and net8.0 with additional ApplicationInsights integration. | ||
|
|
||
| Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here. | ||
|
|
||
| ## Working Effectively | ||
|
|
||
| - **Install Required .NET SDK**: Download and install .NET 9.0.304 exactly as specified in global.json: | ||
| - `wget https://dot.net/v1/dotnet-install.sh -O /tmp/dotnet-install.sh && chmod +x /tmp/dotnet-install.sh` | ||
| - `/tmp/dotnet-install.sh --version 9.0.304 --install-dir ~/.dotnet` | ||
| - `export PATH="$HOME/.dotnet:$PATH"` | ||
| - **Install .NET 8.0 Runtime** (required for running tests): | ||
| - `/tmp/dotnet-install.sh --version 8.0.8 --runtime dotnet --install-dir ~/.dotnet` | ||
| - **Build the project**: | ||
| - Navigate to `src/` directory: `cd src` | ||
| - First restore: `dotnet restore` -- takes 50 seconds initially, 2 seconds subsequently. NEVER CANCEL. Set timeout to 30+ minutes. | ||
| - Debug build: `dotnet build -c Debug` -- takes 9 seconds after restore. NEVER CANCEL. Set timeout to 30+ minutes. | ||
| - Release build may fail with GitVersion issues in non-CI environments. Use Debug build for development. | ||
| - **Run tests**: | ||
| - `dotnet test -c Debug --no-build --verbosity normal` -- takes ~8 seconds if already built, ~17 seconds if a build is required. NEVER CANCEL. Set timeout to 30+ minutes. | ||
| - All 86 tests should pass when environment is properly configured. | ||
| - **Alternative: Use PowerShell build script** (may fail with GitVersion in non-CI): | ||
| - `pwsh ./Build.ps1` -- runs clean, build, test, pack sequence | ||
|
|
||
| ## Validation | ||
|
|
||
| - **ALWAYS run through complete build and test cycle** after making changes to validate functionality. | ||
| - **ALWAYS run both main library tests and analyzer tests** to ensure Roslyn analyzers work correctly. | ||
| - **ALWAYS test MediatR extension functionality** by checking that the library properly registers with dependency injection. | ||
| - **NEVER make changes to PublicAPI.Shipped.txt** without understanding the breaking change implications. | ||
| - Add new public APIs to `PublicAPI.Unshipped.txt` files in the respective project directories. | ||
| - **Always check that all tests pass** - the test suite includes comprehensive validation of MediatR behaviors, analyzers, and integration scenarios. | ||
| - **Validation Scenarios**: After making changes, run these end-to-end validation steps: | ||
| 1. `cd src && dotnet clean && dotnet restore && dotnet build -c Debug` | ||
| 2. `dotnet test -c Debug --no-build --verbosity normal` | ||
| 3. Verify all 86 tests pass | ||
| 4. Check that no new analyzer warnings are introduced | ||
| 5. Ensure PublicAPI files are updated if needed | ||
|
|
||
| ## Common Tasks | ||
|
|
||
| The following are outputs from frequently run commands. Reference them instead of viewing, searching, or running bash commands to save time. | ||
|
|
||
| ### Repository Structure | ||
| ``` | ||
| . | ||
| ├── .github/ # GitHub workflows and templates | ||
| ├── src/ # All source code | ||
| │ ├── Workleap.Extensions.MediatR/ # Main library | ||
| │ ├── Workleap.Extensions.MediatR.ApplicationInsights/ # ApplicationInsights integration | ||
| │ ├── Workleap.Extensions.MediatR.Analyzers/ # Roslyn analyzers | ||
| │ ├── Workleap.Extensions.MediatR.Tests/ # Main library tests | ||
| │ ├── Workleap.Extensions.MediatR.Analyzers.Tests/ # Analyzer tests | ||
| │ └── Workleap.Extensions.MediatR.sln # Solution file | ||
| ├── Build.ps1 # Main build script | ||
| ├── README.md # Project documentation | ||
| ├── global.json # .NET SDK version requirement (9.0.304) | ||
| └── Directory.Build.props # Shared MSBuild properties | ||
| ``` | ||
|
|
||
| ### Key Project Components | ||
|
|
||
| 1. **Main Library** (`Workleap.Extensions.MediatR`): | ||
| - Multi-targets: netstandard2.0, net8.0 | ||
| - Provides MediatR extensions and behaviors | ||
| - Includes activity-based OpenTelemetry instrumentation | ||
| - High-performance logging with Debug level | ||
| - Data annotations support for request validation | ||
|
|
||
| 2. **ApplicationInsights Integration** (`Workleap.Extensions.MediatR.ApplicationInsights`): | ||
| - Separate NuGet package for Application Insights instrumentation | ||
| - Multi-targets: netstandard2.0, net8.0 | ||
|
|
||
| 3. **Roslyn Analyzers** (`Workleap.Extensions.MediatR.Analyzers`): | ||
| - Enforces CQRS naming conventions (GMDTR01-GMDTR13 rules) | ||
| - Embedded into main package during build | ||
| - Validates handler design patterns | ||
|
|
||
| ### Common Build Commands | ||
| ```bash | ||
| # First restore (one-time setup - takes ~50 seconds) | ||
| cd src && dotnet restore | ||
|
|
||
| # Subsequent restores (takes ~2 seconds) | ||
| cd src && dotnet restore | ||
|
|
||
| # Debug build (development recommended - takes ~9 seconds) | ||
| cd src && dotnet build -c Debug | ||
|
|
||
| # Run all tests (takes ~8 seconds if already built, ~17 seconds with build) | ||
| cd src && dotnet test -c Debug --no-build --verbosity normal | ||
|
|
||
| # Run tests with automatic build (if you want to skip separate build step) | ||
| cd src && dotnet test -c Debug --verbosity normal | ||
|
|
||
| # Clean and rebuild (for troubleshooting) | ||
| cd src && dotnet clean && dotnet build -c Debug | ||
|
|
||
| # Check .NET version | ||
| dotnet --version | ||
| ``` | ||
|
|
||
| ### PublicAPI Files | ||
| - `PublicAPI.Shipped.txt` - Contains all shipped public APIs (DO NOT MODIFY) | ||
| - `PublicAPI.Unshipped.txt` - Add new public APIs here before shipping | ||
|
|
||
| ### Analyzer Rules (GMDTR01-GMDTR13) | ||
| - GMDTR01-GMDTR06: Naming conventions for commands, queries, handlers, notifications | ||
| - GMDTR07-GMDTR13: Design patterns and best practices | ||
|
|
||
| ## Important Notes | ||
|
|
||
| - **Release builds require GitVersion** which only works in CI environments with proper git context | ||
| - **Use Debug builds for local development** to avoid GitVersion issues | ||
| - **PowerShell 7.4+ is available** for running Build.ps1 if needed | ||
| - **Assembly signing is enabled** with Workleap.Extensions.MediatR.snk | ||
| - **InternalsVisibleTo** is configured between projects for testing | ||
| - **CI/CD is fully automated** - preview packages on main branch commits, stable releases on tags | ||
|
|
||
| ## Project Dependencies | ||
|
|
||
| Key NuGet packages: | ||
| - MediatR 12.5.0 | ||
| - Microsoft.Extensions.Logging.Abstractions 8.0.0 | ||
| - Microsoft.CodeAnalysis.PublicApiAnalyzers 3.3.4 | ||
| - Workleap.DotNet.CodingStandards 1.1.3 (for style and analysis) | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| - **"GitVersion failed"**: Use Debug build configuration instead of Release | ||
| - **"Framework not found"**: Install .NET 8.0 runtime for test execution | ||
| - **"Assembly not found"**: Run `dotnet restore` in src/ directory first | ||
| - **Tests failing**: Ensure both .NET 9.0.304 SDK and 8.0.8 runtime are installed | ||
| **Any code you commit SHOULD compile, and new and existing tests related to the change SHOULD pass.** | ||
|
|
||
| You MUST make your best effort to ensure your changes satisfy those criteria before committing. If for any reason you were unable to build or test the changes, you MUST report that. You MUST NOT claim success unless all builds and tests pass as described above. | ||
|
|
||
| Do not complete without checking the relevant code builds and relevant tests still pass after the last edits you make. Do not simply assume that your changes fix test failures you see, actually build and run those tests again to confirm. | ||
| Also, do not assume that tests pass just because you did not see any failures in your last test run; verify that all relevant tests were actually run. | ||
|
|
||
| You MUST follow all code-formatting and naming conventions defined in [`.editorconfig`](/.editorconfig). | ||
|
|
||
| In addition to the rules enforced by `.editorconfig`, you SHOULD: | ||
|
|
||
| - Prefer file-scoped namespace declarations and single-line using directives. | ||
| - Ensure that the final return statement of a method is on its own line. | ||
| - Use pattern matching and switch expressions wherever possible. | ||
| - Use `nameof` instead of string literals when referring to member names. | ||
| - Always use `is null` or `is not null` instead of `== null` or `!= null`. | ||
| - Trust the C# null annotations and don't add null checks when the type system says a value cannot be null. | ||
| - Prefer `?.` if applicable (e.g. `scope?.Dispose()`). | ||
| - Use `ObjectDisposedException.ThrowIf` where applicable. | ||
| - When adding new unit tests, strongly prefer to add them to existing test code files rather than creating new code files. | ||
| - When running tests, if possible use filters and check test run counts, or look at test logs, to ensure they actually ran. | ||
| - Do not finish work with any tests commented out or disabled that were not previously commented out or disabled. | ||
| - Do not update `global.json` file | ||
| - When writing tests, do not emit "Act", "Arrange" or "Assert" comments. | ||
| - There should be no trailing whitespace in any lines. | ||
| - Add a blank line before XML documentation comments (`///`) when they follow other code (methods, properties, fields, etc.). | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # See https://docs.github.com/en/copilot/customizing-copilot/customizing-the-development-environment-for-copilot-coding-agent | ||
| name: "Copilot Setup Steps" | ||
| on: | ||
| workflow_dispatch: | ||
| push: | ||
| paths: | ||
| - .github/workflows/copilot-setup-steps.yml | ||
| pull_request: | ||
| paths: | ||
| - .github/workflows/copilot-setup-steps.yml | ||
|
|
||
|
|
||
| jobs: | ||
| # The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot. | ||
| copilot-setup-steps: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| - uses: actions/setup-dotnet@v5 | ||
| with: | ||
| global-json-file: './global.json' | ||
| dotnet-version: | | ||
| 8.0.x | ||
|
|
||
| - name: Restore solution | ||
| run: dotnet restore src/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.