diff --git a/.build/Solution.cs b/.build/Solution.cs index 83230b184..15cf58c19 100644 --- a/.build/Solution.cs +++ b/.build/Solution.cs @@ -1,10 +1,48 @@ using System.Collections.Generic; using System.Linq; using Nuke.Common.CI.GitHubActions; +using Nuke.Common.CI.GitHubActions.Configuration; using Rocket.Surgery.Nuke.ContinuousIntegration; using Rocket.Surgery.Nuke.DotNetCore; using Rocket.Surgery.Nuke.GithubActions; + +internal class LocalConstants +{ + public static string[] PathsIgnore = + { + ".codecov.yml", + ".editorconfig", + ".gitattributes", + ".gitignore", + ".gitmodules", + ".lintstagedrc.js", + ".prettierignore", + ".prettierrc", + "LICENSE", + "nukeeper.settings.json", + "omnisharp.json", + "package-lock.json", + "package.json", + "Readme.md", + ".github/dependabot.yml", + ".github/labels.yml", + ".github/release.yml", + ".github/renovate.json", + }; +} + +[GitHubActionsSteps( + "ci-ignore", + GitHubActionsImage.WindowsLatest, + GitHubActionsImage.UbuntuLatest, + AutoGenerate = false, + On = new[] { GitHubActionsTrigger.Push }, + OnPushTags = new[] { "v*" }, + OnPushBranches = new[] { "master", "main", "next" }, + OnPullRequestBranches = new[] { "master", "main", "next" }, + Enhancements = new[] { nameof(CiIgnoreMiddleware) } +)] [GitHubActionsSteps( "ci", GitHubActionsImage.MacOsLatest, @@ -27,7 +65,7 @@ nameof(Default) }, ExcludedTargets = new[] { nameof(ICanClean.Clean), nameof(ICanRestoreWithDotNetCore.DotnetToolRestore) }, - Enhancements = new[] { nameof(Middleware) } + Enhancements = new[] { nameof(CiMiddleware) } )] [PrintBuildVersion] [PrintCIEnvironment] @@ -35,8 +73,36 @@ [TitleEvents] public partial class Solution { - public static RocketSurgeonGitHubActionsConfiguration Middleware(RocketSurgeonGitHubActionsConfiguration configuration) + public static RocketSurgeonGitHubActionsConfiguration CiIgnoreMiddleware( + RocketSurgeonGitHubActionsConfiguration configuration + ) { + foreach (var item in configuration.DetailedTriggers.OfType()) + { + item.IncludePaths = LocalConstants.PathsIgnore; + } + + configuration.Jobs.RemoveAt(1); + ( (RocketSurgeonsGithubActionsJob)configuration.Jobs[0] ).Steps = new List + { + new RunStep("N/A") + { + Run = "echo \"No build required\"" + } + }; + + return configuration; + } + + public static RocketSurgeonGitHubActionsConfiguration CiMiddleware( + RocketSurgeonGitHubActionsConfiguration configuration + ) + { + foreach (var item in configuration.DetailedTriggers.OfType()) + { + item.ExcludePaths = LocalConstants.PathsIgnore; + } + var buildJob = configuration.Jobs.OfType().First(z => z.Name == "Build"); buildJob.FailFast = false; var checkoutStep = buildJob.Steps.OfType().Single(); @@ -44,7 +110,8 @@ public static RocketSurgeonGitHubActionsConfiguration Middleware(RocketSurgeonGi checkoutStep.FetchDepth = 0; buildJob.Environment["NUGET_PACKAGES"] = "${{ github.workspace }}/.nuget/packages"; buildJob.Steps.InsertRange( - buildJob.Steps.IndexOf(checkoutStep) + 1, new BaseGitHubActionsStep[] + buildJob.Steps.IndexOf(checkoutStep) + 1, + new BaseGitHubActionsStep[] { new RunStep("Fetch all history for all tags and branches") { @@ -58,7 +125,7 @@ public static RocketSurgeonGitHubActionsConfiguration Middleware(RocketSurgeonGi ["path"] = "${{ github.workspace }}/.nuget/packages", // keep in mind using central package versioning here ["key"] = - "${{ runner.os }}-nuget-${{ hashFiles('**/Directory.Build.targets', '**/Directory.Build.props', '**/*.csproj') }}", + "${{ runner.os }}-nuget-${{ hashFiles('**/Directory.Packages.props') }}-${{ hashFiles('**/Directory.Packages.support.props') }}", ["restore-keys"] = @"| ${{ runner.os }}-nuget-" } @@ -81,7 +148,6 @@ public static RocketSurgeonGitHubActionsConfiguration Middleware(RocketSurgeonGi With = new Dictionary { ["name"] = "actions-${{ matrix.os }}", - ["fail_ci_if_error"] = "true", } } ); @@ -122,6 +188,15 @@ public static RocketSurgeonGitHubActionsConfiguration Middleware(RocketSurgeonGi } ); + buildJob.Steps.Add( + new UploadArtifactStep("Publish Docs") + { + Name = "docs", + Path = "artifacts/docs/", + If = "always()" + } + ); + return configuration; } } diff --git a/.editorconfig b/.editorconfig index 737469427..bb7e8b5d2 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1009,12 +1009,6 @@ resharper_web_config_type_not_resolved_highlighting = warning resharper_web_config_wrong_module_highlighting = warning resharper_partial_type_with_single_part_highlighting = none -# .NET Analzyer settings -# VSTHRD200: Use "Async" suffix for awaitable methods -dotnet_diagnostic.VSTHRD200.severity = none -# CA2007: Do not directly await a Task -dotnet_diagnostic.CA2007.severity = error - ij_xml_align_attributes = true ij_xml_align_text = false ij_xml_attribute_wrap = normal diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index eba8bd573..000000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,28 +0,0 @@ -version: 2 -updates: - - package-ecosystem: 'github-actions' - directory: '/' - schedule: - interval: 'daily' - assignees: - - 'david-driscoll' - open-pull-requests-limit: 100 - - - package-ecosystem: 'npm' - directory: '/' - schedule: - interval: 'daily' - assignees: - - 'david-driscoll' - open-pull-requests-limit: 100 - - - package-ecosystem: 'nuget' - directory: '/' - schedule: - interval: 'daily' - assignees: - - 'david-driscoll' - ignore: - - dependency-name: Microsoft.Extensions.* - - dependency-name: Microsoft.AspNetCore.* - open-pull-requests-limit: 100 diff --git a/.github/label-commenter-dependabot.yml b/.github/label-commenter-dependabot.yml deleted file mode 100644 index 0e71df27b..000000000 --- a/.github/label-commenter-dependabot.yml +++ /dev/null @@ -1,5 +0,0 @@ -labels: - - name: 'merge' - labeled: - pr: - body: '@dependabot squash and merge' diff --git a/.github/labels.yml b/.github/labels.yml index a94e5d5d9..bee0d5482 100644 --- a/.github/labels.yml +++ b/.github/labels.yml @@ -1,54 +1,66 @@ -- name: "bug" - color: "d73a4a" +- name: 'bug' + color: 'd73a4a' description: "Something isn't working" -- name: "documentation" +- name: 'documentation' color: 0075ca - description: "Improvements or additions to documentation" -- name: "duplicate" - color: "cfd3d7" - description: "This issue or pull request already exists" -- name: "enhancement" - color: "a2eeef" - description: "New feature or request" -- name: "help wanted" - color: "008672" - description: "Extra attention is needed" -- name: "good first issue" - color: "7057ff" - description: "Good for newcomers" -- name: "invalid" - color: "e4e669" + description: 'Improvements or additions to documentation' +- name: 'duplicate' + color: 'cfd3d7' + description: 'This issue or pull request already exists' +- name: 'enhancement' + color: 'a2eeef' + description: 'New feature or request' +- name: 'help wanted' + color: '008672' + description: 'Extra attention is needed' +- name: 'good first issue' + color: '7057ff' + description: 'Good for newcomers' +- name: 'invalid' + color: 'e4e669' description: "This doesn't seem right" -- name: "question" - color: "d876e3" - description: "Further information is requested" -- name: "wontfix" - color: "ffffff" - description: "This will not be worked on" -- name: "feature" - color: "ccf5ff" - description: "This adds some form of new functionality" -- name: "breaking change" - color: "efa7ae" - description: "This breaks existing behavior" -- name: "mysterious" - color: "cccccc" - description: "We forgot to label this" -- name: "chore" - color: "27127c" - description: "Just keeping things neat and tidy" -- name: "dependencies" - color: "edc397" - description: "Pull requests that update a dependency file" -- name: "merge" - color: "98ed98" - description: "Shipit!" -- name: "deprecated" - color: "dd824d" - description: "Deprecated functionality" -- name: "removed" - color: "fce99f" - description: "Removed functionality" -- name: "security" - color: "cbce1e" - description: "Security related issue" +- name: 'question' + color: 'd876e3' + description: 'Further information is requested' +- name: 'wontfix' + color: 'ffffff' + description: 'This will not be worked on' +- name: 'feature' + color: 'ccf5ff' + description: 'This adds some form of new functionality' +- name: 'breaking change' + color: 'efa7ae' + description: 'This breaks existing behavior' +- name: 'mysterious' + color: 'cccccc' + description: 'We forgot to label this' +- name: 'chore' + color: '27127c' + description: 'Just keeping things neat and tidy' +- name: 'dependencies' + color: 'edc397' + description: 'Pull requests that update a dependency file' +- name: 'merge' + color: '98ed98' + description: 'Shipit!' +- name: 'deprecated' + color: 'dd824d' + description: 'Deprecated functionality' +- name: 'removed' + color: 'fce99f' + description: 'Removed functionality' +- name: 'security' + color: 'cbce1e' + description: 'Security related issue' +- name: 'private-dependencies' + color: 'edc397' + description: 'Private dependency' +- name: 'rebase' + color: 'ffcc66' + description: 'Rebase branch' +- name: 'stop updating' + color: '800000' + description: 'Stop Updating' +- name: 'blocked' + color: 'FF5600' + description: 'Issue is blocked waiting for something or someone' diff --git a/.github/renovate.json b/.github/renovate.json new file mode 100644 index 000000000..1769b4f1d --- /dev/null +++ b/.github/renovate.json @@ -0,0 +1,196 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "config:base", + ":automergePatch", + ":separateMajorReleases", + ":combinePatchMinorReleases", + ":enableVulnerabilityAlertsWithLabel(:old_key: security)", + ":dependencyDashboard" + ], + "prHourlyLimit": 10, + "prConcurrentLimit": 0, + "hostRules": [ + { + "concurrentRequestLimit": 999 + } + ], + "platformAutomerge": true, + "automergeType": "pr", + "automergeStrategy": "rebase", + "rebaseWhen": "auto", + "labels": [":package: dependencies"], + "rebaseLabel": ":trident: rebase", + "stopUpdatingLabel": ":vertical_traffic_light: stop updating", + "github-actions": { + "fileMatch": ["(^workflow-templates|\\.github\\/workflows)\\/[^/]+\\.ya?ml$", "(^|\\/)action\\.ya?ml$"], + "automerge": true, + "groupName": "github actions", + "labels": [":truck: private-dependencies"] + }, + "packageRules": [ + { + "matchManagers": ["nuget"], + "groupName": "build dependencies", + "matchPackagePatterns": ["^Nuke.Common", "^Microsoft\\.NET\\.Test\\.Sdk$", "^Rocket\\.Surgery\\.MSBuild$", "^Rocket\\.Surgery\\.Nuke$"], + "labels": [":truck: private-dependencies"], + "automerge": true + }, + { + "matchPackagePatterns": ["^Roslynator"], + "groupName": "roslynator", + "labels": [":truck: private-dependencies"], + "automerge": true + }, + { + "matchPackagePatterns": ["^FluentAssertions"], + "groupName": "fluentassertions", + "labels": [":truck: private-dependencies"], + "automerge": true + }, + { + "matchPackagePatterns": ["^NSubstitute"], + "groupName": "nsubstitute", + "labels": [":truck: private-dependencies"], + "automerge": true + }, + { + "matchPackagePatterns": ["^Moq"], + "groupName": "moq", + "labels": [":truck: private-dependencies"], + "automerge": true + }, + { + "matchPackagePatterns": ["^FakeItEasy"], + "groupName": "fakeiteasy", + "labels": [":truck: private-dependencies"], + "automerge": true + }, + { + "matchPackagePatterns": ["^coverlet"], + "groupName": "coverlet", + "labels": [":truck: private-dependencies"], + "automerge": true + }, + { + "matchPackagePatterns": ["^Bogus"], + "groupName": "bogus", + "labels": [":truck: private-dependencies"], + "automerge": true + }, + { + "matchPackagePatterns": ["^ReportGenerator", "^reportgenerator", "^dotnet-reportgenerator"], + "groupName": "reportgenerator", + "labels": [":truck: private-dependencies"], + "automerge": true + }, + { + "matchPackagePatterns": ["^JetBrains", "^jetbrains"], + "groupName": "jetbrains", + "labels": [":truck: private-dependencies"], + "automerge": true + }, + { + "matchPackagePatterns": ["^GitVersion", "^gitversion"], + "groupName": "gitversion", + "labels": [":truck: private-dependencies"], + "automerge": true + }, + { + "matchPackagePatterns": ["^xunit"], + "groupName": "xunit", + "labels": [":truck: private-dependencies"], + "automerge": true + }, + { + "matchPackagePatterns": ["^bunit"], + "groupName": "bunit", + "labels": [":truck: private-dependencies"], + "automerge": true + }, + { + "matchPackagePatterns": ["^FluentValidation"], + "groupName": "fluentvalidation", + "labels": [":package: dependencies"], + "automerge": false + }, + { + "matchPackagePatterns": ["^NodaTime"], + "groupName": "nodatime", + "labels": [":package: dependencies"], + "automerge": false + }, + { + "matchPackagePatterns": ["^DryIoc"], + "groupName": "dryioc", + "labels": [":package: dependencies"], + "automerge": false + }, + { + "matchPackagePatterns": ["^FluentAssertions"], + "groupName": "fluentassertions", + "labels": [":truck: private-dependencies"], + "automerge": true + }, + { + "matchPackagePatterns": ["^Verify"], + "groupName": "verify", + "labels": [":truck: private-dependencies"], + "automerge": true + }, + { + "matchManagers": ["nuget"], + "matchPackagePatterns": ["^System\\.Collections\\.Immutable", "^System\\.Interactive", "^System\\.Reactive", "^Humanizer"], + "labels": [":package: dependencies"], + "automerge": true + }, + { + "matchSourceUrlPrefixes": ["https://github.com/RocketSurgeonsGuild"], + "labels": [":package: dependencies"], + "groupName": "Rocket Surgery Other" + }, + { + "matchSourceUrlPrefixes": ["https://github.com/RocketSurgeonsGuild/Conventions"], + "labels": [":package: dependencies"], + "groupName": "Rocket Surgery Conventions" + }, + { + "matchSourceUrlPrefixes": ["https://github.com/RocketSurgeonsGuild/Testing"], + "labels": [":truck: private-dependencies"], + "groupName": "Rocket Surgery Testing" + }, + { + "matchSourceUrlPrefixes": ["https://github.com/RocketSurgeonsGuild/Extensions"], + "labels": [":package: dependencies"], + "groupName": "Rocket Surgery Extensions" + }, + { + "description": "dotnet monorepo", + "groupName": "dotnet monorepo", + "enabled": false, + "matchSourceUrlPrefixes": [ + "https://github.com/dotnet/aspnetcore", + "https://github.com/dotnet/efcore", + "https://github.com/dotnet/extensions", + "https://github.com/dotnet/runtime" + ] + }, + { + "description": "dotnet monorepo [minor/patch]", + "groupName": "dotnet monorepo [minor/patch]", + "enabled": true, + "matchUpdateTypes": ["minor", "patch"], + "matchSourceUrlPrefixes": [ + "https://github.com/dotnet/aspnetcore", + "https://github.com/dotnet/efcore", + "https://github.com/dotnet/extensions", + "https://github.com/dotnet/runtime" + ] + }, + { + "description": "dotnet msbuild", + "groupName": "dotnet msbuild", + "matchSourceUrlPrefixes": ["https://github.com/dotnet/msbuild"] + } + ] +} diff --git a/.github/workflows/ci-ignore.yml b/.github/workflows/ci-ignore.yml new file mode 100644 index 000000000..a5c03cbb6 --- /dev/null +++ b/.github/workflows/ci-ignore.yml @@ -0,0 +1,80 @@ +# ------------------------------------------------------------------------------ +# +# +# This code was generated. +# +# - To turn off auto-generation set: +# +# [GitHubActionsSteps (AutoGenerate = false)] +# +# - To trigger manual generation invoke: +# +# nuke --generate-configuration GitHubActions_ci-ignore --host GitHubActions +# +# +# ------------------------------------------------------------------------------ + +name: ci-ignore + +on: + push: + branches: + - 'master' + - 'main' + - 'next' + tags: + - 'v*' + paths: + - '.codecov.yml' + - '.editorconfig' + - '.gitattributes' + - '.gitignore' + - '.gitmodules' + - '.lintstagedrc.js' + - '.prettierignore' + - '.prettierrc' + - 'LICENSE' + - 'nukeeper.settings.json' + - 'omnisharp.json' + - 'package-lock.json' + - 'package.json' + - 'Readme.md' + - '.github/dependabot.yml' + - '.github/labels.yml' + - '.github/release.yml' + - '.github/renovate.json' + pull_request: + branches: + - 'master' + - 'main' + - 'next' + paths: + - '.codecov.yml' + - '.editorconfig' + - '.gitattributes' + - '.gitignore' + - '.gitmodules' + - '.lintstagedrc.js' + - '.prettierignore' + - '.prettierrc' + - 'LICENSE' + - 'nukeeper.settings.json' + - 'omnisharp.json' + - 'package-lock.json' + - 'package.json' + - 'Readme.md' + - '.github/dependabot.yml' + - '.github/labels.yml' + - '.github/release.yml' + - '.github/renovate.json' + +jobs: + Build: + strategy: + matrix: + os: [windows-latest, ubuntu-latest] + runs-on: ${{ matrix.os }} + steps: + - name: N/A + run: | + echo "No build required" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dc540b305..cb85f7c67 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,11 +24,49 @@ on: - 'next' tags: - 'v*' + paths-ignore: + - '.codecov.yml' + - '.editorconfig' + - '.gitattributes' + - '.gitignore' + - '.gitmodules' + - '.lintstagedrc.js' + - '.prettierignore' + - '.prettierrc' + - 'LICENSE' + - 'nukeeper.settings.json' + - 'omnisharp.json' + - 'package-lock.json' + - 'package.json' + - 'Readme.md' + - '.github/dependabot.yml' + - '.github/labels.yml' + - '.github/release.yml' + - '.github/renovate.json' pull_request: branches: - 'master' - 'main' - 'next' + paths-ignore: + - '.codecov.yml' + - '.editorconfig' + - '.gitattributes' + - '.gitignore' + - '.gitmodules' + - '.lintstagedrc.js' + - '.prettierignore' + - '.prettierrc' + - 'LICENSE' + - 'nukeeper.settings.json' + - 'omnisharp.json' + - 'package-lock.json' + - 'package.json' + - 'Readme.md' + - '.github/dependabot.yml' + - '.github/labels.yml' + - '.github/release.yml' + - '.github/renovate.json' jobs: Build: @@ -52,7 +90,7 @@ jobs: uses: actions/cache@v2 with: path: '${{ github.workspace }}/.nuget/packages' - key: "${{ runner.os }}-nuget-${{ hashFiles('**/Directory.Build.targets', '**/Directory.Build.props', '**/*.csproj') }}" + key: "${{ runner.os }}-nuget-${{ hashFiles('**/Directory.Packages.props') }}-${{ hashFiles('**/Directory.Packages.support.props') }}" restore-keys: | ${{ runner.os }}-nuget- - name: 🔨 Use .NET Core 3.1 SDK @@ -82,7 +120,6 @@ jobs: uses: codecov/codecov-action@v1 with: name: 'actions-${{ matrix.os }}' - fail_ci_if_error: 'true' - name: 🏺 Publish logs if: always() uses: actions/upload-artifact@v2 @@ -107,6 +144,12 @@ jobs: with: name: 'nuget' path: 'artifacts/nuget/' + - name: 🏺 Publish Docs + if: always() + uses: actions/upload-artifact@v2 + with: + name: 'docs' + path: 'artifacts/docs/' Publish: needs: - Build diff --git a/.github/workflows/close-milestone.yml b/.github/workflows/close-milestone.yml index d0e2bc2c9..87f19af23 100644 --- a/.github/workflows/close-milestone.yml +++ b/.github/workflows/close-milestone.yml @@ -1,30 +1,32 @@ name: Close Milestone + on: release: types: - released + jobs: close_milestone: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2.4.0 + uses: actions/checkout@v3.0.1 with: fetch-depth: 0 - name: Install GitVersion - uses: gittools/actions/gitversion/setup@v0.9.11 + uses: gittools/actions/gitversion/setup@v0.9.13 with: versionSpec: '5.x' - name: Install GitReleaseManager - uses: gittools/actions/gitreleasemanager/setup@v0.9.11 + uses: gittools/actions/gitreleasemanager/setup@v0.9.13 with: versionSpec: '0.11.x' - name: Use GitVersion id: gitversion - uses: gittools/actions/gitversion/execute@v0.9.11 + uses: gittools/actions/gitversion/execute@v0.9.13 # Ensure the milestone exists - name: Create Milestone @@ -37,7 +39,7 @@ jobs: # move any issues to that milestone in the event the release is renamed - name: sync milestones - uses: RocketSurgeonsGuild/actions/sync-milestone@v0.2.4 + uses: RocketSurgeonsGuild/actions/sync-milestone@v0.3.0 with: default-label: 'mysterious' github-token: ${{ secrets.OMNISHARP_BOT_TOKEN }} diff --git a/.github/workflows/dependabot-merge.yml b/.github/workflows/dependabot-merge.yml index 25aeaa680..5da81288a 100644 --- a/.github/workflows/dependabot-merge.yml +++ b/.github/workflows/dependabot-merge.yml @@ -4,34 +4,80 @@ on: pull_request_target: types: - labeled + - opened + - reopened + - closed + - synchronize jobs: comment: - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest + if: | + (github.event.action == 'labeled' || github.event.action == 'opened' || github.event.action == 'reopened') steps: - name: Dump GitHub context env: GITHUB_CONTEXT: ${{ toJson(github) }} run: echo "$GITHUB_CONTEXT" + - name: Dump job context env: JOB_CONTEXT: ${{ toJson(job) }} run: echo "$JOB_CONTEXT" + - name: Dump steps context env: STEPS_CONTEXT: ${{ toJson(steps) }} run: echo "$STEPS_CONTEXT" + - name: Dump runner context env: RUNNER_CONTEXT: ${{ toJson(runner) }} run: echo "$RUNNER_CONTEXT" - - uses: actions/checkout@v2.4.0 + + - name: GitHub Automerge + if: | + contains(github.event.pull_request.labels.*.name, ':shipit: merge') + || contains(github.event.pull_request.labels.*.name, 'javascript') + || contains(github.event.pull_request.labels.*.name, 'github-actions') + uses: alexwilson/enable-github-automerge-action@1.0.0 + continue-on-error: true with: - ref: master - - name: Dependabot Commenter + github-token: '${{ secrets.OMNISHARP_BOT_TOKEN }}' + merge-method: 'SQUASH' + + labeler: + runs-on: ubuntu-latest + if: | + (github.event.action == 'closed' || github.event.action == 'opened' || github.event.action == 'reopened') + steps: + - name: Dump GitHub context + env: + GITHUB_CONTEXT: ${{ toJson(github) }} + run: echo "$GITHUB_CONTEXT" + + - name: Dump job context + env: + JOB_CONTEXT: ${{ toJson(job) }} + run: echo "$JOB_CONTEXT" + + - name: Dump steps context + env: + STEPS_CONTEXT: ${{ toJson(steps) }} + run: echo "$STEPS_CONTEXT" + + - name: Dump runner context + env: + RUNNER_CONTEXT: ${{ toJson(runner) }} + run: echo "$RUNNER_CONTEXT" + + - name: GitHub Remove Labels if: | - (github.event.label.name == 'merge') && (github.event.pull_request.user.login == 'dependabot[bot]' || github.event.pull_request.user.login == 'dependabot-preview[bot]') - uses: peaceiris/actions-label-commenter@v1.10.0 + github.event.action == 'closed' + uses: actions-ecosystem/action-remove-labels@v1 with: - github_token: ${{ secrets.OMNISHARP_BOT_TOKEN }} - config_file: .github/label-commenter-dependabot.yml + labels: | + :shipit: merge + github-actions + javascript + .NET diff --git a/.github/workflows/draft-release.yml b/.github/workflows/draft-release.yml index c8ebd826a..4b97fa167 100644 --- a/.github/workflows/draft-release.yml +++ b/.github/workflows/draft-release.yml @@ -1,16 +1,20 @@ name: Create Milestone and Draft Release + on: push: branches: - master paths-ignore: - '**/*.md' + schedule: + - cron: '0 0 * * 4' + jobs: create_milestone_and_draft_release: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2.4.0 + uses: actions/checkout@v3.0.1 with: fetch-depth: 0 @@ -18,18 +22,13 @@ jobs: run: git fetch --prune - name: Install GitVersion - uses: gittools/actions/gitversion/setup@v0.9.11 + uses: gittools/actions/gitversion/setup@v0.9.13 with: versionSpec: '5.x' - - name: Install GitReleaseManager - uses: gittools/actions/gitreleasemanager/setup@v0.9.11 - with: - versionSpec: '0.12.x' - - name: Use GitVersion id: gitversion - uses: gittools/actions/gitversion/execute@v0.9.11 + uses: gittools/actions/gitversion/execute@v0.9.13 - name: Create Milestone uses: WyriHaximus/github-action-create-milestone@v1 @@ -39,34 +38,19 @@ jobs: GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' continue-on-error: true - - name: Get Repo and Owner - shell: pwsh - id: repository - run: | - $parts = $ENV:GITHUB_REPOSITORY.Split('/') - echo "::set-output name=owner::$($parts[0])" - echo "::set-output name=repository::$($parts[1])" - - name: sync milestones - uses: RocketSurgeonsGuild/actions/sync-milestone@v0.2.4 + uses: RocketSurgeonsGuild/actions/sync-milestone@v0.3.0 with: default-label: 'mysterious' github-token: ${{ secrets.GITHUB_TOKEN }} - - name: Create Draft Release - shell: pwsh - run: | - dotnet gitreleasemanager create ` - -o "${{ steps.repository.outputs.owner }}" ` - -r "${{ steps.repository.outputs.repository }}" ` - --token "${{ secrets.OMNISHARP_BOT_TOKEN }}" ` - -m "v${{ steps.gitversion.outputs.majorMinorPatch }}" - - - name: Export Changelog - shell: pwsh - run: | - dotnet gitreleasemanager export ` - -o "${{ steps.repository.outputs.owner }}" ` - -r "${{ steps.repository.outputs.repository }}" ` - --token "${{ secrets.GITHUB_TOKEN }}" ` - -f CHANGELOG.md + - uses: ncipollo/release-action@v1 + with: + allowUpdates: true + generateReleaseNotes: true + draft: true + omitNameDuringUpdate: true + name: 'v${{ steps.gitversion.outputs.majorMinorPatch }}' + tag: 'v${{ steps.gitversion.outputs.majorMinorPatch }}' + token: ${{ secrets.OMNISHARP_BOT_TOKEN }} + commit: ${{ github.base_ref }} diff --git a/.github/workflows/publish-nuget.yml b/.github/workflows/publish-nuget.yml new file mode 100644 index 000000000..586ed7dd5 --- /dev/null +++ b/.github/workflows/publish-nuget.yml @@ -0,0 +1,38 @@ +name: Publish Nuget Packages + +on: + workflow_call: + # inputs: + secrets: + RSG_NUGET_API_KEY: + required: true + RSG_AZURE_DEVOPS: + required: false + +jobs: + publish: + runs-on: ubuntu-latest + + steps: + - name: Dump GitHub context + env: + GITHUB_CONTEXT: ${{ toJson(github) }} + run: echo "$GITHUB_CONTEXT" + + - uses: nuget/setup-nuget@v1 + with: + nuget-version: '5.x' + + - uses: actions/download-artifact@v3 + with: + name: nuget + + - name: nuget.org + # continue-on-error: true + if: startsWith(github.ref, 'refs/tags/') # this is the best approximation for a tag + env: + ApiKey: ${{ secrets.RSG_NUGET_API_KEY }} + shell: pwsh + run: | + dotnet nuget push **/*.nupkg --skip-duplicate -s nuget.org --api-key $ENV:ApiKey + dotnet nuget push **/*.snupkg --skip-duplicate -s nuget.org --api-key $ENV:ApiKey diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml index 77fcaefb3..bc3c7ae8c 100644 --- a/.github/workflows/sync-labels.yml +++ b/.github/workflows/sync-labels.yml @@ -1,5 +1,7 @@ name: Sync Labels + on: + workflow_call: push: branches: - master @@ -14,14 +16,13 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2.4.0 + uses: actions/checkout@v3.0.1 - name: Run Labeler if: success() uses: crazy-max/ghaction-github-labeler@v3.1.1 with: - yaml_file: .github/labels.yml - skip_delete: false - dry_run: false - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + yaml-file: .github/labels.yml + skip-delete: false + dry-run: false + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/update-milestone.yml b/.github/workflows/update-milestone.yml index 7ba09e71f..49d50ba3e 100644 --- a/.github/workflows/update-milestone.yml +++ b/.github/workflows/update-milestone.yml @@ -1,4 +1,5 @@ name: Update Milestone + on: pull_request_target: types: @@ -12,10 +13,42 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2.4.0 + uses: actions/checkout@v3.0.1 + with: + ref: ${{ github.sha }} + fetch-depth: 0 + + - name: Fetch all history for all tags and branches + run: git fetch --prune + + - name: Install GitVersion + if: ${{ github.event.action == 'opened' }} + uses: gittools/actions/gitversion/setup@v0.9.13 + with: + versionSpec: '5.x' + + - name: Install GitReleaseManager + if: ${{ github.event.action == 'opened' }} + uses: gittools/actions/gitreleasemanager/setup@v0.9.13 + with: + versionSpec: '0.11.x' + + - name: Use GitVersion + if: ${{ github.event.action == 'opened' }} + id: gitversion + uses: gittools/actions/gitversion/execute@v0.9.13 + + - name: Create Milestone + if: ${{ github.event.action == 'opened' }} + uses: WyriHaximus/github-action-create-milestone@v1 + with: + title: v${{ steps.gitversion.outputs.majorMinorPatch }} + env: + GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' + continue-on-error: true - name: sync milestones - uses: RocketSurgeonsGuild/actions/sync-milestone@v0.2.4 + uses: RocketSurgeonsGuild/actions/sync-milestone@v0.3.0 with: default-label: 'mysterious' github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.husky/pre-commit b/.husky/pre-commit index d0879ca8c..3f6421029 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -3,5 +3,7 @@ npx lint-staged -d -r dotnet nuke --generate-configuration GitHubActions_ci --host GitHubActions +dotnet nuke --generate-configuration GitHubActions_ci-ignore --host GitHubActions git add .github/workflows/ci.yml +git add .github/workflows/ci-ignore.yml git add .nuke/build.schema.json diff --git a/Directory.Build.props b/Directory.Build.props index 0eaf54839..c824ab2bf 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -14,14 +14,21 @@ lsp;language server;language server protocol;language client;language server client $(MSBuildThisFileDirectory)\lsp.snk + AllEnabledByDefault + preview + true true + 1 + true + enable true true snupkg true - $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb + $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb $(AllowedReferenceRelatedFileExtensions);.pdb @@ -29,11 +36,11 @@ diff --git a/Directory.Build.targets b/Directory.Build.targets index 6078ba62b..4cc7c05d3 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -4,48 +4,9 @@ $(BaseIntermediateOutputPath)\GeneratedFiles - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + diff --git a/Directory.Packages.props b/Directory.Packages.props new file mode 100644 index 000000000..36683010e --- /dev/null +++ b/Directory.Packages.props @@ -0,0 +1,63 @@ + + + + $(BaseIntermediateOutputPath)\GeneratedFiles + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Directory.Packages.supports.props b/Directory.Packages.supports.props new file mode 100644 index 000000000..665086a69 --- /dev/null +++ b/Directory.Packages.supports.props @@ -0,0 +1,15 @@ + + + + + + + + + + + + + diff --git a/LSP.sln b/LSP.sln index 7ca6d6531..68d6c34bf 100644 --- a/LSP.sln +++ b/LSP.sln @@ -12,6 +12,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{2F323ED5-E ProjectSection(SolutionItems) = preProject test\Directory.Build.props = test\Directory.Build.props test\Directory.Build.targets = test\Directory.Build.targets + test\.editorconfig = test\.editorconfig EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".config", ".config", "{AE4D7807-6F78-428C-A0D9-914BA583A104}" @@ -25,6 +26,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".config", ".config", "{AE4D Directory.Build.props = Directory.Build.props nuget.config = nuget.config Directory.Build.targets = Directory.Build.targets + Directory.Packages.props = Directory.Packages.props EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JsonRpc", "src\JsonRpc\JsonRpc.csproj", "{9AF43FA2-EF35-435E-B59E-724877E44DDA}" diff --git a/benchmarks/Pipeline/Pipeline.csproj b/benchmarks/Pipeline/Pipeline.csproj index 17f69cce5..c20468ddb 100644 --- a/benchmarks/Pipeline/Pipeline.csproj +++ b/benchmarks/Pipeline/Pipeline.csproj @@ -1,7 +1,7 @@ - net472;netcoreapp3.1 + net472;netcoreapp3.1;net6.0 Exe false diff --git a/sample/SampleServer/SampleServer.csproj b/sample/SampleServer/SampleServer.csproj index 482852f5b..f793325cd 100644 --- a/sample/SampleServer/SampleServer.csproj +++ b/sample/SampleServer/SampleServer.csproj @@ -10,17 +10,17 @@ - - - - - - - - - - - + + + + + + + + + + + diff --git a/sample/SampleServer/TextDocumentHandler.cs b/sample/SampleServer/TextDocumentHandler.cs index 701b67278..f3b6f9c2f 100644 --- a/sample/SampleServer/TextDocumentHandler.cs +++ b/sample/SampleServer/TextDocumentHandler.cs @@ -13,6 +13,8 @@ using OmniSharp.Extensions.LanguageServer.Protocol.Server.Capabilities; using OmniSharp.Extensions.LanguageServer.Protocol.Server.WorkDone; using OmniSharp.Extensions.LanguageServer.Protocol.Workspace; +using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range; + #pragma warning disable CS0618 diff --git a/src/.editorconfig b/src/.editorconfig new file mode 100644 index 000000000..dc318009a --- /dev/null +++ b/src/.editorconfig @@ -0,0 +1,2 @@ +[*] +dotnet_diagnostic.CA1014.severity = none diff --git a/src/Client/Client.csproj b/src/Client/Client.csproj index 14bd92c9e..ebf3ae955 100644 --- a/src/Client/Client.csproj +++ b/src/Client/Client.csproj @@ -1,7 +1,7 @@  - netstandard2.1;netstandard2.0 + netstandard2.1;netstandard2.0;net6.0 AnyCPU OmniSharp.Extensions.LanguageClient OmniSharp.Extensions.LanguageServer.Client @@ -9,14 +9,15 @@ - - - - + + + + - <_Parameter1>OmniSharp.Extensions.LanguageProtocol.Testing, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f + <_Parameter1 + >OmniSharp.Extensions.LanguageProtocol.Testing, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f diff --git a/src/Dap.Client/Dap.Client.csproj b/src/Dap.Client/Dap.Client.csproj index 1fe996a04..8997ffd64 100644 --- a/src/Dap.Client/Dap.Client.csproj +++ b/src/Dap.Client/Dap.Client.csproj @@ -1,7 +1,7 @@  - netstandard2.1;netstandard2.0 + netstandard2.1;netstandard2.0;net6.0 AnyCPU OmniSharp.Extensions.DebugAdapter.Client OmniSharp.Extensions.DebugAdapter.Client @@ -9,11 +9,12 @@ - + - <_Parameter1>OmniSharp.Extensions.DebugAdapter.Testing, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f + <_Parameter1 + >OmniSharp.Extensions.DebugAdapter.Testing, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f diff --git a/src/Dap.Protocol.Proposals/Dap.Protocol.Proposals.csproj b/src/Dap.Protocol.Proposals/Dap.Protocol.Proposals.csproj index 77f12517f..e03805d19 100644 --- a/src/Dap.Protocol.Proposals/Dap.Protocol.Proposals.csproj +++ b/src/Dap.Protocol.Proposals/Dap.Protocol.Proposals.csproj @@ -1,18 +1,19 @@  - netstandard2.1;netstandard2.0 + netstandard2.1;netstandard2.0;net6.0 AnyCPU OmniSharp.Extensions.DebugAdapter.Proposals OmniSharp.Extensions.DebugAdapter.Protocol - Proposed Debug Adapter Protocol models, classes, interfaces and helper methods, that may or may not make it into the final spec + Proposed Debug Adapter Protocol models, classes, interfaces and helper methods, that may or may not make it into the final spec - + - + diff --git a/src/Dap.Protocol/Dap.Protocol.csproj b/src/Dap.Protocol/Dap.Protocol.csproj index 45920e504..4622960c4 100644 --- a/src/Dap.Protocol/Dap.Protocol.csproj +++ b/src/Dap.Protocol/Dap.Protocol.csproj @@ -1,7 +1,7 @@  - netstandard2.1;netstandard2.0 + netstandard2.1;netstandard2.0;net6.0 AnyCPU OmniSharp.Extensions.DebugAdapter OmniSharp.Extensions.DebugAdapter.Protocol @@ -9,29 +9,40 @@ - + - - + + - <_Parameter1>OmniSharp.Extensions.DebugAdapter.Testing, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f + <_Parameter1 + >OmniSharp.Extensions.DebugAdapter.Testing, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f - <_Parameter1>OmniSharp.Extensions.DebugAdapter.Server, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f + <_Parameter1 + >OmniSharp.Extensions.DebugAdapter.Server, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f - <_Parameter1>OmniSharp.Extensions.DebugAdapter.Client, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f + <_Parameter1 + >OmniSharp.Extensions.DebugAdapter.Client, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f - <_Parameter1>OmniSharp.Extensions.DebugAdapter.Shared, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f + <_Parameter1 + >OmniSharp.Extensions.DebugAdapter.Shared, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f - <_Parameter1>OmniSharp.Extensions.DebugAdapter.Proposals, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f + <_Parameter1 + >OmniSharp.Extensions.DebugAdapter.Proposals, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f diff --git a/src/Dap.Protocol/Feature/Requests/ThreadsFeature.cs b/src/Dap.Protocol/Feature/Requests/ThreadsFeature.cs index 498ccf17b..9d5e6cb04 100644 --- a/src/Dap.Protocol/Feature/Requests/ThreadsFeature.cs +++ b/src/Dap.Protocol/Feature/Requests/ThreadsFeature.cs @@ -2,6 +2,7 @@ using OmniSharp.Extensions.DebugAdapter.Protocol.Models; using OmniSharp.Extensions.JsonRpc; using OmniSharp.Extensions.JsonRpc.Generation; +using Thread = OmniSharp.Extensions.DebugAdapter.Protocol.Models.Thread; // ReSharper disable once CheckNamespace namespace OmniSharp.Extensions.DebugAdapter.Protocol diff --git a/src/Dap.Server/Dap.Server.csproj b/src/Dap.Server/Dap.Server.csproj index e6847acd4..c3d82e895 100644 --- a/src/Dap.Server/Dap.Server.csproj +++ b/src/Dap.Server/Dap.Server.csproj @@ -1,7 +1,7 @@ - netstandard2.1;netstandard2.0 + netstandard2.1;netstandard2.0;net6.0 AnyCPU OmniSharp.Extensions.DebugAdapter.Server OmniSharp.Extensions.DebugAdapter.Server @@ -9,11 +9,12 @@ - + - <_Parameter1>OmniSharp.Extensions.DebugAdapter.Testing, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f + <_Parameter1 + >OmniSharp.Extensions.DebugAdapter.Testing, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f diff --git a/src/Dap.Shared/Dap.Shared.csproj b/src/Dap.Shared/Dap.Shared.csproj index 7b833c799..cabed9b52 100644 --- a/src/Dap.Shared/Dap.Shared.csproj +++ b/src/Dap.Shared/Dap.Shared.csproj @@ -1,25 +1,28 @@ - netstandard2.1;netstandard2.0 + netstandard2.1;netstandard2.0;net6.0 AnyCPU OmniSharp.Extensions.DebugAdapter.Shared OmniSharp.Extensions.DebugAdapter.Shared - - + + - <_Parameter1>OmniSharp.Extensions.DebugAdapter.Testing, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f + <_Parameter1 + >OmniSharp.Extensions.DebugAdapter.Testing, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f - <_Parameter1>OmniSharp.Extensions.DebugAdapter.Server, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f + <_Parameter1 + >OmniSharp.Extensions.DebugAdapter.Server, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f - <_Parameter1>OmniSharp.Extensions.DebugAdapter.Client, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f + <_Parameter1 + >OmniSharp.Extensions.DebugAdapter.Client, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f diff --git a/src/Dap.Testing/Dap.Testing.csproj b/src/Dap.Testing/Dap.Testing.csproj index fd64128ec..dec248cdd 100644 --- a/src/Dap.Testing/Dap.Testing.csproj +++ b/src/Dap.Testing/Dap.Testing.csproj @@ -1,7 +1,7 @@  - netstandard2.1;netstandard2.0 + netstandard2.1;netstandard2.0;net6.0 AnyCPU OmniSharp.Extensions.DebugAdapter.Testing OmniSharp.Extensions.DebugAdapter.Testing @@ -9,9 +9,9 @@ - - - - + + + + diff --git a/src/JsonRpc.Testing/JsonRpc.Testing.csproj b/src/JsonRpc.Testing/JsonRpc.Testing.csproj index 5c6ce8413..d02e92518 100644 --- a/src/JsonRpc.Testing/JsonRpc.Testing.csproj +++ b/src/JsonRpc.Testing/JsonRpc.Testing.csproj @@ -1,7 +1,7 @@  - netstandard2.1;netstandard2.0 + netstandard2.1;netstandard2.0;net6.0 AnyCPU OmniSharp.Extensions.JsonRpc.Testing OmniSharp.Extensions.JsonRpc.Testing @@ -13,10 +13,12 @@ - <_Parameter1>OmniSharp.Extensions.LanguageProtocol.Testing, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f + <_Parameter1 + >OmniSharp.Extensions.LanguageProtocol.Testing, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f - <_Parameter1>OmniSharp.Extensions.DebugAdapter.Testing, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f + <_Parameter1 + >OmniSharp.Extensions.DebugAdapter.Testing, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f diff --git a/src/JsonRpc/DryIoc/DryIocAdapter.cs b/src/JsonRpc/DryIoc/DryIocAdapter.cs index 2b30999fd..ca0e269b9 100644 --- a/src/JsonRpc/DryIoc/DryIocAdapter.cs +++ b/src/JsonRpc/DryIoc/DryIocAdapter.cs @@ -1,184 +1,188 @@ -using System; -using System.Collections.Generic; +using System.Runtime.CompilerServices; using Microsoft.Extensions.DependencyInjection; using OmniSharp.Extensions.JsonRpc; -// ReSharper disable once CheckNamespace -namespace DryIoc -{ +namespace DryIoc; - /// Adapts DryIoc container to be used as MS.DI service provider, plus provides the helpers - /// to simplify work with adapted container. - internal static class DryIocAdapter +/// Adapts DryIoc container to be used as MS.DI service provider, plus provides the helpers +/// to simplify work with adapted container. +internal static class DryIocAdapter +{ + /// Adapts passed to Microsoft.DependencyInjection conventions, + /// registers DryIoc implementations of and , + /// and returns NEW container. + /// + /// Source container to adapt. + /// (optional) Specify service descriptors or use later. + /// (optional) Custom registration action, should return true to skip normal registration. + /// (optional) Use DryIoc capability. + /// + /// (Reuse.Scoped) + /// + /// // applies the MS.DI rules and registers the infrastructure helpers and service collection to the container + /// var adaptedContainer = container.WithDependencyInjectionAdapter(services); + /// + /// // the container implements IServiceProvider + /// IServiceProvider serviceProvider = adaptedContainer; + /// + ///]]> + /// + /// You still need to Dispose adapted container at the end / application shutdown. + public static IContainer WithDependencyInjectionAdapter( + this IContainer container, + IEnumerable descriptors = null, + Func registerDescriptor = null, + RegistrySharing registrySharing = RegistrySharing.Share + ) { - /// Creates the container and the `IServiceProvider` because its implemented by `IContainer` - - /// you get simply the best of both worlds. - public static IContainer Create( - IEnumerable services, - Func? registerService = null) - { - var container = new Container(Rules.MicrosoftDependencyInjectionRules); - - container.Use(r => new DryIocServiceScopeFactory(r)); - container.Populate(services, registerService); - - return container; - } + if (container.Rules != Rules.MicrosoftDependencyInjectionRules) + container = container.With( + container.Rules.WithMicrosoftDependencyInjectionRules(), + container.ScopeContext, registrySharing, container.SingletonScope + ); + + var capabilities = new DryIocServiceProviderCapabilities(container); + var singletons = container.SingletonScope; +#if NET6_0_OR_GREATER + singletons.Use(capabilities); +#endif + singletons.Use(capabilities); + singletons.UseFactory(r => new DryIocServiceScopeFactory(r)); + + if (descriptors != null) + container.Populate(descriptors, registerDescriptor); + + return container; + } - /// Adapts passed to Microsoft.DependencyInjection conventions, - /// registers DryIoc implementations of and , - /// and returns NEW container. - /// - /// Source container to adapt. - /// (optional) Specify service descriptors or use later. - /// (optional) Custom registration action, should return true to skip normal registration. - /// - /// (Reuse.Scoped) - /// - /// var adaptedContainer = container.WithDependencyInjectionAdapter(services); - /// IServiceProvider serviceProvider = adaptedContainer; // the container implements IServiceProvider now - /// - ///]]> - /// - /// You still need to Dispose adapted container at the end / application shutdown. - public static IContainer WithDependencyInjectionAdapter(this IContainer container, - IEnumerable? descriptors = null, - Func? registerDescriptor = null) - { - if (container.Rules != Rules.MicrosoftDependencyInjectionRules) - container = container.With(rules => rules.WithMicrosoftDependencyInjectionRules()); + /// Sugar to create the DryIoc container and adapter populated with services + public static IServiceProvider CreateServiceProvider(this IServiceCollection services) => + new Container(DryIoc.Rules.MicrosoftDependencyInjectionRules).WithDependencyInjectionAdapter(services); - container.Use(r => new DryIocServiceScopeFactory(r)); + /// Adds services registered in to container + public static IContainer WithCompositionRoot(this IContainer container, Type compositionRootType) + { + container.Register(compositionRootType); + container.Resolve(compositionRootType); + return container; + } - // Registers service collection - if (descriptors != null) - container.Populate(descriptors, registerDescriptor); + /// Adds services registered in to container + public static IContainer WithCompositionRoot(this IContainer container) => + container.WithCompositionRoot(typeof(TCompositionRoot)); + + /// It does not really build anything, it just gets the `IServiceProvider` from the container. + public static IServiceProvider BuildServiceProvider(this IContainer container) => + container.GetServiceProvider(); + + /// Just gets the `IServiceProvider` from the container. + public static IServiceProvider GetServiceProvider(this IResolver container) => + container; + + /// Facade to consolidate DryIoc registrations in + /// The class will be created by container on Startup + /// to enable registrations with injected or full . + /// Adapted container Service provider + /// + /// (Reuse.Singleton); + /// r.Register(Reuse.Transient); + /// r.Register(Reuse.InCurrentScope); + /// } + /// } + /// ]]> + /// + public static IServiceProvider ConfigureServiceProvider(this IContainer container) => + container.WithCompositionRoot().GetServiceProvider(); + + /// Registers service descriptors into container. May be called multiple times with different service collections. + /// The container. + /// The service descriptors. + /// (optional) Custom registration action, should return true to skip normal registration. + /// + /// { + /// if (service.ServiceType == typeof(SomeService)) { + /// r.Register(Made.Of(() => CreateCustomService()), Reuse.Singleton); + /// return true; + /// }; + /// return false; // fallback to normal registrations for the rest of the descriptors. + /// }); + /// ]]> + /// + public static IContainer Populate( + this IContainer container, IEnumerable descriptors, + Func registerDescriptor = null + ) + { + if (registerDescriptor == null) + foreach (var descriptor in descriptors) + container.RegisterDescriptor(descriptor); + else + foreach (var descriptor in descriptors) + if (!registerDescriptor(container, descriptor)) + container.RegisterDescriptor(descriptor); + return container; + } - return container; - } + /// Converts the MS.DI ServiceLifetime into the corresponding `DryIoc.IReuse` + [MethodImpl((MethodImplOptions)256)] + public static IReuse ToReuse(this ServiceLifetime lifetime) => + lifetime == ServiceLifetime.Singleton ? Reuse.Singleton : + lifetime == ServiceLifetime.Scoped ? Reuse.ScopedOrSingleton : // see, that we have Reuse.ScopedOrSingleton here instead of Reuse.Scoped + Reuse.Transient; - /// Adds services registered in to container - public static IContainer WithCompositionRoot(this IContainer container, Type compositionRootType) + /// Unpacks the service descriptor to register the service in DryIoc container + public static void RegisterDescriptor(this IContainer container, ServiceDescriptor descriptor) + { + var serviceType = descriptor.ServiceType; + var implType = descriptor.ImplementationType; + if (implType != null) { - container.Register(compositionRootType); - container.Resolve(compositionRootType); - return container; + // ensure eventing handlers are pulled in automagically. + container.RegisterMany( + new [] {descriptor.ImplementationType}, + reuse: descriptor.Lifetime.ToReuse(), + serviceTypeCondition: type => type == descriptor.ImplementationType || type == descriptor.ServiceType || typeof(IEventingHandler).IsAssignableFrom(type) || typeof(IJsonRpcHandler).IsAssignableFrom(type), + nonPublicServiceTypes: true + ); } - - /// Adds services registered in to container - public static IContainer WithCompositionRoot(this IContainer container) => - container.WithCompositionRoot(typeof(TCompositionRoot)); - - /// It does not really build anything, it just gets the `IServiceProvider` from the container. - public static IServiceProvider BuildServiceProvider(this IContainer container) => - container.GetServiceProvider(); - - /// Just gets the `IServiceProvider` from the container. - public static IServiceProvider GetServiceProvider(this IResolver container) => - container; - - /// Facade to consolidate DryIoc registrations in - /// The class will be created by container on Startup - /// to enable registrations with injected or full . - /// Adapted container Service provider - /// - /// (Reuse.Singleton); - /// r.Register(Reuse.Transient); - /// r.Register(Reuse.InCurrentScope); - /// } - /// } - /// ]]> - /// - public static IServiceProvider ConfigureServiceProvider(this IContainer container) => - container.WithCompositionRoot().GetServiceProvider(); - - /// Registers service descriptors into container. May be called multiple times with different service collections. - /// The container. - /// The service descriptors. - /// (optional) Custom registration action, should return true to skip normal registration. - /// - /// { - /// if (service.ServiceType == typeof(SomeService)) { - /// r.Register(Made.Of(() => CreateCustomService()), Reuse.Singleton); - /// return true; - /// }; - /// return false; // fallback to normal registrations for the rest of the descriptors. - /// }); - /// ]]> - /// - public static IContainer Populate(this IContainer container, IEnumerable descriptors, - Func? registerDescriptor = null) + else if (descriptor.ImplementationFactory != null) { - if (registerDescriptor == null) - foreach (var descriptor in descriptors) - container.RegisterDescriptor(descriptor); - else - foreach (var descriptor in descriptors) - if (!registerDescriptor(container, descriptor)) - container.RegisterDescriptor(descriptor); - return container; + container.Register( + DelegateFactory.Of(descriptor.ImplementationFactory.ToFactoryDelegate, descriptor.Lifetime.ToReuse()), serviceType, + null, null, isStaticallyChecked: true + ); } - - /// Uses passed descriptor to register service in container: - /// maps DI Lifetime to DryIoc Reuse, - /// and DI registration type to corresponding DryIoc Register, RegisterDelegate or RegisterInstance. - /// The container. - /// Service descriptor. - public static void RegisterDescriptor(this IContainer container, ServiceDescriptor descriptor) + else { - if (descriptor.ImplementationType != null) + // ensure eventing handlers are pulled in automagically. + if (descriptor.ImplementationInstance is not IEnumerable + && descriptor.ImplementationInstance is IEventingHandler or IJsonRpcHandler) { - var reuse = descriptor.Lifetime == ServiceLifetime.Singleton ? Reuse.Singleton - : descriptor.Lifetime == ServiceLifetime.Scoped ? Reuse.Scoped - : Reuse.Transient; - - // ensure eventing handlers are pulled in automagically. - container.RegisterMany( - new [] {descriptor.ImplementationType}, - reuse: reuse, - serviceTypeCondition: type => type == descriptor.ImplementationType || type == descriptor.ServiceType || typeof(IEventingHandler).IsAssignableFrom(type) || typeof(IJsonRpcHandler).IsAssignableFrom(type), - nonPublicServiceTypes: true - ); - } - else if (descriptor.ImplementationFactory != null) - { - var reuse = descriptor.Lifetime == ServiceLifetime.Singleton ? Reuse.Singleton - : descriptor.Lifetime == ServiceLifetime.Scoped ? Reuse.Scoped - : Reuse.Transient; - - container.RegisterDelegate(true, descriptor.ServiceType, - descriptor.ImplementationFactory, - reuse - ); + var instance = descriptor.ImplementationInstance; + container.RegisterInstanceMany(instance, nonPublicServiceTypes: true); + container.TrackDisposable(instance); } else { - // ensure eventing handlers are pulled in automagically. - if (!(descriptor.ImplementationInstance is IEnumerable) && (descriptor.ImplementationInstance is IEventingHandler || descriptor.ImplementationInstance is IJsonRpcHandler)) - { - - container.RegisterInstanceMany( - descriptor.ImplementationInstance, - nonPublicServiceTypes: true - ); - } - else - { - container.RegisterInstance(true, descriptor.ServiceType, descriptor.ImplementationInstance); - } + var instance = descriptor.ImplementationInstance; + container.Register( + InstanceFactory.Of(instance), serviceType, + null, null, isStaticallyChecked: true + ); + container.TrackDisposable(instance); } } } diff --git a/src/JsonRpc/DryIoc/DryIocServiceProviderCapabilities.cs b/src/JsonRpc/DryIoc/DryIocServiceProviderCapabilities.cs new file mode 100644 index 000000000..c291ecc91 --- /dev/null +++ b/src/JsonRpc/DryIoc/DryIocServiceProviderCapabilities.cs @@ -0,0 +1,46 @@ +using Microsoft.Extensions.DependencyInjection; + +namespace DryIoc; + +/// Wrapper of DryIoc `IsRegistered` and `Resolve` throwing the exception on unresolved type capabilities. +internal sealed class DryIocServiceProviderCapabilities : +#if NET6_0_OR_GREATER + IServiceProviderIsService, +#endif + ISupportRequiredService +{ + private readonly IContainer _container; + + /// Statefully wraps the passed + public DryIocServiceProviderCapabilities(IContainer container) => _container = container; + + /// + public bool IsService(Type serviceType) + { + // I am not fully comprehend but MS.DI considers asking for the open-generic type even if it is registered to return `false` + // Probably mixing here the fact that open type cannot be instantiated without providing the concrete type argument. + // But I think it is conflating two things and making the reasoning harder. + if (serviceType.IsGenericTypeDefinition) + return false; + + if ( +#if NET6_0_OR_GREATER + serviceType == typeof(IServiceProviderIsService) || +#endif + serviceType == typeof(ISupportRequiredService) || + serviceType == typeof(IServiceScopeFactory)) + return true; + + if (_container.IsRegistered(serviceType)) + return true; + + if (serviceType.IsGenericType && + _container.IsRegistered(serviceType.GetGenericTypeDefinition())) + return true; + + return _container.IsRegistered(serviceType, factoryType: FactoryType.Wrapper); + } + + /// + public object GetRequiredService(Type serviceType) => _container.Resolve(serviceType); +} \ No newline at end of file diff --git a/src/JsonRpc/DryIoc/DryIocServiceProviderFactory.cs b/src/JsonRpc/DryIoc/DryIocServiceProviderFactory.cs index 28b752b46..fde1de962 100644 --- a/src/JsonRpc/DryIoc/DryIocServiceProviderFactory.cs +++ b/src/JsonRpc/DryIoc/DryIocServiceProviderFactory.cs @@ -1,56 +1,77 @@ -using System; -using Microsoft.Extensions.DependencyInjection; -// ReSharper disable once CheckNamespace +using Microsoft.Extensions.DependencyInjection; -namespace DryIoc +namespace DryIoc; + +/// +/// This DryIoc is supposed to be used with generic `IHostBuilder` like this: +/// +/// +/// await CreateHostBuilder(args).Build().RunAsync(); +/// +/// Rules WithMyRules(Rules currentRules) => currentRules; +/// +/// public static IHostBuilder CreateHostBuilder(string[] args) => +/// Host.CreateDefaultBuilder(args) +/// .UseServiceProviderFactory(new DryIocServiceProviderFactory(new Container(rules => WithMyRules(rules)))) +/// .ConfigureWebHostDefaults(webBuilder => +/// { +/// webBuilder.UseStartup(); +/// }); +/// } +/// ]]> +/// +/// Then register your services in `Startup.ConfigureContainer`. +/// +/// DON'T try to change the container rules there - they will be lost, +/// instead pass the pre-configured container to `DryIocServiceProviderFactory` as in example above. +/// By default container will use +/// +/// DON'T forget to add `services.AddControllers().AddControllersAsServices()` in `Startup.ConfigureServices` +/// in order to access DryIoc diagnostics for controllers, property-injection, etc. +/// +/// +internal class DryIocServiceProviderFactory : IServiceProviderFactory { - /// This DryIoc is supposed to be used with `IHostBuilder` like this: - /// - /// await CreateHostBuilder(args).Build().RunAsync(); - /// - /// public static IHostBuilder CreateHostBuilder(string[] args) => - /// Host.CreateDefaultBuilder(args) - /// .UseServiceProviderFactory(new DryIocServiceProviderFactory(new Container(rules => WithMyRules(rules)))) - /// .ConfigureWebHostDefaults(webBuilder => - /// { - /// webBuilder.UseStartup(); - /// }); - /// } - /// ]]> - /// - /// Then register your services in `Startup.ConfigureContainer`. - /// - /// DON'T try to change the container rules there - they will be lost, - /// instead pass the pre-configured container to `DryIocServiceProviderFactory` as in example above. - /// - /// DON'T forget to add `services.AddControllers().AddControllersAsServices` in `Startup.ConfigureServices` - /// in order to access DryIoc diagnostics for controllers, property-injection, etc. - /// - /// That's probably ALL YOU NEED to do. + private readonly IContainer _container; + private readonly Func _registerDescriptor; + private readonly RegistrySharing _registrySharing; + + /// + /// We won't initialize the container here because it is logically expected to be done in `CreateBuilder`, + /// so the factory constructor is just saving some options to use later. /// - internal class DryIocServiceProviderFactory : IServiceProviderFactory + public DryIocServiceProviderFactory( + IContainer container = null, + Func registerDescriptor = null + ) : + this(container, RegistrySharing.CloneAndDropCache, registerDescriptor) { - private readonly IContainer? _container; - private readonly Func? _registerDescriptor; + } - /// Some options to push to `.WithDependencyInjectionAdapter(...)` - public DryIocServiceProviderFactory( - IContainer? container = null, - Func? registerDescriptor = null) - { - _container = container; // we won't initialize the container here because it is logically expected to be done in `CreateBuilder` - _registerDescriptor = registerDescriptor; - } + /// + /// `container` is the existing container which will be cloned with the MS.DI rules and its cache will be dropped, + /// unless the `registrySharing` is set to the `RegistrySharing.Share` or to `RegistrySharing.CloneButKeepCache`. + /// `registerDescriptor` is the custom service descriptor handler. + /// + public DryIocServiceProviderFactory( + IContainer container, RegistrySharing registrySharing, + Func registerDescriptor = null + ) + { + _container = container; + _registrySharing = registrySharing; + _registerDescriptor = registerDescriptor; + } - /// - public IContainer CreateBuilder(IServiceCollection services) => - (_container ?? new Container()).WithDependencyInjectionAdapter(services, _registerDescriptor); + /// + public IContainer CreateBuilder(IServiceCollection services) => + ( _container ?? new Container(Rules.MicrosoftDependencyInjectionRules) ) + .WithDependencyInjectionAdapter(services, _registerDescriptor, _registrySharing); - /// - public IServiceProvider CreateServiceProvider(IContainer container) => - container.BuildServiceProvider(); - } -} + /// + public IServiceProvider CreateServiceProvider(IContainer container) => + container.BuildServiceProvider(); +} \ No newline at end of file diff --git a/src/JsonRpc/DryIoc/DryIocServiceScope.cs b/src/JsonRpc/DryIoc/DryIocServiceScope.cs index d1951a5c5..b0688b136 100644 --- a/src/JsonRpc/DryIoc/DryIocServiceScope.cs +++ b/src/JsonRpc/DryIoc/DryIocServiceScope.cs @@ -1,24 +1,18 @@ -using System; -using Microsoft.Extensions.DependencyInjection; -// ReSharper disable once CheckNamespace +using Microsoft.Extensions.DependencyInjection; -namespace DryIoc +namespace DryIoc; + +/// Bare-bones IServiceScope implementations +internal sealed class DryIocServiceScope : IServiceScope { - /// Bare-bones IServiceScope implementations - internal sealed class DryIocServiceScope : IServiceScope - { - /// - public IServiceProvider ServiceProvider => _resolverContext; + /// + public IServiceProvider ServiceProvider => _resolverContext; - private readonly IResolverContext _resolverContext; + private readonly IResolverContext _resolverContext; - /// Creating from resolver context - public DryIocServiceScope(IResolverContext resolverContext) - { - _resolverContext = resolverContext; - } + /// Creating from resolver context + public DryIocServiceScope(IResolverContext resolverContext) => _resolverContext = resolverContext; - /// Disposes the underlying resolver context - public void Dispose() => _resolverContext.Dispose(); - } -} + /// Disposes the underlying resolver context + public void Dispose() => _resolverContext.Dispose(); +} \ No newline at end of file diff --git a/src/JsonRpc/DryIoc/DryIocServiceScopeFactory.cs b/src/JsonRpc/DryIoc/DryIocServiceScopeFactory.cs index f45a9e738..742855a28 100644 --- a/src/JsonRpc/DryIoc/DryIocServiceScopeFactory.cs +++ b/src/JsonRpc/DryIoc/DryIocServiceScopeFactory.cs @@ -1,4 +1,5 @@ using Microsoft.Extensions.DependencyInjection; + // ReSharper disable once CheckNamespace namespace DryIoc @@ -10,17 +11,16 @@ internal sealed class DryIocServiceScopeFactory : IServiceScopeFactory /// Stores passed scoped container to open nested scope. /// Scoped container to be used to create nested scope. - public DryIocServiceScopeFactory(IResolverContext scopedResolver) - { - _scopedResolver = scopedResolver; - } + public DryIocServiceScopeFactory(IResolverContext scopedResolver) => _scopedResolver = scopedResolver; /// Opens scope and wraps it into DI interface. /// DI wrapper of opened scope. public IServiceScope CreateScope() { var r = _scopedResolver; - var scope = r.ScopeContext == null ? new Scope(r.CurrentScope) : r.ScopeContext.SetCurrent(p => new Scope(p)); + var scope = r.ScopeContext == null + ? Scope.Of(r.OwnCurrentScope) + : r.ScopeContext.SetCurrent(p => Scope.Of(p)); return new DryIocServiceScope(r.WithCurrentScope(scope)); } } diff --git a/src/JsonRpc/JsonRpc.csproj b/src/JsonRpc/JsonRpc.csproj index b347e0f6d..29782f6dc 100644 --- a/src/JsonRpc/JsonRpc.csproj +++ b/src/JsonRpc/JsonRpc.csproj @@ -1,6 +1,6 @@ - netstandard2.1;netstandard2.0 + netstandard2.1;netstandard2.0;net6.0 AnyCPU OmniSharp.Extensions.JsonRpc OmniSharp.Extensions.JsonRpc diff --git a/src/JsonRpc/JsonRpcServerContainer.cs b/src/JsonRpc/JsonRpcServerContainer.cs index b69a102cf..ccc645e85 100644 --- a/src/JsonRpc/JsonRpcServerContainer.cs +++ b/src/JsonRpc/JsonRpcServerContainer.cs @@ -37,7 +37,7 @@ public static IContainer Create(IServiceProvider? outerServiceProvider) rules => rules.WithUnknownServiceResolvers( request => { var value = outerServiceProvider.GetService(request.ServiceType); - return value == null ? null : (Factory) new RegisteredInstanceFactory(value, Reuse.Transient); + return value == null ? null : (Factory) InstanceFactory.Of(value, Reuse.Transient); } ) ); diff --git a/src/JsonRpc/JsonRpcServerServiceCollectionExtensions.cs b/src/JsonRpc/JsonRpcServerServiceCollectionExtensions.cs index e61f8059c..c24bb27d2 100644 --- a/src/JsonRpc/JsonRpcServerServiceCollectionExtensions.cs +++ b/src/JsonRpc/JsonRpcServerServiceCollectionExtensions.cs @@ -49,23 +49,23 @@ internal static IContainer AddJsonRpcServerCore(this IContainer container, Js ); container.Register( - made: new Made.TypedMade().Parameters - .Type(serviceKey: nameof(options.MaximumRequestTimeout)) - .Type(serviceKey: nameof(options.SupportsContentModified)) - .Name("concurrency", serviceKey: nameof(options.Concurrency)), + made: Made.Of().Parameters + .Type(serviceKey: nameof(options.MaximumRequestTimeout)) + .Type(serviceKey: nameof(options.SupportsContentModified)) + .Name("concurrency", serviceKey: nameof(options.Concurrency)), reuse: Reuse.Singleton); if (!container.IsRegistered()) { container.Register( - made: new Made.TypedMade().Parameters - .Type(serviceKey: nameof(options.InputScheduler)), + made: Made.Of().Parameters + .Type(serviceKey: nameof(options.InputScheduler)), reuse: Reuse.Singleton); } container.Register( - made: new Made.TypedMade().Parameters - .Type(serviceKey: nameof(options.Input)) + made: Made.Of().Parameters + .Type(serviceKey: nameof(options.Input)) , reuse: Reuse.Singleton ); diff --git a/src/Protocol.Proposals/Protocol.Proposals.csproj b/src/Protocol.Proposals/Protocol.Proposals.csproj index b330ead61..2e61bfaed 100644 --- a/src/Protocol.Proposals/Protocol.Proposals.csproj +++ b/src/Protocol.Proposals/Protocol.Proposals.csproj @@ -1,19 +1,20 @@ - netstandard2.1;netstandard2.0 + netstandard2.1;netstandard2.0;net6.0 AnyCPU OmniSharp.Extensions.LanguageProtocol.Proposals OmniSharp.Extensions.LanguageServer.Protocol - Proposed Language Server Protocol models, classes, interfaces and helper methods, that may or may not make it into the final spec + Proposed Language Server Protocol models, classes, interfaces and helper methods, that may or may not make it into the final spec - - - + + + - + diff --git a/src/Protocol/Features/Document/SemanticTokensBuilder.cs b/src/Protocol/Features/Document/SemanticTokensBuilder.cs index 87c26a98b..bdd5b94a9 100644 --- a/src/Protocol/Features/Document/SemanticTokensBuilder.cs +++ b/src/Protocol/Features/Document/SemanticTokensBuilder.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Collections.Immutable; using OmniSharp.Extensions.LanguageServer.Protocol.Models; -using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range; + // ReSharper disable once CheckNamespace namespace OmniSharp.Extensions.LanguageServer.Protocol.Document diff --git a/src/Protocol/Features/Document/SemanticTokensDocument.cs b/src/Protocol/Features/Document/SemanticTokensDocument.cs index a9d7e1155..562478f51 100644 --- a/src/Protocol/Features/Document/SemanticTokensDocument.cs +++ b/src/Protocol/Features/Document/SemanticTokensDocument.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Immutable; using OmniSharp.Extensions.LanguageServer.Protocol.Models; -using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range; + // ReSharper disable once CheckNamespace namespace OmniSharp.Extensions.LanguageServer.Protocol.Document diff --git a/src/Protocol/Protocol.csproj b/src/Protocol/Protocol.csproj index bedebe4d9..28fb52bfa 100644 --- a/src/Protocol/Protocol.csproj +++ b/src/Protocol/Protocol.csproj @@ -1,6 +1,6 @@ - netstandard2.1;netstandard2.0 + netstandard2.1;netstandard2.0;net6.0 AnyCPU OmniSharp.Extensions.LanguageProtocol OmniSharp.Extensions.LanguageServer.Protocol @@ -15,23 +15,34 @@ - + - <_Parameter1>OmniSharp.Extensions.LanguageProtocol.Testing, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f + <_Parameter1 + >OmniSharp.Extensions.LanguageProtocol.Testing, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f - <_Parameter1>OmniSharp.Extensions.LanguageServer, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f + <_Parameter1 + >OmniSharp.Extensions.LanguageServer, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f - <_Parameter1>OmniSharp.Extensions.LanguageProtocol.Proposals, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f + <_Parameter1 + >OmniSharp.Extensions.LanguageProtocol.Proposals, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f - <_Parameter1>OmniSharp.Extensions.LanguageServer.Shared, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f + <_Parameter1 + >OmniSharp.Extensions.LanguageServer.Shared, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f - <_Parameter1>OmniSharp.Extensions.LanguageClient, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f + <_Parameter1 + >OmniSharp.Extensions.LanguageClient, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f diff --git a/src/Protocol/Serialization/Converters/RangeOrPlaceholderRangeConverter.cs b/src/Protocol/Serialization/Converters/RangeOrPlaceholderRangeConverter.cs index 38887e41d..ff641aa77 100644 --- a/src/Protocol/Serialization/Converters/RangeOrPlaceholderRangeConverter.cs +++ b/src/Protocol/Serialization/Converters/RangeOrPlaceholderRangeConverter.cs @@ -2,7 +2,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using OmniSharp.Extensions.LanguageServer.Protocol.Models; -using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range; + namespace OmniSharp.Extensions.LanguageServer.Protocol.Serialization.Converters { diff --git a/src/Protocol/Serialization/Converters/TextEditConverter.cs b/src/Protocol/Serialization/Converters/TextEditConverter.cs index 7777a111a..69929db95 100644 --- a/src/Protocol/Serialization/Converters/TextEditConverter.cs +++ b/src/Protocol/Serialization/Converters/TextEditConverter.cs @@ -2,7 +2,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using OmniSharp.Extensions.LanguageServer.Protocol.Models; -using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range; + namespace OmniSharp.Extensions.LanguageServer.Protocol.Serialization.Converters { diff --git a/src/Protocol/Usings.global.cs b/src/Protocol/Usings.global.cs new file mode 100644 index 000000000..1f6c6a094 --- /dev/null +++ b/src/Protocol/Usings.global.cs @@ -0,0 +1 @@ +global using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range; diff --git a/src/Server/Server.csproj b/src/Server/Server.csproj index 572abd66d..d3c5c310b 100644 --- a/src/Server/Server.csproj +++ b/src/Server/Server.csproj @@ -1,6 +1,6 @@  - netstandard2.1;netstandard2.0 + netstandard2.1;netstandard2.0;net6.0 AnyCPU OmniSharp.Extensions.LanguageServer OmniSharp.Extensions.LanguageServer.Server @@ -8,14 +8,15 @@ - - - - + + + + - <_Parameter1>OmniSharp.Extensions.LanguageProtocol.Testing, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f + <_Parameter1 + >OmniSharp.Extensions.LanguageProtocol.Testing, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f diff --git a/src/Shared/Shared.csproj b/src/Shared/Shared.csproj index b253a26d1..b42aa76a1 100644 --- a/src/Shared/Shared.csproj +++ b/src/Shared/Shared.csproj @@ -1,23 +1,26 @@ - netstandard2.1;netstandard2.0 + netstandard2.1;netstandard2.0;net6.0 AnyCPU OmniSharp.Extensions.LanguageServer.Shared OmniSharp.Extensions.LanguageServer.Shared Shared classes for language server protocol - + - <_Parameter1>OmniSharp.Extensions.LanguageProtocol.Testing, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f + <_Parameter1 + >OmniSharp.Extensions.LanguageProtocol.Testing, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f - <_Parameter1>OmniSharp.Extensions.LanguageServer, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f + <_Parameter1 + >OmniSharp.Extensions.LanguageServer, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f - <_Parameter1>OmniSharp.Extensions.LanguageClient, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f + <_Parameter1 + >OmniSharp.Extensions.LanguageClient, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f diff --git a/src/Testing/TestContent.cs b/src/Testing/TestContent.cs index a9c52d607..a8b0635e5 100644 --- a/src/Testing/TestContent.cs +++ b/src/Testing/TestContent.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using OmniSharp.Extensions.LanguageServer.Protocol.Models; -using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range; + namespace OmniSharp.Extensions.LanguageProtocol.Testing { diff --git a/src/Testing/TestSourceHelpers.cs b/src/Testing/TestSourceHelpers.cs index 5b3e588ec..8e06cbf47 100644 --- a/src/Testing/TestSourceHelpers.cs +++ b/src/Testing/TestSourceHelpers.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; using OmniSharp.Extensions.LanguageServer.Protocol.Models; -using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range; + namespace OmniSharp.Extensions.LanguageProtocol.Testing { diff --git a/src/Testing/Testing.csproj b/src/Testing/Testing.csproj index 279eb835f..4ce49a710 100644 --- a/src/Testing/Testing.csproj +++ b/src/Testing/Testing.csproj @@ -1,7 +1,7 @@  - netstandard2.1;netstandard2.0 + netstandard2.1;netstandard2.0;net6.0 AnyCPU OmniSharp.Extensions.LanguageProtocol.Testing OmniSharp.Extensions.LanguageProtocol.Testing @@ -9,9 +9,9 @@ - - - - + + + + diff --git a/src/Testing/Usings.global.cs b/src/Testing/Usings.global.cs new file mode 100644 index 000000000..1f6c6a094 --- /dev/null +++ b/src/Testing/Usings.global.cs @@ -0,0 +1 @@ +global using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range; diff --git a/test/.editorconfig b/test/.editorconfig index c810d8b12..f1d0802e3 100644 --- a/test/.editorconfig +++ b/test/.editorconfig @@ -1,22 +1,27 @@ -[*] -dotnet_diagnostic.CA2007.severity = none -dotnet_diagnostic.CS0618.severity = none -dotnet_diagnostic.CS0168.severity = none -dotnet_diagnostic.CS0105.severity = none -dotnet_diagnostic.CS4014.severity = none -dotnet_diagnostic.CS0162.severity = none -dotnet_diagnostic.CS8602.severity = none -dotnet_diagnostic.CS8604.severity = none -dotnet_diagnostic.CS8618.severity = none -dotnet_diagnostic.CS8619.severity = none -dotnet_diagnostic.CS8620.severity = none -dotnet_diagnostic.CS8625.severity = none -dotnet_diagnostic.CS8762.severity = none -dotnet_diagnostic.CS8767.severity = none -dotnet_diagnostic.CS1998.severity = none -dotnet_diagnostic.VSTHRD003.severity = none -dotnet_diagnostic.VSTHRD103.severity = none -dotnet_diagnostic.VSTHRD105.severity = none -dotnet_diagnostic.VSTHRD110.severity = none +[*] +dotnet_diagnostic.CS0436.severity = none +dotnet_diagnostic.CA1014.severity = none +dotnet_diagnostic.CA1034.severity = none +dotnet_diagnostic.CA1040.severity = none +dotnet_diagnostic.CA1062.severity = none +dotnet_diagnostic.CA1707.severity = none +dotnet_diagnostic.CA1711.severity = none +dotnet_diagnostic.CA1715.severity = none +dotnet_diagnostic.CA1720.severity = none +dotnet_diagnostic.CA1812.severity = none +dotnet_diagnostic.CA1822.severity = none +dotnet_diagnostic.CA1848.severity = none +dotnet_diagnostic.CA2000.severity = none +dotnet_diagnostic.CA2225.severity = none +dotnet_diagnostic.CA2227.severity = none +dotnet_diagnostic.CA2254.severity = none +dotnet_diagnostic.IDE0060.severity = none +dotnet_diagnostic.RCS1163.severity = none dotnet_diagnostic.VSTHRD200.severity = none +resharper_possible_multiple_enumeration_highlighting = none +resharper_template_is_not_compile_time_constant_problem_highlighting = none +resharper_inconsistent_naming_highlighting = none +resharper_variable_hides_outer_variable_highlighting = none resharper_unused_parameter_local_highlighting = none +resharper_unused_variable_highlighting = none +resharper_suspicious_type_conversion_global_highlighting = none diff --git a/test/Client.Tests/ClientTests.cs b/test/Client.Tests/ClientTests.cs index 650968289..6c31d0426 100644 --- a/test/Client.Tests/ClientTests.cs +++ b/test/Client.Tests/ClientTests.cs @@ -11,6 +11,7 @@ using Xunit.Abstractions; using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range; + namespace OmniSharp.Extensions.LanguageServer.Client.Tests { /// diff --git a/test/Generation.Tests/GeneratedRegistrationOptionsTests.cs b/test/Generation.Tests/GeneratedRegistrationOptionsTests.cs index 4c22321db..1ab1e1561 100644 --- a/test/Generation.Tests/GeneratedRegistrationOptionsTests.cs +++ b/test/Generation.Tests/GeneratedRegistrationOptionsTests.cs @@ -137,7 +137,7 @@ public async Task Supports_Generating_Strongly_Typed_Registration_Options() using OmniSharp.Extensions.LanguageServer.Protocol.Serialization; using OmniSharp.Extensions.LanguageServer.Protocol.Server; using OmniSharp.Extensions.LanguageServer.Protocol.Server.Capabilities; -using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range; + #nullable enable namespace OmniSharp.Extensions.LanguageServer.Protocol.Test @@ -183,7 +183,6 @@ public partial class CodeActionRegistrationOptions using OmniSharp.Extensions.LanguageServer.Protocol.Serialization; using OmniSharp.Extensions.LanguageServer.Protocol.Server; using OmniSharp.Extensions.LanguageServer.Protocol.Server.Capabilities; -using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range; #nullable enable namespace OmniSharp.Extensions.LanguageServer.Protocol.Test @@ -257,7 +256,6 @@ public async Task Supports_Generating_Strongly_Typed_Registration_Options_With_C using OmniSharp.Extensions.LanguageServer.Protocol.Models; using OmniSharp.Extensions.LanguageServer.Protocol.Serialization; using OmniSharp.Extensions.LanguageServer.Protocol.Server; -using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range; #nullable enable namespace OmniSharp.Extensions.LanguageServer.Protocol.Test @@ -322,7 +320,6 @@ public override StaticCodeActionRegistrationOptions Convert(CodeActionRegistrati using OmniSharp.Extensions.LanguageServer.Protocol.Models; using OmniSharp.Extensions.LanguageServer.Protocol.Serialization; using OmniSharp.Extensions.LanguageServer.Protocol.Server; -using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range; using OmniSharp.Extensions.LanguageServer.Protocol.Server.Capabilities; #nullable enable diff --git a/test/Generation.Tests/TypedCanBeResolvedTests.cs b/test/Generation.Tests/TypedCanBeResolvedTests.cs index 2544f5fd7..e3512ef7e 100644 --- a/test/Generation.Tests/TypedCanBeResolvedTests.cs +++ b/test/Generation.Tests/TypedCanBeResolvedTests.cs @@ -25,7 +25,6 @@ public async Task Supports_Generating_Strongly_Typed_ICanBeResolved_Data() using OmniSharp.Extensions.LanguageServer.Protocol.Models; using OmniSharp.Extensions.LanguageServer.Protocol.Serialization; using OmniSharp.Extensions.LanguageServer.Protocol.Server; -using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range; #nullable enable namespace OmniSharp.Extensions.LanguageServer.Protocol.Test @@ -76,7 +75,6 @@ public partial record CodeLens : IRequest, ICanBeResolved using OmniSharp.Extensions.LanguageServer.Protocol.Models; using OmniSharp.Extensions.LanguageServer.Protocol.Serialization; using OmniSharp.Extensions.LanguageServer.Protocol.Server; -using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Immutable; @@ -266,7 +264,6 @@ public async Task Supports_Generating_Strongly_Typed_Container() using OmniSharp.Extensions.LanguageServer.Protocol.Models; using OmniSharp.Extensions.LanguageServer.Protocol.Serialization; using OmniSharp.Extensions.LanguageServer.Protocol.Server; -using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range; #nullable enable namespace OmniSharp.Extensions.LanguageServer.Protocol.Test @@ -316,7 +313,6 @@ public partial class CodeLens : IRequest, ICanBeResolved using OmniSharp.Extensions.LanguageServer.Protocol.Models; using OmniSharp.Extensions.LanguageServer.Protocol.Serialization; using OmniSharp.Extensions.LanguageServer.Protocol.Server; -using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Immutable; diff --git a/test/Lsp.Integration.Tests/ExecuteCommandTests.cs b/test/Lsp.Integration.Tests/ExecuteCommandTests.cs index 5cf75ae98..9066bf3a4 100644 --- a/test/Lsp.Integration.Tests/ExecuteCommandTests.cs +++ b/test/Lsp.Integration.Tests/ExecuteCommandTests.cs @@ -17,7 +17,7 @@ using Serilog.Events; using Xunit; using Xunit.Abstractions; -using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range; + namespace Lsp.Integration.Tests { diff --git a/test/Lsp.Integration.Tests/ExecuteTypedCommandTests.cs b/test/Lsp.Integration.Tests/ExecuteTypedCommandTests.cs index b57001dc8..732a46dde 100644 --- a/test/Lsp.Integration.Tests/ExecuteTypedCommandTests.cs +++ b/test/Lsp.Integration.Tests/ExecuteTypedCommandTests.cs @@ -17,7 +17,7 @@ using Serilog.Events; using Xunit; using Xunit.Abstractions; -using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range; + namespace Lsp.Integration.Tests { diff --git a/test/Lsp.Integration.Tests/Lsp.Integration.Tests.csproj b/test/Lsp.Integration.Tests/Lsp.Integration.Tests.csproj index 4962ff8ef..fcb489822 100644 --- a/test/Lsp.Integration.Tests/Lsp.Integration.Tests.csproj +++ b/test/Lsp.Integration.Tests/Lsp.Integration.Tests.csproj @@ -1,6 +1,6 @@  - net6.0;netcoreapp3.1 + net6.0;netcoreapp3.1;net6.0 true AnyCPU @@ -19,6 +19,12 @@ - + diff --git a/test/Lsp.Integration.Tests/RenameTests.cs b/test/Lsp.Integration.Tests/RenameTests.cs index cffef9bc7..7c4d6be93 100644 --- a/test/Lsp.Integration.Tests/RenameTests.cs +++ b/test/Lsp.Integration.Tests/RenameTests.cs @@ -16,7 +16,7 @@ using TestingUtils; using Xunit; using Xunit.Abstractions; -using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range; + namespace Lsp.Integration.Tests { diff --git a/test/Lsp.Integration.Tests/Usings.global.cs b/test/Lsp.Integration.Tests/Usings.global.cs new file mode 100644 index 000000000..1f6c6a094 --- /dev/null +++ b/test/Lsp.Integration.Tests/Usings.global.cs @@ -0,0 +1 @@ +global using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range; diff --git a/test/Lsp.Tests/Lsp.Tests.csproj b/test/Lsp.Tests/Lsp.Tests.csproj index 4962ff8ef..fcb489822 100644 --- a/test/Lsp.Tests/Lsp.Tests.csproj +++ b/test/Lsp.Tests/Lsp.Tests.csproj @@ -1,6 +1,6 @@  - net6.0;netcoreapp3.1 + net6.0;netcoreapp3.1;net6.0 true AnyCPU @@ -19,6 +19,12 @@ - + diff --git a/test/Lsp.Tests/MediatorTestsRequestHandlerOfTRequestTResponse.cs b/test/Lsp.Tests/MediatorTestsRequestHandlerOfTRequestTResponse.cs index 0b4e8c6a2..e322ee26f 100644 --- a/test/Lsp.Tests/MediatorTestsRequestHandlerOfTRequestTResponse.cs +++ b/test/Lsp.Tests/MediatorTestsRequestHandlerOfTRequestTResponse.cs @@ -22,7 +22,6 @@ using Xunit.Abstractions; using Xunit.Sdk; using Arg = NSubstitute.Arg; -using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range; using Request = OmniSharp.Extensions.JsonRpc.Server.Request; #pragma warning disable CS0162 diff --git a/test/Lsp.Tests/Models/ApplyWorkspaceEditParamsTests.cs b/test/Lsp.Tests/Models/ApplyWorkspaceEditParamsTests.cs index ec62c4c1c..9ac2f424c 100644 --- a/test/Lsp.Tests/Models/ApplyWorkspaceEditParamsTests.cs +++ b/test/Lsp.Tests/Models/ApplyWorkspaceEditParamsTests.cs @@ -7,7 +7,6 @@ using OmniSharp.Extensions.LanguageServer.Protocol.Serialization; using TestingUtils; using Xunit; -using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range; namespace Lsp.Tests.Models { diff --git a/test/Lsp.Tests/Models/CodeActionParamsTests.cs b/test/Lsp.Tests/Models/CodeActionParamsTests.cs index cbe63cae8..d795dc4a6 100644 --- a/test/Lsp.Tests/Models/CodeActionParamsTests.cs +++ b/test/Lsp.Tests/Models/CodeActionParamsTests.cs @@ -5,7 +5,7 @@ using OmniSharp.Extensions.LanguageServer.Protocol.Serialization; using TestingUtils; using Xunit; -using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range; + namespace Lsp.Tests.Models { diff --git a/test/Lsp.Tests/Models/DiagnosticTests.cs b/test/Lsp.Tests/Models/DiagnosticTests.cs index 735da6d6c..5af0bf2b3 100644 --- a/test/Lsp.Tests/Models/DiagnosticTests.cs +++ b/test/Lsp.Tests/Models/DiagnosticTests.cs @@ -5,7 +5,7 @@ using OmniSharp.Extensions.LanguageServer.Protocol.Serialization; using TestingUtils; using Xunit; -using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range; + namespace Lsp.Tests.Models { diff --git a/test/Lsp.Tests/Models/DocumentLinkTests.cs b/test/Lsp.Tests/Models/DocumentLinkTests.cs index 92d65f404..a3ddedc5a 100644 --- a/test/Lsp.Tests/Models/DocumentLinkTests.cs +++ b/test/Lsp.Tests/Models/DocumentLinkTests.cs @@ -4,7 +4,7 @@ using OmniSharp.Extensions.LanguageServer.Protocol.Models; using OmniSharp.Extensions.LanguageServer.Protocol.Serialization; using Xunit; -using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range; + namespace Lsp.Tests.Models { diff --git a/test/Lsp.Tests/Models/DocumentSymbolInformationTests.cs b/test/Lsp.Tests/Models/DocumentSymbolInformationTests.cs index c0ff3b0da..07fed7f34 100644 --- a/test/Lsp.Tests/Models/DocumentSymbolInformationTests.cs +++ b/test/Lsp.Tests/Models/DocumentSymbolInformationTests.cs @@ -5,7 +5,7 @@ using OmniSharp.Extensions.LanguageServer.Protocol.Serialization; using TestingUtils; using Xunit; -using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range; + namespace Lsp.Tests.Models { diff --git a/test/Lsp.Tests/Models/LocationOrLocationLinksTests.cs b/test/Lsp.Tests/Models/LocationOrLocationLinksTests.cs index 5d6a68457..300d1cb4a 100644 --- a/test/Lsp.Tests/Models/LocationOrLocationLinksTests.cs +++ b/test/Lsp.Tests/Models/LocationOrLocationLinksTests.cs @@ -5,7 +5,7 @@ using OmniSharp.Extensions.LanguageServer.Protocol.Serialization; using TestingUtils; using Xunit; -using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range; + namespace Lsp.Tests.Models { diff --git a/test/Lsp.Tests/Models/LocationTests.cs b/test/Lsp.Tests/Models/LocationTests.cs index c3d6424f6..025db8316 100644 --- a/test/Lsp.Tests/Models/LocationTests.cs +++ b/test/Lsp.Tests/Models/LocationTests.cs @@ -5,7 +5,7 @@ using OmniSharp.Extensions.LanguageServer.Protocol.Serialization; using TestingUtils; using Xunit; -using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range; + namespace Lsp.Tests.Models { diff --git a/test/Lsp.Tests/Models/PublishDiagnosticsParamsTests.cs b/test/Lsp.Tests/Models/PublishDiagnosticsParamsTests.cs index 8a5ae567b..c5e9e6bcd 100644 --- a/test/Lsp.Tests/Models/PublishDiagnosticsParamsTests.cs +++ b/test/Lsp.Tests/Models/PublishDiagnosticsParamsTests.cs @@ -5,7 +5,7 @@ using OmniSharp.Extensions.LanguageServer.Protocol.Serialization; using TestingUtils; using Xunit; -using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range; + namespace Lsp.Tests.Models { diff --git a/test/Lsp.Tests/Models/TextDocumentEditTests.cs b/test/Lsp.Tests/Models/TextDocumentEditTests.cs index 9ee46bca0..9489f32ee 100644 --- a/test/Lsp.Tests/Models/TextDocumentEditTests.cs +++ b/test/Lsp.Tests/Models/TextDocumentEditTests.cs @@ -5,7 +5,7 @@ using OmniSharp.Extensions.LanguageServer.Protocol.Serialization; using TestingUtils; using Xunit; -using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range; + namespace Lsp.Tests.Models { diff --git a/test/Lsp.Tests/Models/WorkspaceEditTests.cs b/test/Lsp.Tests/Models/WorkspaceEditTests.cs index 75334924d..964dd1561 100644 --- a/test/Lsp.Tests/Models/WorkspaceEditTests.cs +++ b/test/Lsp.Tests/Models/WorkspaceEditTests.cs @@ -7,7 +7,7 @@ using OmniSharp.Extensions.LanguageServer.Protocol.Serialization; using TestingUtils; using Xunit; -using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range; + namespace Lsp.Tests.Models { diff --git a/test/Lsp.Tests/Models/WorkspaceSymbolInformationTests.cs b/test/Lsp.Tests/Models/WorkspaceSymbolInformationTests.cs index 24780de5f..a5105a878 100644 --- a/test/Lsp.Tests/Models/WorkspaceSymbolInformationTests.cs +++ b/test/Lsp.Tests/Models/WorkspaceSymbolInformationTests.cs @@ -5,7 +5,7 @@ using OmniSharp.Extensions.LanguageServer.Protocol.Serialization; using TestingUtils; using Xunit; -using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range; + namespace Lsp.Tests.Models { diff --git a/test/Lsp.Tests/SemanticTokensDocumentTests.cs b/test/Lsp.Tests/SemanticTokensDocumentTests.cs index 0c240ac45..41752c565 100644 --- a/test/Lsp.Tests/SemanticTokensDocumentTests.cs +++ b/test/Lsp.Tests/SemanticTokensDocumentTests.cs @@ -11,7 +11,7 @@ using OmniSharp.Extensions.LanguageServer.Protocol.Models; using Xunit; using Xunit.Abstractions; -using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range; + #pragma warning disable 618 diff --git a/test/Lsp.Tests/Usings.global.cs b/test/Lsp.Tests/Usings.global.cs new file mode 100644 index 000000000..1f6c6a094 --- /dev/null +++ b/test/Lsp.Tests/Usings.global.cs @@ -0,0 +1 @@ +global using Range = OmniSharp.Extensions.LanguageServer.Protocol.Models.Range; diff --git a/test/TestingUtils/AutoNSubstitute/DryIocExtensions.cs b/test/TestingUtils/AutoNSubstitute/DryIocExtensions.cs index d2ca14963..975f1aee3 100644 --- a/test/TestingUtils/AutoNSubstitute/DryIocExtensions.cs +++ b/test/TestingUtils/AutoNSubstitute/DryIocExtensions.cs @@ -35,7 +35,7 @@ internal static Rules WithTestLoggerResolver(this Rules rules, Func).MakeGenericType( request.ServiceType.GetGenericArguments()[0] ); - instance = new DelegateFactory(_ => creator(request, loggerType), Reuse.Singleton); + instance = DelegateFactory.Of(_ => creator(request, loggerType), Reuse.Singleton); dictionary.TryAdd(serviceType, instance); } @@ -66,7 +66,7 @@ internal static Rules WithUndefinedTestDependenciesResolver(this Rules rules, Fu if (!dictionary.TryGetValue(serviceType, out var instance)) { - instance = new DelegateFactory(_ => creator(request), Reuse.Singleton); + instance = DelegateFactory.Of(_ => creator(request), Reuse.Singleton); dictionary.TryAdd(serviceType, instance); } diff --git a/test/TestingUtils/AutoNSubstitute/TestLogger.cs b/test/TestingUtils/AutoNSubstitute/TestLogger.cs index e974b4405..cb777ed61 100644 --- a/test/TestingUtils/AutoNSubstitute/TestLogger.cs +++ b/test/TestingUtils/AutoNSubstitute/TestLogger.cs @@ -16,7 +16,7 @@ public TestLogger(IEnumerable loggers) _loggers = loggers; } - public void Log(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func formatter) + public void Log(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func formatter) { foreach (var logger in _loggers) { diff --git a/test/TestingUtils/TestingUtils.csproj b/test/TestingUtils/TestingUtils.csproj index 60d9e1d41..5f9c8393f 100644 --- a/test/TestingUtils/TestingUtils.csproj +++ b/test/TestingUtils/TestingUtils.csproj @@ -1,7 +1,7 @@ - netstandard2.0;netstandard2.1 + netstandard2.0;netstandard2.1;net6.0 false