Changes to make main branch become 8.1 (#4695)

* Changes to make main branch become 8.1

* Branding changes for 8.1
This commit is contained in:
Jose Perez Rodriguez 2023-11-09 14:36:19 -08:00 коммит произвёл GitHub
Родитель 6bf0456059
Коммит 5e6ee76270
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
109 изменённых файлов: 3121 добавлений и 792 удалений

Просмотреть файл

@ -15,7 +15,7 @@
]
},
"microsoft.visualstudio.slngen.tool": {
"version": "11.1.0",
"version": "9.5.3",
"commands": [
"slngen"
]

13
.github/fabricbot.json поставляемый
Просмотреть файл

@ -565,6 +565,17 @@
},
"disabled": false
},
{
"taskType": "trigger",
"capabilityId": "ReleaseAnnouncement",
"subCapability": "ReleaseAnnouncement",
"version": "1.0",
"config": {
"taskName": "Release announcement",
"prReply": "The fix is included in ${pkgName} ${version}.",
"issueReply": "Fixed in ${pkgName} ${version}."
}
},
{
"taskType": "trigger",
"capabilityId": "InPrLabel",
@ -626,7 +637,7 @@
{
"name": "addMilestone",
"parameters": {
"milestoneName": "9.0-preview1"
"milestoneName": "8.0 RC1"
}
}
],

35
.github/workflows/backport.yml поставляемый
Просмотреть файл

@ -1,35 +0,0 @@
name: Backport PR to branch
on:
issue_comment:
types: [created]
schedule:
# once a day at 13:00 UTC to cleanup old runs
- cron: '0 13 * * *'
permissions:
contents: write
issues: write
pull-requests: write
actions: write
jobs:
backport:
if: ${{ contains(github.event.comment.body, '/backport to') || github.event_name == 'schedule' }}
uses: dotnet/arcade/.github/workflows/backport-base.yml@main
with:
pr_description_template: |
Backport of #%source_pr_number% to %target_branch%
/cc %cc_users%
## Customer Impact
## Testing
## Risk
**IMPORTANT**: If this backport is for a servicing release, please verify that:
- The PR target branch is `release/X.0-staging`, not `release/X.0`.
- If the change touches code that ships in a NuGet package, you have added the necessary [package authoring](https://github.com/dotnet/runtime/blob/main/docs/project/library-servicing.md) and gotten it explicitly reviewed.

3
.gitignore поставляемый
Просмотреть файл

@ -38,7 +38,6 @@ bld/
.vs/
.build/
.vscode
!.vscode/settings.json
# MSTest test Results
[Tt]est[Rr]esult*/
@ -309,4 +308,4 @@ BenchmarkDotNet.artifacts/
/_TEST
*.binlog
*.binlog

3
.vscode/settings.json поставляемый
Просмотреть файл

@ -1,3 +0,0 @@
{
"dotnet.automaticallyCreateSolutionInWorkspace": false
}

Просмотреть файл

@ -1,12 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<Import Project="Sdk.props" Sdk="Microsoft.DotNet.Arcade.Sdk" />
<Import Project="$(MSBuildThisFileDirectory)\eng\Net9Workarounds.props" />
<!-- TFMs and their permutations -->
<PropertyGroup>
<TargetFrameworkName>net</TargetFrameworkName>
<TargetFrameworkMajorVersion>9</TargetFrameworkMajorVersion>
<TargetFrameworkMajorVersion>8</TargetFrameworkMajorVersion>
<TargetFrameworkMinorVersion>0</TargetFrameworkMinorVersion>
<TargetFrameworkVersion>$(TargetFrameworkMajorVersion).$(TargetFrameworkMinorVersion)</TargetFrameworkVersion>
@ -14,10 +13,10 @@
<LatestTargetFramework>$(TargetFrameworkName)$(TargetFrameworkVersion)</LatestTargetFramework>
<!-- All the .NET TFMs we're building -->
<SupportedNetCoreTargetFrameworks>$(LatestTargetFramework)</SupportedNetCoreTargetFrameworks>
<NetCoreTargetFrameworks>$(SupportedNetCoreTargetFrameworks);net8.0</NetCoreTargetFrameworks>
<NetCoreTargetFrameworks>$(SupportedNetCoreTargetFrameworks);net6.0</NetCoreTargetFrameworks>
<!-- The minimum supported .NET version for external consumers. This is used for packaging control, see Packaging.targets -->
<MinimumSupportedTfmForPackaging>net8.0</MinimumSupportedTfmForPackaging>
<MinimumSupportedTfmForPackaging>net6.0</MinimumSupportedTfmForPackaging>
<!-- Limit the .NET TFMs when .targetframeworks is defined -->
<!--
@ -28,7 +27,7 @@
<CustomTargetFrameworks Condition="Exists('$(MSBuildThisFileDirectory)\.targetframeworks')">$([System.IO.File]::ReadAllText('$(MSBuildThisFileDirectory)\.targetframeworks').Trim())</CustomTargetFrameworks>
<SupportedNetCoreTargetFrameworks Condition="'$(CustomTargetFrameworks)' != ''">$(LatestTargetFramework)</SupportedNetCoreTargetFrameworks>
<NetCoreTargetFrameworks Condition="'$(CustomTargetFrameworks)' != ''">$(SupportedNetCoreTargetFrameworks)</NetCoreTargetFrameworks>
<NetCoreTargetFrameworks Condition="'$(CustomTargetFrameworks)' != '' AND $(CustomTargetFrameworks.Contains('net8.0'))">$(NetCoreTargetFrameworks);net8.0</NetCoreTargetFrameworks>
<NetCoreTargetFrameworks Condition="'$(CustomTargetFrameworks)' != '' AND $(CustomTargetFrameworks.Contains('net6.0'))">$(NetCoreTargetFrameworks);net6.0</NetCoreTargetFrameworks>
<ConditionalNet462 Condition="'$(CustomTargetFrameworks)' == '' OR $(CustomTargetFrameworks.Contains('net462'))">;net462</ConditionalNet462>
<!-- All the .NET TFMs we're testing against -->

Просмотреть файл

@ -8,8 +8,6 @@
<Import Project="$(MSBuildThisFileDirectory)\eng\MSBuild\Generators.targets" />
<Import Project="$(MSBuildThisFileDirectory)\eng\MSBuild\ProjectStaging.targets" />
<Import Project="$(MSBuildThisFileDirectory)\eng\Net9Workarounds.targets" />
<!-- Warning stuff -->
<PropertyGroup>
<MSBuildWarningsAsMessages>$(MSBuildWarningsAsMessages);NETSDK1138;MSB3270</MSBuildWarningsAsMessages>

Просмотреть файл

@ -2,20 +2,26 @@
<configuration>
<packageSources>
<clear />
<!--Begin: Package sources managed by Dependency Flow automation. Do not edit the sources below.-->
<!-- Begin: Package sources from dotnet-runtime -->
<add key="darc-pub-dotnet-runtime-488a8a3" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-runtime-488a8a35/nuget/v3/index.json" />
<!-- End: Package sources from dotnet-runtime -->
<!--End: Package sources managed by Dependency Flow automation. Do not edit the sources above.-->
<!-- Arcade -->
<add key="dotnet-public" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json" />
<add key="dotnet-eng" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json" />
<add key="dotnet-tools" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json" />
<add key="dotnet8" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json" />
<add key="dotnet8-transport" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8-transport/nuget/v3/index.json" />
<add key="dotnet9" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v3/index.json" />
<add key="dotnet9-transport" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9-transport/nuget/v3/index.json" />
<!-- Used for the Rich Navigation indexing task -->
<add key="richnav" value="https://pkgs.dev.azure.com/azure-public/vside/_packaging/vs-buildservices/nuget/v3/index.json" />
</packageSources>
<!-- Define mappings by adding package patterns beneath the target source.
https://aka.ms/nuget-package-source-mapping -->
<packageSourceMapping>
<packageSource key="darc-pub-dotnet-runtime-488a8a3">
<package pattern="*" />
</packageSource>
<packageSource key="dotnet-public">
<package pattern="*" />
</packageSource>
@ -31,12 +37,6 @@
<packageSource key="dotnet8-transport">
<package pattern="*" />
</packageSource>
<packageSource key="dotnet9">
<package pattern="*" />
</packageSource>
<packageSource key="dotnet9-transport">
<package pattern="*" />
</packageSource>
<packageSource key="richnav">
<package pattern="*" />
</packageSource>

Просмотреть файл

@ -45,8 +45,8 @@ Here are few commands that you will likely use the most:
- `build.sh --restore`: to install the required .NET SDK, .NET tools and the toolset. This is equivalent to running `./restore.sh`.
- `build.sh --build`: to build the solution<sup>1</sup>.
- `build.sh --test`: to run all unit tests in the solution<sup>1</sup>.
- `build.sh --vs <keywords>`: to generate a "filtered" solution and save it as `SDK.sln`. It also performs the "restore" operation. Keywords can be any part of the name or path of project files you want to include. For example: `./build.sh --vs Http,Fakes,AspNetCore`.<br />
If for some reason you wish to generate a solution with all projects you can pass `*` for the keyword, e.g.: `./build.sh -vs '*'` (Note: you have to escape the asterisk or use `set -f` to turn off expansion).<br />
- `build.sh --vs <keywords>`: to generate a "filtered" solution and save it as `SDK.sln`. It also performs the "restore" operation. For example: `./build.sh --vs Http,Fakes`.<br />
If for some reason you wish to generate a solution with all projects you can pass `*` for the keyword, e.g.: `./build.sh --vs '*'` (Note: you have to escape the asterisk or use `set -f` to turn off expansion).<br />
> Under the hood, this invokes `scripts/Slngen.ps1` script, which in turn executes [slngen tool][slngen-tool]. If you want to customize how the "filtered" solution is generated, you will need to invoke `scripts/Slngen.ps1` script directly.<br />
Run `./scripts/Slngen.ps1 -help` for more details.

Просмотреть файл

@ -1,7 +0,0 @@
<Project>
<PropertyGroup>
<!-- Disable IsTrimmable on non-DefaultNetCoreTargetFrameworks even if explicitly enabled or else we'll get NETSDK1195 and NETSDK1210 errors -->
<IsTrimmable>false</IsTrimmable>
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
</PropertyGroup>
</Project>

Просмотреть файл

@ -1,67 +0,0 @@
<Project>
<PropertyGroup>
<!-- Workaround while there is no SDK available that understands the TFM; suppress unsupported version errors. -->
<NETCoreAppMaximumVersion>99.9</NETCoreAppMaximumVersion>
<UpdateAspNetCoreKnownFramework
Condition=" '$(UpdateAspNetCoreKnownFramework)' == '' ">true</UpdateAspNetCoreKnownFramework>
</PropertyGroup>
<ItemGroup>
<!-- Workaround when there is no vNext SDK available; copy known packs info from 8.0. -->
<KnownAppHostPack Include="@(KnownAppHostPack->WithMetadataValue('TargetFramework', 'net8.0'))"
TargetFramework="$(LatestTargetFramework)"
Condition="'@(KnownAppHostPack->Count())' != '0' AND
!(@(KnownAppHostPack->AnyHaveMetadataValue('TargetFramework', '$(LatestTargetFramework)')))" />
<KnownRuntimePack Include="@(KnownRuntimePack->WithMetadataValue('TargetFramework', 'net8.0'))"
TargetFramework="$(LatestTargetFramework)"
Condition="'@(KnownRuntimePack->Count())' != '0' AND
!(@(KnownRuntimePack->AnyHaveMetadataValue('TargetFramework', '$(LatestTargetFramework)')))" />
<KnownFrameworkReference Include="@(KnownFrameworkReference->WithMetadataValue('TargetFramework', 'net8.0'))"
TargetFramework="$(LatestTargetFramework)"
Condition="'@(KnownFrameworkReference->Count())' != '0' AND
!(@(KnownFrameworkReference->AnyHaveMetadataValue('TargetFramework', '$(LatestTargetFramework)')))" />
<KnownFrameworkReference Update="Microsoft.NETCore.App">
<LatestRuntimeFrameworkVersion
Condition=" '%(TargetFramework)' == '$(LatestTargetFramework)' ">$(MicrosoftNETCoreAppRuntimewinx64Version)</LatestRuntimeFrameworkVersion>
<TargetingPackVersion
Condition=" '%(TargetFramework)' == '$(LatestTargetFramework)' ">$(MicrosoftNETCoreAppRefVersion)</TargetingPackVersion>
<!--
Change the default shared framework version only when _not_ servicing. Avoid bumping version used in most
projects.
-->
<DefaultRuntimeFrameworkVersion Condition=" '$(IsServicingBuild)' != 'true' AND
'%(TargetFramework)' == '$(LatestTargetFramework)'">$(MicrosoftNETCoreAppRuntimeVersion)</DefaultRuntimeFrameworkVersion>
</KnownFrameworkReference>
<KnownFrameworkReference Update="Microsoft.AspNetCore.App">
<LatestRuntimeFrameworkVersion
Condition=" '%(TargetFramework)' == '$(LatestTargetFramework)' ">$(MicrosoftAspNetCoreAppRuntimewinx64Version)</LatestRuntimeFrameworkVersion>
<TargetingPackVersion
Condition=" '%(TargetFramework)' == '$(LatestTargetFramework)' ">$(MicrosoftAspNetCoreAppRefVersion)</TargetingPackVersion>
<!--
Change the default shared framework version only when _not_ servicing. Avoid bumping version used in most
projects.
-->
<DefaultRuntimeFrameworkVersion Condition=" '$(IsServicingBuild)' != 'true' AND
'%(TargetFramework)' == '$(LatestTargetFramework)'">$(MicrosoftNETCoreAppRuntimeVersion)</DefaultRuntimeFrameworkVersion>
</KnownFrameworkReference>
<KnownAppHostPack Update="Microsoft.NETCore.App">
<AppHostPackVersion
Condition=" '%(TargetFramework)' == '$(LatestTargetFramework)' ">$(MicrosoftNETCoreAppRuntimewinx64Version)</AppHostPackVersion>
</KnownAppHostPack>
<KnownRuntimePack Update="Microsoft.NETCore.App">
<LatestRuntimeFrameworkVersion
Condition=" '%(TargetFramework)' == '$(LatestTargetFramework)' ">$(MicrosoftNETCoreAppRuntimewinx64Version)</LatestRuntimeFrameworkVersion>
</KnownRuntimePack>
<KnownRuntimePack Update="Microsoft.AspNetCore.App">
<LatestRuntimeFrameworkVersion
Condition=" '%(TargetFramework)' == '$(LatestTargetFramework)' ">$(MicrosoftAspNetCoreAppRuntimewinx64Version)</LatestRuntimeFrameworkVersion>
</KnownRuntimePack>
</ItemGroup>
</Project>

Просмотреть файл

@ -1,198 +1,182 @@
<Dependencies>
<ProductDependencies>
<Dependency Name="Microsoft.Bcl.TimeProvider" Version="9.0.0-alpha.1.23558.1" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Dependency Name="Microsoft.Bcl.TimeProvider" Version="8.0.0" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>dc9c9d5f9e23ff6aa0b99af8f6c410a0558fadaf</Sha>
<Sha>488a8a3521610422e8fbe22d5cc66127f3dce3dc</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Caching.Abstractions" Version="9.0.0-alpha.1.23558.1" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Dependency Name="Microsoft.Extensions.Caching.Abstractions" Version="8.0.0" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>dc9c9d5f9e23ff6aa0b99af8f6c410a0558fadaf</Sha>
<Sha>488a8a3521610422e8fbe22d5cc66127f3dce3dc</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Caching.Memory" Version="9.0.0-alpha.1.23558.1" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Dependency Name="Microsoft.Extensions.Caching.Memory" Version="8.0.0" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>dc9c9d5f9e23ff6aa0b99af8f6c410a0558fadaf</Sha>
<Sha>488a8a3521610422e8fbe22d5cc66127f3dce3dc</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Configuration.Abstractions" Version="9.0.0-alpha.1.23558.1" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Dependency Name="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>dc9c9d5f9e23ff6aa0b99af8f6c410a0558fadaf</Sha>
<Sha>488a8a3521610422e8fbe22d5cc66127f3dce3dc</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Configuration.Binder" Version="9.0.0-alpha.1.23558.1" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Dependency Name="Microsoft.Extensions.Configuration.Binder" Version="8.0.0" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>dc9c9d5f9e23ff6aa0b99af8f6c410a0558fadaf</Sha>
<Sha>488a8a3521610422e8fbe22d5cc66127f3dce3dc</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Configuration.CommandLine" Version="9.0.0-alpha.1.23558.1" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Dependency Name="Microsoft.Extensions.Configuration.CommandLine" Version="8.0.0" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>dc9c9d5f9e23ff6aa0b99af8f6c410a0558fadaf</Sha>
<Sha>488a8a3521610422e8fbe22d5cc66127f3dce3dc</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Configuration.Json" Version="9.0.0-alpha.1.23558.1" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Dependency Name="Microsoft.Extensions.Configuration.Json" Version="8.0.0" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>dc9c9d5f9e23ff6aa0b99af8f6c410a0558fadaf</Sha>
<Sha>488a8a3521610422e8fbe22d5cc66127f3dce3dc</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Configuration" Version="9.0.0-alpha.1.23558.1" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Dependency Name="Microsoft.Extensions.Configuration" Version="8.0.0" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>dc9c9d5f9e23ff6aa0b99af8f6c410a0558fadaf</Sha>
<Sha>488a8a3521610422e8fbe22d5cc66127f3dce3dc</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.0-alpha.1.23558.1" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Dependency Name="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>dc9c9d5f9e23ff6aa0b99af8f6c410a0558fadaf</Sha>
<Sha>488a8a3521610422e8fbe22d5cc66127f3dce3dc</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.DependencyInjection" Version="9.0.0-alpha.1.23558.1" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Dependency Name="Microsoft.Extensions.DependencyInjection" Version="8.0.0" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>dc9c9d5f9e23ff6aa0b99af8f6c410a0558fadaf</Sha>
<Sha>488a8a3521610422e8fbe22d5cc66127f3dce3dc</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Hosting.Abstractions" Version="9.0.0-alpha.1.23558.1" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Dependency Name="Microsoft.Extensions.Diagnostics" Version="8.0.0" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>dc9c9d5f9e23ff6aa0b99af8f6c410a0558fadaf</Sha>
<Sha>488a8a3521610422e8fbe22d5cc66127f3dce3dc</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Diagnostics" Version="9.0.0-alpha.1.23558.1" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Dependency Name="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>dc9c9d5f9e23ff6aa0b99af8f6c410a0558fadaf</Sha>
<Sha>488a8a3521610422e8fbe22d5cc66127f3dce3dc</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Hosting" Version="9.0.0-alpha.1.23558.1" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Dependency Name="Microsoft.Extensions.Hosting" Version="8.0.0" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>dc9c9d5f9e23ff6aa0b99af8f6c410a0558fadaf</Sha>
<Sha>488a8a3521610422e8fbe22d5cc66127f3dce3dc</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Http" Version="9.0.0-alpha.1.23558.1" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Dependency Name="Microsoft.Extensions.Http" Version="8.0.0" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>dc9c9d5f9e23ff6aa0b99af8f6c410a0558fadaf</Sha>
<Sha>488a8a3521610422e8fbe22d5cc66127f3dce3dc</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Logging.Abstractions" Version="9.0.0-alpha.1.23558.1" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Dependency Name="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>dc9c9d5f9e23ff6aa0b99af8f6c410a0558fadaf</Sha>
<Sha>488a8a3521610422e8fbe22d5cc66127f3dce3dc</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Logging.Configuration" Version="9.0.0-alpha.1.23558.1" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Dependency Name="Microsoft.Extensions.Logging.Configuration" Version="8.0.0" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>dc9c9d5f9e23ff6aa0b99af8f6c410a0558fadaf</Sha>
<Sha>488a8a3521610422e8fbe22d5cc66127f3dce3dc</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Logging.Console" Version="9.0.0-alpha.1.23558.1" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Dependency Name="Microsoft.Extensions.Logging.Console" Version="8.0.0" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>dc9c9d5f9e23ff6aa0b99af8f6c410a0558fadaf</Sha>
<Sha>488a8a3521610422e8fbe22d5cc66127f3dce3dc</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Logging" Version="9.0.0-alpha.1.23558.1" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Dependency Name="Microsoft.Extensions.Logging" Version="8.0.0" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>dc9c9d5f9e23ff6aa0b99af8f6c410a0558fadaf</Sha>
<Sha>488a8a3521610422e8fbe22d5cc66127f3dce3dc</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Options.ConfigurationExtensions" Version="9.0.0-alpha.1.23558.1" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Dependency Name="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>dc9c9d5f9e23ff6aa0b99af8f6c410a0558fadaf</Sha>
<Sha>488a8a3521610422e8fbe22d5cc66127f3dce3dc</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Options.DataAnnotations" Version="9.0.0-alpha.1.23558.1" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Dependency Name="Microsoft.Extensions.Options.DataAnnotations" Version="8.0.0" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>dc9c9d5f9e23ff6aa0b99af8f6c410a0558fadaf</Sha>
<Sha>488a8a3521610422e8fbe22d5cc66127f3dce3dc</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Options" Version="9.0.0-alpha.1.23558.1" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Dependency Name="Microsoft.Extensions.Options" Version="8.0.0" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>dc9c9d5f9e23ff6aa0b99af8f6c410a0558fadaf</Sha>
<Sha>488a8a3521610422e8fbe22d5cc66127f3dce3dc</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Primitives" Version="9.0.0-alpha.1.23558.1" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Dependency Name="Microsoft.Extensions.Primitives" Version="8.0.0" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>dc9c9d5f9e23ff6aa0b99af8f6c410a0558fadaf</Sha>
<Sha>488a8a3521610422e8fbe22d5cc66127f3dce3dc</Sha>
</Dependency>
<Dependency Name="Microsoft.NETCore.App.Ref" Version="9.0.0-alpha.1.23558.1" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Dependency Name="System.Collections.Immutable" Version="8.0.0" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>dc9c9d5f9e23ff6aa0b99af8f6c410a0558fadaf</Sha>
<Sha>488a8a3521610422e8fbe22d5cc66127f3dce3dc</Sha>
</Dependency>
<!--
Win-x64 is used here because we have picked an arbitrary runtime identifier to flow the version of the latest NETCore.App runtime.
All Runtime.$rid packages should have the same version.
-->
<Dependency Name="Microsoft.NETCore.App.Runtime.win-x64" Version="9.0.0-alpha.1.23558.1" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Dependency Name="System.Configuration.ConfigurationManager" Version="8.0.0" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>dc9c9d5f9e23ff6aa0b99af8f6c410a0558fadaf</Sha>
<Sha>488a8a3521610422e8fbe22d5cc66127f3dce3dc</Sha>
</Dependency>
<Dependency Name="System.Collections.Immutable" Version="9.0.0-alpha.1.23558.1" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Dependency Name="System.Diagnostics.DiagnosticSource" Version="8.0.0" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>dc9c9d5f9e23ff6aa0b99af8f6c410a0558fadaf</Sha>
<Sha>488a8a3521610422e8fbe22d5cc66127f3dce3dc</Sha>
</Dependency>
<Dependency Name="System.Configuration.ConfigurationManager" Version="9.0.0-alpha.1.23558.1" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Dependency Name="System.Diagnostics.PerformanceCounter" Version="8.0.0" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>dc9c9d5f9e23ff6aa0b99af8f6c410a0558fadaf</Sha>
<Sha>488a8a3521610422e8fbe22d5cc66127f3dce3dc</Sha>
</Dependency>
<Dependency Name="System.Diagnostics.DiagnosticSource" Version="9.0.0-alpha.1.23558.1" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Dependency Name="System.IO.Hashing" Version="8.0.0" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>dc9c9d5f9e23ff6aa0b99af8f6c410a0558fadaf</Sha>
<Sha>488a8a3521610422e8fbe22d5cc66127f3dce3dc</Sha>
</Dependency>
<Dependency Name="System.Diagnostics.PerformanceCounter" Version="9.0.0-alpha.1.23558.1" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Dependency Name="System.Net.Http.Json" Version="8.0.0" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>dc9c9d5f9e23ff6aa0b99af8f6c410a0558fadaf</Sha>
<Sha>488a8a3521610422e8fbe22d5cc66127f3dce3dc</Sha>
</Dependency>
<Dependency Name="System.IO.Hashing" Version="9.0.0-alpha.1.23558.1" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Dependency Name="System.Security.Cryptography.Pkcs" Version="8.0.0" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>dc9c9d5f9e23ff6aa0b99af8f6c410a0558fadaf</Sha>
<Sha>488a8a3521610422e8fbe22d5cc66127f3dce3dc</Sha>
</Dependency>
<Dependency Name="System.Net.Http.Json" Version="9.0.0-alpha.1.23558.1" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Dependency Name="System.Security.Cryptography.Xml" Version="8.0.0" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>dc9c9d5f9e23ff6aa0b99af8f6c410a0558fadaf</Sha>
<Sha>488a8a3521610422e8fbe22d5cc66127f3dce3dc</Sha>
</Dependency>
<Dependency Name="System.Security.Cryptography.Pkcs" Version="9.0.0-alpha.1.23558.1" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Dependency Name="System.Text.Encodings.Web" Version="8.0.0" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>dc9c9d5f9e23ff6aa0b99af8f6c410a0558fadaf</Sha>
<Sha>488a8a3521610422e8fbe22d5cc66127f3dce3dc</Sha>
</Dependency>
<Dependency Name="System.Security.Cryptography.Xml" Version="9.0.0-alpha.1.23558.1" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Dependency Name="System.Text.Json" Version="8.0.0" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>dc9c9d5f9e23ff6aa0b99af8f6c410a0558fadaf</Sha>
<Sha>488a8a3521610422e8fbe22d5cc66127f3dce3dc</Sha>
</Dependency>
<Dependency Name="System.Text.Encodings.Web" Version="9.0.0-alpha.1.23558.1" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Dependency Name="System.Runtime.Caching" Version="8.0.0" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>dc9c9d5f9e23ff6aa0b99af8f6c410a0558fadaf</Sha>
<Sha>488a8a3521610422e8fbe22d5cc66127f3dce3dc</Sha>
</Dependency>
<Dependency Name="System.Text.Json" Version="9.0.0-alpha.1.23558.1" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>dc9c9d5f9e23ff6aa0b99af8f6c410a0558fadaf</Sha>
</Dependency>
<Dependency Name="System.Runtime.Caching" Version="9.0.0-alpha.1.23558.1" CoherentParentDependency="Microsoft.AspNetCore.App.Runtime.win-x64">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>dc9c9d5f9e23ff6aa0b99af8f6c410a0558fadaf</Sha>
</Dependency>
<Dependency Name="Microsoft.AspNetCore.App.Ref" Version="9.0.0-alpha.1.23559.3">
<Dependency Name="Microsoft.AspNetCore.App.Runtime.win-x64" Version="8.0.0-rtm.23524.15">
<Uri>https://github.com/dotnet/aspnetcore</Uri>
<Sha>1ab87c942788c9b35b1967f5209b22e5f357e901</Sha>
<Sha>815eb281ecad13eb69cf50516ac7f534b947f2b0</Sha>
</Dependency>
<Dependency Name="Microsoft.AspNetCore.App.Runtime.win-x64" Version="9.0.0-alpha.1.23559.3">
<Dependency Name="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.0-rtm.23524.15">
<Uri>https://github.com/dotnet/aspnetcore</Uri>
<Sha>1ab87c942788c9b35b1967f5209b22e5f357e901</Sha>
<Sha>815eb281ecad13eb69cf50516ac7f534b947f2b0</Sha>
</Dependency>
<Dependency Name="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.0-alpha.1.23559.3">
<Dependency Name="Microsoft.AspNetCore.TestHost" Version="8.0.0-rtm.23524.15">
<Uri>https://github.com/dotnet/aspnetcore</Uri>
<Sha>1ab87c942788c9b35b1967f5209b22e5f357e901</Sha>
<Sha>815eb281ecad13eb69cf50516ac7f534b947f2b0</Sha>
</Dependency>
<Dependency Name="Microsoft.AspNetCore.TestHost" Version="9.0.0-alpha.1.23559.3">
<Dependency Name="Microsoft.Extensions.Caching.StackExchangeRedis" Version="8.0.0-rtm.23524.15">
<Uri>https://github.com/dotnet/aspnetcore</Uri>
<Sha>1ab87c942788c9b35b1967f5209b22e5f357e901</Sha>
<Sha>815eb281ecad13eb69cf50516ac7f534b947f2b0</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Caching.StackExchangeRedis" Version="9.0.0-alpha.1.23559.3">
<Dependency Name="Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions" Version="8.0.0-rtm.23524.15">
<Uri>https://github.com/dotnet/aspnetcore</Uri>
<Sha>1ab87c942788c9b35b1967f5209b22e5f357e901</Sha>
<Sha>815eb281ecad13eb69cf50516ac7f534b947f2b0</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions" Version="9.0.0-alpha.1.23559.3">
<Dependency Name="Microsoft.Extensions.Diagnostics.HealthChecks" Version="8.0.0-rtm.23524.15">
<Uri>https://github.com/dotnet/aspnetcore</Uri>
<Sha>1ab87c942788c9b35b1967f5209b22e5f357e901</Sha>
<Sha>815eb281ecad13eb69cf50516ac7f534b947f2b0</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Diagnostics.HealthChecks" Version="9.0.0-alpha.1.23559.3">
<Dependency Name="Microsoft.Extensions.Features" Version="8.0.0-rtm.23524.15">
<Uri>https://github.com/dotnet/aspnetcore</Uri>
<Sha>1ab87c942788c9b35b1967f5209b22e5f357e901</Sha>
<Sha>815eb281ecad13eb69cf50516ac7f534b947f2b0</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Features" Version="9.0.0-alpha.1.23559.3">
<Dependency Name="Microsoft.Extensions.Http.Polly" Version="8.0.0-rtm.23524.15">
<Uri>https://github.com/dotnet/aspnetcore</Uri>
<Sha>1ab87c942788c9b35b1967f5209b22e5f357e901</Sha>
<Sha>815eb281ecad13eb69cf50516ac7f534b947f2b0</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Http.Polly" Version="9.0.0-alpha.1.23559.3">
<Dependency Name="Microsoft.Extensions.ObjectPool" Version="8.0.0-rtm.23524.15">
<Uri>https://github.com/dotnet/aspnetcore</Uri>
<Sha>1ab87c942788c9b35b1967f5209b22e5f357e901</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.ObjectPool" Version="9.0.0-alpha.1.23559.3">
<Uri>https://github.com/dotnet/aspnetcore</Uri>
<Sha>1ab87c942788c9b35b1967f5209b22e5f357e901</Sha>
<Sha>815eb281ecad13eb69cf50516ac7f534b947f2b0</Sha>
</Dependency>
</ProductDependencies>
<ToolsetDependencies>
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="9.0.0-beta.23557.7">
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="8.0.0-beta.23525.4">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>aa0317458d29ec79935ca04fa47d3a6f14a0944f</Sha>
<Sha>a57022b44f3ff23de925530ea1d27da9701aed57</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.Helix.Sdk" Version="9.0.0-beta.23557.7">
<Dependency Name="Microsoft.DotNet.Helix.Sdk" Version="8.0.0-beta.23525.4">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>aa0317458d29ec79935ca04fa47d3a6f14a0944f</Sha>
<Sha>a57022b44f3ff23de925530ea1d27da9701aed57</Sha>
</Dependency>
</ToolsetDependencies>
</Dependencies>

Просмотреть файл

@ -1,18 +1,18 @@
<Project>
<PropertyGroup Label="Version settings">
<MajorVersion>9</MajorVersion>
<MinorVersion>0</MinorVersion>
<MajorVersion>8</MajorVersion>
<MinorVersion>1</MinorVersion>
<PatchVersion>0</PatchVersion>
<PreReleaseVersionLabel>alpha</PreReleaseVersionLabel>
<PreReleaseVersionIteration>1</PreReleaseVersionIteration>
<PreReleaseVersionLabel>preview</PreReleaseVersionLabel>
<PreReleaseVersionIteration>
</PreReleaseVersionIteration>
<VersionPrefix>$(MajorVersion).$(MinorVersion).$(PatchVersion)</VersionPrefix>
<ValidateBaseline>true</ValidateBaseline>
<AssemblyVersion>$(MajorVersion).$(MinorVersion).0.0</AssemblyVersion>
<IsServicingBuild Condition=" '$(PreReleaseVersionLabel)' == 'servicing' ">true</IsServicingBuild>
<!--
When StabilizePackageVersion is set to 'true', this branch will produce stable outputs for 'Shipping' packages
When DotNetFinalVersionKind is set to 'release', this branch will produce stable outputs for 'Shipping' packages
-->
<StabilizePackageVersion Condition="'$(StabilizePackageVersion)' == ''">false</StabilizePackageVersion>
<DotNetFinalVersionKind />
<!-- Enabling this rule will cause build failures on undocumented public APIs. -->
<SkipArcadeNoWarnCS1591>true</SkipArcadeNoWarnCS1591>
</PropertyGroup>
@ -28,52 +28,49 @@
-->
<PropertyGroup Label="Automated">
<!-- Packages from dotnet/runtime -->
<MicrosoftBclTimeProviderVersion>9.0.0-alpha.1.23558.1</MicrosoftBclTimeProviderVersion>
<MicrosoftExtensionsCachingAbstractionsVersion>9.0.0-alpha.1.23558.1</MicrosoftExtensionsCachingAbstractionsVersion>
<MicrosoftExtensionsCachingMemoryVersion>9.0.0-alpha.1.23558.1</MicrosoftExtensionsCachingMemoryVersion>
<MicrosoftExtensionsConfigurationAbstractionsVersion>9.0.0-alpha.1.23558.1</MicrosoftExtensionsConfigurationAbstractionsVersion>
<MicrosoftExtensionsConfigurationBinderVersion>9.0.0-alpha.1.23558.1</MicrosoftExtensionsConfigurationBinderVersion>
<MicrosoftExtensionsConfigurationCommandLineVersion>9.0.0-alpha.1.23558.1</MicrosoftExtensionsConfigurationCommandLineVersion>
<MicrosoftExtensionsConfigurationJsonVersion>9.0.0-alpha.1.23558.1</MicrosoftExtensionsConfigurationJsonVersion>
<MicrosoftExtensionsConfigurationVersion>9.0.0-alpha.1.23558.1</MicrosoftExtensionsConfigurationVersion>
<MicrosoftExtensionsDependencyInjectionAbstractionsVersion>9.0.0-alpha.1.23558.1</MicrosoftExtensionsDependencyInjectionAbstractionsVersion>
<MicrosoftExtensionsDependencyInjectionVersion>9.0.0-alpha.1.23558.1</MicrosoftExtensionsDependencyInjectionVersion>
<MicrosoftExtensionsDiagnosticsVersion>9.0.0-alpha.1.23558.1</MicrosoftExtensionsDiagnosticsVersion>
<MicrosoftExtensionsHostingAbstractionsVersion>9.0.0-alpha.1.23558.1</MicrosoftExtensionsHostingAbstractionsVersion>
<MicrosoftExtensionsHostingVersion>9.0.0-alpha.1.23558.1</MicrosoftExtensionsHostingVersion>
<MicrosoftExtensionsHttpVersion>9.0.0-alpha.1.23558.1</MicrosoftExtensionsHttpVersion>
<MicrosoftExtensionsLoggingAbstractionsVersion>9.0.0-alpha.1.23558.1</MicrosoftExtensionsLoggingAbstractionsVersion>
<MicrosoftExtensionsLoggingConfigurationVersion>9.0.0-alpha.1.23558.1</MicrosoftExtensionsLoggingConfigurationVersion>
<MicrosoftExtensionsLoggingConsoleVersion>9.0.0-alpha.1.23558.1</MicrosoftExtensionsLoggingConsoleVersion>
<MicrosoftExtensionsLoggingVersion>9.0.0-alpha.1.23558.1</MicrosoftExtensionsLoggingVersion>
<MicrosoftExtensionsOptionsConfigurationExtensionsVersion>9.0.0-alpha.1.23558.1</MicrosoftExtensionsOptionsConfigurationExtensionsVersion>
<MicrosoftExtensionsOptionsDataAnnotationsVersion>9.0.0-alpha.1.23558.1</MicrosoftExtensionsOptionsDataAnnotationsVersion>
<MicrosoftExtensionsOptionsVersion>9.0.0-alpha.1.23558.1</MicrosoftExtensionsOptionsVersion>
<MicrosoftExtensionsPrimitivesVersion>9.0.0-alpha.1.23558.1</MicrosoftExtensionsPrimitivesVersion>
<MicrosoftNETCoreAppRefVersion>9.0.0-alpha.1.23558.1</MicrosoftNETCoreAppRefVersion>
<MicrosoftNETCoreAppRuntimewinx64Version>9.0.0-alpha.1.23558.1</MicrosoftNETCoreAppRuntimewinx64Version>
<SystemCollectionsImmutableVersion>9.0.0-alpha.1.23558.1</SystemCollectionsImmutableVersion>
<SystemConfigurationConfigurationManagerVersion>9.0.0-alpha.1.23558.1</SystemConfigurationConfigurationManagerVersion>
<SystemDiagnosticsDiagnosticSourceVersion>9.0.0-alpha.1.23558.1</SystemDiagnosticsDiagnosticSourceVersion>
<SystemDiagnosticsPerformanceCounterVersion>9.0.0-alpha.1.23558.1</SystemDiagnosticsPerformanceCounterVersion>
<SystemIOHashingVersion>9.0.0-alpha.1.23558.1</SystemIOHashingVersion>
<SystemNetHttpJsonVersion>9.0.0-alpha.1.23558.1</SystemNetHttpJsonVersion>
<SystemRuntimeCachingVersion>9.0.0-alpha.1.23558.1</SystemRuntimeCachingVersion>
<SystemSecurityCryptographyPkcsVersion>9.0.0-alpha.1.23558.1</SystemSecurityCryptographyPkcsVersion>
<SystemSecurityCryptographyXmlVersion>9.0.0-alpha.1.23558.1</SystemSecurityCryptographyXmlVersion>
<SystemTextEncodingsWebVersion>9.0.0-alpha.1.23558.1</SystemTextEncodingsWebVersion>
<SystemTextJsonVersion>9.0.0-alpha.1.23558.1</SystemTextJsonVersion>
<MicrosoftBclTimeProviderVersion>8.0.0</MicrosoftBclTimeProviderVersion>
<MicrosoftExtensionsCachingAbstractionsVersion>8.0.0</MicrosoftExtensionsCachingAbstractionsVersion>
<MicrosoftExtensionsCachingMemoryVersion>8.0.0</MicrosoftExtensionsCachingMemoryVersion>
<MicrosoftExtensionsConfigurationAbstractionsVersion>8.0.0</MicrosoftExtensionsConfigurationAbstractionsVersion>
<MicrosoftExtensionsConfigurationBinderVersion>8.0.0</MicrosoftExtensionsConfigurationBinderVersion>
<MicrosoftExtensionsConfigurationCommandLineVersion>8.0.0</MicrosoftExtensionsConfigurationCommandLineVersion>
<MicrosoftExtensionsConfigurationJsonVersion>8.0.0</MicrosoftExtensionsConfigurationJsonVersion>
<MicrosoftExtensionsConfigurationVersion>8.0.0</MicrosoftExtensionsConfigurationVersion>
<MicrosoftExtensionsDependencyInjectionAbstractionsVersion>8.0.0</MicrosoftExtensionsDependencyInjectionAbstractionsVersion>
<MicrosoftExtensionsDependencyInjectionVersion>8.0.0</MicrosoftExtensionsDependencyInjectionVersion>
<MicrosoftExtensionsDiagnosticsVersion>8.0.0</MicrosoftExtensionsDiagnosticsVersion>
<MicrosoftExtensionsHostingAbstractionsVersion>8.0.0</MicrosoftExtensionsHostingAbstractionsVersion>
<MicrosoftExtensionsHostingVersion>8.0.0</MicrosoftExtensionsHostingVersion>
<MicrosoftExtensionsHttpVersion>8.0.0</MicrosoftExtensionsHttpVersion>
<MicrosoftExtensionsLoggingAbstractionsVersion>8.0.0</MicrosoftExtensionsLoggingAbstractionsVersion>
<MicrosoftExtensionsLoggingConfigurationVersion>8.0.0</MicrosoftExtensionsLoggingConfigurationVersion>
<MicrosoftExtensionsLoggingConsoleVersion>8.0.0</MicrosoftExtensionsLoggingConsoleVersion>
<MicrosoftExtensionsLoggingVersion>8.0.0</MicrosoftExtensionsLoggingVersion>
<MicrosoftExtensionsOptionsConfigurationExtensionsVersion>8.0.0</MicrosoftExtensionsOptionsConfigurationExtensionsVersion>
<MicrosoftExtensionsOptionsDataAnnotationsVersion>8.0.0</MicrosoftExtensionsOptionsDataAnnotationsVersion>
<MicrosoftExtensionsOptionsVersion>8.0.0</MicrosoftExtensionsOptionsVersion>
<MicrosoftExtensionsPrimitivesVersion>8.0.0</MicrosoftExtensionsPrimitivesVersion>
<SystemCollectionsImmutableVersion>8.0.0</SystemCollectionsImmutableVersion>
<SystemConfigurationConfigurationManagerVersion>8.0.0</SystemConfigurationConfigurationManagerVersion>
<SystemDiagnosticsDiagnosticSourceVersion>8.0.0</SystemDiagnosticsDiagnosticSourceVersion>
<SystemDiagnosticsPerformanceCounterVersion>8.0.0</SystemDiagnosticsPerformanceCounterVersion>
<SystemIOHashingVersion>8.0.0</SystemIOHashingVersion>
<SystemNetHttpJsonVersion>8.0.0</SystemNetHttpJsonVersion>
<SystemSecurityCryptographyPkcsVersion>8.0.0</SystemSecurityCryptographyPkcsVersion>
<SystemSecurityCryptographyXmlVersion>8.0.0</SystemSecurityCryptographyXmlVersion>
<SystemTextEncodingsWebVersion>8.0.0</SystemTextEncodingsWebVersion>
<SystemTextJsonVersion>8.0.0</SystemTextJsonVersion>
<SystemRuntimeCachingVersion>8.0.0</SystemRuntimeCachingVersion>
<!-- Dependencies from https://github.com/aspnet/AspNetCore -->
<MicrosoftAspNetCoreAppRefVersion>9.0.0-alpha.1.23559.3</MicrosoftAspNetCoreAppRefVersion>
<MicrosoftAspNetCoreAppRuntimewinx64Version>9.0.0-alpha.1.23559.3</MicrosoftAspNetCoreAppRuntimewinx64Version>
<MicrosoftAspNetCoreMvcTestingVersion>9.0.0-alpha.1.23559.3</MicrosoftAspNetCoreMvcTestingVersion>
<MicrosoftAspNetCoreTestHostVersion>9.0.0-alpha.1.23559.3</MicrosoftAspNetCoreTestHostVersion>
<MicrosoftExtensionsCachingStackExchangeRedisVersion>9.0.0-alpha.1.23559.3</MicrosoftExtensionsCachingStackExchangeRedisVersion>
<MicrosoftExtensionsDiagnosticsHealthChecksAbstractionsVersion>9.0.0-alpha.1.23559.3</MicrosoftExtensionsDiagnosticsHealthChecksAbstractionsVersion>
<MicrosoftExtensionsDiagnosticsHealthChecksVersion>9.0.0-alpha.1.23559.3</MicrosoftExtensionsDiagnosticsHealthChecksVersion>
<MicrosoftExtensionsFeaturesVersion>9.0.0-alpha.1.23559.3</MicrosoftExtensionsFeaturesVersion>
<MicrosoftExtensionsHttpPollyVersion>9.0.0-alpha.1.23559.3</MicrosoftExtensionsHttpPollyVersion>
<MicrosoftExtensionsObjectPoolVersion>9.0.0-alpha.1.23559.3</MicrosoftExtensionsObjectPoolVersion>
<MicrosoftAspNetCoreAppRuntimewinx64Version>8.0.0-rtm.23524.15</MicrosoftAspNetCoreAppRuntimewinx64Version>
<MicrosoftAspNetCoreMvcTestingVersion>8.0.0-rtm.23524.15</MicrosoftAspNetCoreMvcTestingVersion>
<MicrosoftAspNetCoreTestHostVersion>8.0.0-rtm.23524.15</MicrosoftAspNetCoreTestHostVersion>
<MicrosoftExtensionsCachingStackExchangeRedisVersion>8.0.0-rtm.23524.15</MicrosoftExtensionsCachingStackExchangeRedisVersion>
<MicrosoftExtensionsDiagnosticsHealthChecksAbstractionsVersion>8.0.0-rtm.23524.15</MicrosoftExtensionsDiagnosticsHealthChecksAbstractionsVersion>
<MicrosoftExtensionsDiagnosticsHealthChecksVersion>8.0.0-rtm.23524.15</MicrosoftExtensionsDiagnosticsHealthChecksVersion>
<MicrosoftExtensionsFeaturesVersion>8.0.0-rtm.23524.15</MicrosoftExtensionsFeaturesVersion>
<MicrosoftExtensionsHttpPollyVersion>8.0.0-rtm.23524.15</MicrosoftExtensionsHttpPollyVersion>
<MicrosoftExtensionsObjectPoolVersion>8.0.0-rtm.23524.15</MicrosoftExtensionsObjectPoolVersion>
</PropertyGroup>
<!--
@ -85,10 +82,5 @@
Versions below this comment are not managed by automation and can be changed as needed.
-->
<PropertyGroup Label="Manual">
<!--
Win-x64 is used here because we have picked an arbitrary runtime identifier to flow the version of the latest NETCore.App runtime.
All Runtime.$rid packages should have the same version.
-->
<MicrosoftNETCoreAppRuntimeVersion>$(MicrosoftNETCoreAppRuntimewinx64Version)</MicrosoftNETCoreAppRuntimeVersion>
</PropertyGroup>
</Project>

Просмотреть файл

@ -105,7 +105,7 @@ while [[ $# > 0 ]]; do
-binarylog|-bl)
binary_log=true
;;
-excludecibinarylog|-nobl)
-excludeCIBinarylog|-nobl)
exclude_ci_binary_log=true
;;
-pipelineslog|-pl)

Просмотреть файл

@ -487,7 +487,7 @@ if [[ "$__CodeName" == "alpine" ]]; then
-X "http://dl-cdn.alpinelinux.org/alpine/$version/main" \
-X "http://dl-cdn.alpinelinux.org/alpine/$version/community" \
-U $__ApkSignatureArg --root "$__RootfsDir" --arch "$__AlpineArch" \
search 'llvm*-libs' | grep -E '^llvm' | sort | tail -1 | sed 's/-[^-]*//2g')"
search 'llvm*-libs' | sort | tail -1 | sed 's/-[^-]*//2g')"
fi
# install all packages in one go

Просмотреть файл

@ -1,9 +0,0 @@
diff -u -r a/usr/lib/libc.so b/usr/lib/libc.so
--- a/usr/lib64/libc.so 2016-12-30 23:00:08.284951863 +0900
+++ b/usr/lib64/libc.so 2016-12-30 23:00:32.140951815 +0900
@@ -2,4 +2,4 @@
Use the shared library, but some functions are only in
the static library, so try that secondarily. */
OUTPUT_FORMAT(elf64-littleriscv)
-GROUP ( /lib64/libc.so.6 /usr/lib64/libc_nonshared.a AS_NEEDED ( /lib64/ld-linux-riscv64-lp64d.so.1 ) )
+GROUP ( libc.so.6 libc_nonshared.a AS_NEEDED ( ld-linux-riscv64-lp64d.so.1 ) )

Просмотреть файл

@ -22,10 +22,6 @@ case "$ARCH" in
TIZEN_ARCH="x86_64"
LINK_ARCH="x86"
;;
riscv64)
TIZEN_ARCH="riscv64"
LINK_ARCH="riscv"
;;
*)
echo "Unsupported architecture for tizen: $ARCH"
exit 1
@ -62,21 +58,4 @@ rm -rf $TIZEN_TMP_DIR
echo ">>Start configuring Tizen rootfs"
ln -sfn asm-${LINK_ARCH} ./usr/include/asm
patch -p1 < $__TIZEN_CROSSDIR/tizen.patch
if [[ "$TIZEN_ARCH" == "riscv64" ]]; then
echo "Fixing broken symlinks in $PWD"
rm ./usr/lib64/libresolv.so
ln -s ../../lib64/libresolv.so.2 ./usr/lib64/libresolv.so
rm ./usr/lib64/libpthread.so
ln -s ../../lib64/libpthread.so.0 ./usr/lib64/libpthread.so
rm ./usr/lib64/libdl.so
ln -s ../../lib64/libdl.so.2 ./usr/lib64/libdl.so
rm ./usr/lib64/libutil.so
ln -s ../../lib64/libutil.so.1 ./usr/lib64/libutil.so
rm ./usr/lib64/libm.so
ln -s ../../lib64/libm.so.6 ./usr/lib64/libm.so
rm ./usr/lib64/librt.so
ln -s ../../lib64/librt.so.1 ./usr/lib64/librt.so
rm ./lib/ld-linux-riscv64-lp64d.so.1
ln -s ../lib64/ld-linux-riscv64-lp64d.so.1 ./lib/ld-linux-riscv64-lp64d.so.1
fi
echo "<<Finish configuring Tizen rootfs"

Просмотреть файл

@ -156,28 +156,17 @@ fetch_tizen_pkgs()
done
}
if [ "$TIZEN_ARCH" == "riscv64" ]; then
BASE="Tizen-Base-RISCV"
UNIFIED="Tizen-Unified-RISCV"
else
BASE="Tizen-Base"
UNIFIED="Tizen-Unified"
fi
Inform "Initialize ${TIZEN_ARCH} base"
fetch_tizen_pkgs_init standard $BASE
fetch_tizen_pkgs_init standard Tizen-Base
Inform "fetch common packages"
fetch_tizen_pkgs ${TIZEN_ARCH} gcc gcc-devel-static glibc glibc-devel libicu libicu-devel libatomic linux-glibc-devel keyutils keyutils-devel libkeyutils
Inform "fetch coreclr packages"
fetch_tizen_pkgs ${TIZEN_ARCH} libgcc libstdc++ libstdc++-devel libunwind libunwind-devel lttng-ust-devel lttng-ust userspace-rcu-devel userspace-rcu
if [ "$TIZEN_ARCH" != "riscv64" ]; then
fetch_tizen_pkgs ${TIZEN_ARCH} lldb lldb-devel
fi
fetch_tizen_pkgs ${TIZEN_ARCH} lldb lldb-devel libgcc libstdc++ libstdc++-devel libunwind libunwind-devel lttng-ust-devel lttng-ust userspace-rcu-devel userspace-rcu
Inform "fetch corefx packages"
fetch_tizen_pkgs ${TIZEN_ARCH} libcom_err libcom_err-devel zlib zlib-devel libopenssl11 libopenssl1.1-devel krb5 krb5-devel
Inform "Initialize standard unified"
fetch_tizen_pkgs_init standard $UNIFIED
fetch_tizen_pkgs_init standard Tizen-Unified
Inform "fetch corefx packages"
fetch_tizen_pkgs ${TIZEN_ARCH} gssdp gssdp-devel tizen-release

Просмотреть файл

@ -80,9 +80,6 @@ elseif(TARGET_ARCH_NAME STREQUAL "riscv64")
set(TOOLCHAIN "riscv64-alpine-linux-musl")
else()
set(TOOLCHAIN "riscv64-linux-gnu")
if(TIZEN)
set(TIZEN_TOOLCHAIN "riscv64-tizen-linux-gnu/13.1.0")
endif()
endif()
elseif(TARGET_ARCH_NAME STREQUAL "s390x")
set(CMAKE_SYSTEM_PROCESSOR s390x)
@ -147,10 +144,6 @@ if(TIZEN)
include_directories(SYSTEM ${CROSS_ROOTFS}/usr/lib64/gcc/${TIZEN_TOOLCHAIN}/include/c++/)
include_directories(SYSTEM ${CROSS_ROOTFS}/usr/lib64/gcc/${TIZEN_TOOLCHAIN}/include/c++/x86_64-tizen-linux-gnu)
endif()
if(TARGET_ARCH_NAME STREQUAL "riscv64")
include_directories(SYSTEM ${CROSS_ROOTFS}/usr/lib64/gcc/${TIZEN_TOOLCHAIN}/include/c++/)
include_directories(SYSTEM ${CROSS_ROOTFS}/usr/lib64/gcc/${TIZEN_TOOLCHAIN}/include/c++/riscv64-tizen-linux-gnu)
endif()
endif()
if(ANDROID)
@ -277,7 +270,7 @@ if(TARGET_ARCH_NAME MATCHES "^(arm|armel)$")
add_toolchain_linker_flag("-L${CROSS_ROOTFS}/usr/lib")
add_toolchain_linker_flag("-L${CROSS_ROOTFS}/usr/lib/gcc/${TIZEN_TOOLCHAIN}")
endif()
elseif(TARGET_ARCH_NAME MATCHES "^(arm64|x64|riscv64)$")
elseif(TARGET_ARCH_NAME MATCHES "^(arm64|x64)$")
if(TIZEN)
add_toolchain_linker_flag("-B${CROSS_ROOTFS}/usr/lib64/gcc/${TIZEN_TOOLCHAIN}")
add_toolchain_linker_flag("-L${CROSS_ROOTFS}/lib64")

Просмотреть файл

@ -7,7 +7,7 @@ try {
. $PSScriptRoot\post-build-utils.ps1
if ($PromoteToChannels -eq "") {
Write-PipelineTaskError -Type 'warning' -Message "This build won't publish assets as it's not configured to any Maestro channel. If that wasn't intended use Darc to configure a default channel using add-default-channel for this branch or to promote it to a channel using add-build-to-channel. See https://github.com/dotnet/arcade/blob/main/Documentation/Darc.md#assigning-an-individual-build-to-a-channel for more info."
Write-PipelineTaskError -Type 'warning' -Message "This build won't publish assets as it's not configured to any Maestro channel. If that wasn't intended use Darc to configure a default channel using add-default-channel for this branch or to promote it to a channel using add-build-to-channel. See https://github.com/dotnet/arcade/blob/master/Documentation/Darc.md#assigning-an-individual-build-to-a-channel for more info."
ExitWithExitCode 0
}

Просмотреть файл

@ -154,7 +154,7 @@ jobs:
displayName: RichCodeNav Upload
inputs:
languages: ${{ coalesce(parameters.richCodeNavigationLanguage, 'csharp') }}
environment: ${{ coalesce(parameters.richCodeNavigationEnvironment, 'internal') }}
environment: ${{ coalesce(parameters.richCodeNavigationEnvironment, 'production') }}
richNavLogOutputDirectory: $(Build.SourcesDirectory)/artifacts/bin
uploadRichNavArtifacts: ${{ coalesce(parameters.richCodeNavigationUploadArtifacts, false) }}
continueOnError: true

Просмотреть файл

@ -158,7 +158,7 @@ function InitializeDotNetCli([bool]$install, [bool]$createSdkLocationFile) {
$env:DOTNET_MULTILEVEL_LOOKUP=0
# Disable first run since we do not need all ASP.NET packages restored.
$env:DOTNET_NOLOGO=1
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
# Disable telemetry on CI.
if ($ci) {
@ -228,7 +228,7 @@ function InitializeDotNetCli([bool]$install, [bool]$createSdkLocationFile) {
Write-PipelinePrependPath -Path $dotnetRoot
Write-PipelineSetVariable -Name 'DOTNET_MULTILEVEL_LOOKUP' -Value '0'
Write-PipelineSetVariable -Name 'DOTNET_NOLOGO' -Value '1'
Write-PipelineSetVariable -Name 'DOTNET_SKIP_FIRST_TIME_EXPERIENCE' -Value '1'
return $global:_DotNetInstallDir = $dotnetRoot
}

Просмотреть файл

@ -112,7 +112,7 @@ function InitializeDotNetCli {
export DOTNET_MULTILEVEL_LOOKUP=0
# Disable first run since we want to control all package sources
export DOTNET_NOLOGO=1
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
# Disable telemetry on CI
if [[ $ci == true ]]; then
@ -165,7 +165,7 @@ function InitializeDotNetCli {
Write-PipelinePrependPath -path "$dotnet_root"
Write-PipelineSetVariable -name "DOTNET_MULTILEVEL_LOOKUP" -value "0"
Write-PipelineSetVariable -name "DOTNET_NOLOGO" -value "1"
Write-PipelineSetVariable -name "DOTNET_SKIP_FIRST_TIME_EXPERIENCE" -value "1"
# return value
_InitializeDotNetCli="$dotnet_root"
@ -341,12 +341,7 @@ function InitializeBuildTool {
# return values
_InitializeBuildTool="$_InitializeDotNetCli/dotnet"
_InitializeBuildToolCommand="msbuild"
# use override if it exists - commonly set by source-build
if [[ "${_OverrideArcadeInitializeBuildToolFramework:-x}" == "x" ]]; then
_InitializeBuildToolFramework="net8.0"
else
_InitializeBuildToolFramework="${_OverrideArcadeInitializeBuildToolFramework}"
fi
_InitializeBuildToolFramework="net8.0"
}
# Set RestoreNoCache as a workaround for https://github.com/NuGet/Home/issues/3116

Просмотреть файл

@ -37,10 +37,10 @@
<PackageVersion Include="Microsoft.Extensions.Primitives" Version="$(MicrosoftExtensionsPrimitivesVersion)" />
<PackageVersion Include="Microsoft.IO.RecyclableMemoryStream" Version="2.3.2" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.1" />
<PackageVersion Include="Polly" Version="8.1.0" />
<PackageVersion Include="Polly.Core" Version="8.1.0" />
<PackageVersion Include="Polly.Extensions" Version="8.1.0" />
<PackageVersion Include="Polly.RateLimiting" Version="8.1.0" />
<PackageVersion Include="Polly" Version="8.0.0" />
<PackageVersion Include="Polly.Core" Version="8.0.0" />
<PackageVersion Include="Polly.Extensions" Version="8.0.0" />
<PackageVersion Include="Polly.RateLimiting" Version="8.0.0" />
<PackageVersion Include="System.Buffers" Version="4.5.1" />
<PackageVersion Include="System.Collections.Immutable" Version="$(SystemCollectionsImmutableVersion)" />
<PackageVersion Include="System.CommandLine.NamingConventionBinder" Version="2.0.0-beta4.22272.1" />

Просмотреть файл

@ -8,7 +8,7 @@
<PackageVersion Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="3.1.3" />
<PackageVersion Include="Moq.AutoMock" Version="3.1.0" />
<PackageVersion Include="Moq" Version="4.18.4" />
<PackageVersion Include="Polly.Testing" Version="8.1.0" />
<PackageVersion Include="Polly.Testing" Version="8.0.0" />
<PackageVersion Include="StrongNamer" Version="0.2.5" />
<PackageVersion Include="System.Configuration.ConfigurationManager" Version="$(SystemConfigurationConfigurationManagerVersion)" />
<PackageVersion Include="Xunit.Combinatorial" Version="1.5.25" />
@ -30,11 +30,6 @@
<PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="7.0.8" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.0-rtm.23476.22" />
<PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="8.0.0-rtm.23476.22" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == '$(LatestTargetFramework)'">
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="$(MicrosoftAspNetCoreMvcTestingVersion)" />
<PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="$(MicrosoftAspNetCoreTestHostVersion)" />

Просмотреть файл

@ -1,24 +1,22 @@
{
"sdk": {
"version": "9.0.100-alpha.1.23557.5"
"version": "8.0.100-rtm.23506.1"
},
"tools": {
"dotnet": "9.0.100-alpha.1.23557.5",
"dotnet": "8.0.100-rtm.23506.1",
"runtimes": {
"dotnet/x64": [
"8.0.0-rtm.23516.15",
"$(MicrosoftNETCoreAppRuntimewinx64Version)"
"6.0.22"
],
"aspnetcore/x64": [
"8.0.0-rtm.23517.6",
"$(MicrosoftAspNetCoreAppRuntimewinx64Version)"
"6.0.22"
]
}
},
"msbuild-sdks": {
"Microsoft.Build.NoTargets": "3.7.0",
"Microsoft.Build.Traversal": "3.2.0",
"Microsoft.DotNet.Arcade.Sdk": "9.0.0-beta.23557.7",
"Microsoft.DotNet.Helix.Sdk": "9.0.0-beta.23557.7"
"Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.23525.4",
"Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.23525.4"
}
}

Просмотреть файл

@ -0,0 +1,139 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// Forked from StyleCop.Analyzers repo.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
namespace Microsoft.Extensions.LocalAnalyzers.Json;
/// <summary>
/// Represents an ordered collection of JsonValues.
/// </summary>
[DebuggerDisplay("Count = {Count}")]
[DebuggerTypeProxy(typeof(JsonArrayDebugView))]
internal sealed class JsonArray : IEnumerable<JsonValue>
{
private readonly List<JsonValue> _items = [];
/// <summary>
/// Initializes a new instance of the <see cref="JsonArray"/> class, adding the given values to the collection.
/// </summary>
/// <param name="values">The values to be added to this collection.</param>
public JsonArray(params JsonValue[] values)
{
if (values == null)
{
throw new ArgumentNullException(nameof(values));
}
_items.AddRange(values);
}
/// <summary>
/// Gets the number of values in this collection.
/// </summary>
/// <value>The number of values in this collection.</value>
public int Count => _items.Count;
/// <summary>
/// Gets or sets the value at the given index.
/// </summary>
/// <param name="index">The zero-based index of the value to get or set.</param>
/// <remarks>
/// <para>The getter will return JsonValue.Null if the given index is out of range.</para>
/// </remarks>
public JsonValue this[int index]
{
get => index >= 0 && index < _items.Count
? _items[index]
: JsonValue.Null;
set => _items[index] = value;
}
/// <summary>
/// Adds the given value to this collection.
/// </summary>
/// <param name="value">The value to be added.</param>
/// <returns>Returns this collection.</returns>
public JsonArray Add(JsonValue value)
{
_items.Add(value);
return this;
}
/// <summary>
/// Inserts the given value at the given index in this collection.
/// </summary>
/// <param name="index">The index where the given value will be inserted.</param>
/// <param name="value">The value to be inserted into this collection.</param>
/// <returns>Returns this collection.</returns>
public JsonArray Insert(int index, JsonValue value)
{
_items.Insert(index, value);
return this;
}
/// <summary>
/// Removes the value at the given index.
/// </summary>
/// <param name="index">The index of the value to be removed.</param>
/// <returns>Return this collection.</returns>
public JsonArray Remove(int index)
{
_items.RemoveAt(index);
return this;
}
/// <summary>
/// Clears the contents of this collection.
/// </summary>
/// <returns>Returns this collection.</returns>
public JsonArray Clear()
{
_items.Clear();
return this;
}
/// <summary>
/// Determines whether the given item is in the JsonArray.
/// </summary>
/// <param name="item">The item to locate in the JsonArray.</param>
/// <returns>Returns true if the item is found; otherwise, false.</returns>
public bool Contains(JsonValue item) => _items.Contains(item);
/// <summary>
/// Determines the index of the given item in this JsonArray.
/// </summary>
/// <param name="item">The item to locate in this JsonArray.</param>
/// <returns>The index of the item, if found. Otherwise, returns -1.</returns>
public int IndexOf(JsonValue item) => _items.IndexOf(item);
/// <summary>
/// Returns an enumerator that iterates through the collection.
/// </summary>
/// <returns>The enumerator that iterates through the collection.</returns>
public IEnumerator<JsonValue> GetEnumerator() => _items.GetEnumerator();
/// <summary>
/// Returns an enumerator that iterates through the collection.
/// </summary>
/// <returns>The enumerator that iterates through the collection.</returns>
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() => GetEnumerator();
[ExcludeFromCodeCoverage]
private sealed class JsonArrayDebugView
{
[SuppressMessage("Major Code Smell", "S1144:Unused private types or members should be removed", Justification = "Used by debugger.")]
public JsonArrayDebugView(JsonArray array)
{
Items = array._items.ToArray();
}
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
public JsonValue[] Items { get; }
}
}

Просмотреть файл

@ -0,0 +1,212 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// Forked from StyleCop.Analyzers repo.
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
namespace Microsoft.Extensions.LocalAnalyzers.Json;
/// <summary>
/// Represents a key-value pair collection of JsonValue objects.
/// </summary>
[DebuggerDisplay("Count = {Count}")]
[DebuggerTypeProxy(typeof(JsonObjectDebugView))]
internal sealed class JsonObject : IEnumerable<KeyValuePair<string, JsonValue>>, IEnumerable<JsonValue>
{
private readonly IDictionary<string, JsonValue> _properties;
/// <summary>
/// Initializes a new instance of the <see cref="JsonObject"/> class.
/// </summary>
public JsonObject()
{
_properties = new Dictionary<string, JsonValue>();
}
/// <summary>
/// Gets the number of properties in this JsonObject.
/// </summary>
/// <value>The number of properties in this JsonObject.</value>
public int Count => _properties.Count;
/// <summary>
/// Gets or sets the property with the given key.
/// </summary>
/// <param name="key">The key of the property to get or set.</param>
/// <remarks>
/// <para>The getter will return JsonValue.Null if the given key is not associated with any value.</para>
/// </remarks>
public JsonValue this[string key]
{
get => _properties.TryGetValue(key, out var value)
? value
: JsonValue.Null;
set => _properties[key] = value;
}
/// <summary>
/// Adds a key with a <see langword="null" /> value to this collection.
/// </summary>
/// <param name="key">The key of the property to be added.</param>
/// <remarks><para>Returns this JsonObject.</para></remarks>
/// <returns>The <see cref="JsonObject"/> that was added.</returns>
public JsonObject Add(string key) => Add(key, JsonValue.Null);
/// <summary>
/// Adds a value associated with a key to this collection.
/// </summary>
/// <param name="key">The key of the property to be added.</param>
/// <param name="value">The value of the property to be added.</param>
/// <returns>Returns this JsonObject.</returns>
public JsonObject Add(string key, JsonValue value)
{
_properties.Add(key, value);
return this;
}
/// <summary>
/// Removes a property with the given key.
/// </summary>
/// <param name="key">The key of the property to be removed.</param>
/// <returns>
/// Returns true if the given key is found and removed; otherwise, false.
/// </returns>
public bool Remove(string key) => _properties.Remove(key);
/// <summary>
/// Clears the contents of this collection.
/// </summary>
/// <returns>Returns this JsonObject.</returns>
public JsonObject Clear()
{
_properties.Clear();
return this;
}
/// <summary>
/// Changes the key of one of the items in the collection.
/// </summary>
/// <remarks>
/// <para>This method has no effects if the <i>oldKey</i> does not exists.
/// If the <i>newKey</i> already exists, the value will be overwritten.</para>
/// </remarks>
/// <param name="oldKey">The name of the key to be changed.</param>
/// <param name="newKey">The new name of the key.</param>
/// <returns>Returns this JsonObject.</returns>
public JsonObject Rename(string oldKey, string newKey)
{
if (oldKey == newKey)
{
return this;
}
if (_properties.TryGetValue(oldKey, out var value))
{
this[newKey] = value;
_ = Remove(oldKey);
}
return this;
}
/// <summary>
/// Determines whether this collection contains an item associated with the given key.
/// </summary>
/// <param name="key">The key to locate in this collection.</param>
/// <returns>Returns true if the key is found; otherwise, false.</returns>
public bool ContainsKey(string key) => _properties.ContainsKey(key);
/// <summary>
/// Determines whether this collection contains the given JsonValue.
/// </summary>
/// <param name="value">The value to locate in this collection.</param>
/// <returns>Returns true if the value is found; otherwise, false.</returns>
public bool Contains(JsonValue value) => _properties.Values.Contains(value);
/// <summary>
/// Returns an enumerator that iterates through this collection.
/// </summary>
/// <returns>The enumerator that iterates through this collection.</returns>
public IEnumerator<KeyValuePair<string, JsonValue>> GetEnumerator() => _properties.GetEnumerator();
/// <summary>
/// Returns an enumerator that iterates through this collection.
/// </summary>
/// <returns>The enumerator that iterates through this collection.</returns>
IEnumerator<JsonValue> IEnumerable<JsonValue>.GetEnumerator() => _properties.Values.GetEnumerator();
/// <summary>
/// Returns an enumerator that iterates through this collection.
/// </summary>
/// <returns>The enumerator that iterates through this collection.</returns>
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() => GetEnumerator();
[ExcludeFromCodeCoverage]
private sealed class JsonObjectDebugView
{
private readonly JsonObject _object;
[SuppressMessage("Major Code Smell", "S1144:Unused private types or members should be removed", Justification = "Used by debugger.")]
public JsonObjectDebugView(JsonObject jsonObject)
{
_object = jsonObject;
}
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
public KeyValuePair[] Keys
{
get
{
var keys = new KeyValuePair[_object.Count];
var i = 0;
foreach (var property in _object)
{
keys[i] = new KeyValuePair(property.Key, property.Value);
i += 1;
}
return keys;
}
}
[DebuggerDisplay("{value.ToString(),nq}", Name = "{key}", Type = "JsonValue({Type})")]
public sealed class KeyValuePair
{
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
#pragma warning disable IDE0052 // Remove unread private members
private readonly string _key;
#pragma warning restore IDE0052 // Remove unread private members
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private readonly JsonValue _value;
public KeyValuePair(string key, JsonValue value)
{
_key = key;
_value = value;
}
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
public object View
{
get
{
if (_value.IsJsonObject)
{
return (JsonObject)_value!;
}
else if (_value.IsJsonArray)
{
return (JsonArray)_value!;
}
return _value;
}
}
}
}
}

Просмотреть файл

@ -0,0 +1,29 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using Microsoft.Extensions.LocalAnalyzers.Json;
namespace Microsoft.Extensions.LocalAnalyzers.Json;
internal static class JsonObjectExtensions
{
public static T[] GetValueArray<T>(this JsonObject value, string name)
{
var arrayOfTypes = value[name].AsJsonArray;
if (arrayOfTypes == null)
{
return Array.Empty<T>();
}
var types = new T[arrayOfTypes.Count];
for (var i = 0; i < arrayOfTypes.Count; i++)
{
types[i] = (T)Activator.CreateInstance(typeof(T), arrayOfTypes[i].AsJsonObject);
}
return types;
}
}

Просмотреть файл

@ -0,0 +1,73 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// Forked from StyleCop.Analyzers repo.
using System;
namespace Microsoft.Extensions.LocalAnalyzers.Json;
/// <summary>
/// The exception that is thrown when a JSON message cannot be parsed.
/// </summary>
/// <remarks>
/// <para>This exception is only intended to be thrown by LightJson.</para>
/// </remarks>
#pragma warning disable CA1032 // Implement standard exception constructors
public sealed class JsonParseException : Exception
#pragma warning restore CA1032 // Implement standard exception constructors
{
/// <summary>
/// Gets the text position where the error occurred.
/// </summary>
/// <value>The text position where the error occurred.</value>
public TextPosition Position { get; }
/// <summary>
/// Gets the type of error that caused the exception to be thrown.
/// </summary>
/// <value>The type of error that caused the exception to be thrown.</value>
public ParsingError Error { get; }
/// <summary>
/// Initializes a new instance of the <see cref="JsonParseException"/> class.
/// </summary>
public JsonParseException()
: base(GetMessage(ParsingError.Unknown))
{
}
/// <summary>
/// Initializes a new instance of the <see cref="JsonParseException"/> class with the given error type and position.
/// </summary>
/// <param name="type">The error type that describes the cause of the error.</param>
/// <param name="position">The position in the text where the error occurred.</param>
public JsonParseException(ParsingError type, TextPosition position)
: this(GetMessage(type), type, position)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="JsonParseException"/> class with the given message, error type, and position.
/// </summary>
/// <param name="message">The message that describes the error.</param>
/// <param name="type">The error type that describes the cause of the error.</param>
/// <param name="position">The position in the text where the error occurred.</param>
public JsonParseException(string message, ParsingError error, TextPosition position)
: base(message)
{
Error = error;
Position = position;
}
private static string GetMessage(ParsingError type)
{
return type switch
{
ParsingError.IncompleteMessage => "The string ended before a value could be parsed.",
ParsingError.InvalidOrUnexpectedCharacter => "The parser encountered an invalid or unexpected character.",
ParsingError.DuplicateObjectKeys => "The parser encountered a JsonObject with duplicate keys.",
_ => "An error occurred while parsing the JSON message."
};
}
}

Просмотреть файл

@ -0,0 +1,389 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// Forked from StyleCop.Analyzers repo.
using System;
using System.Globalization;
using System.IO;
using System.Text;
namespace Microsoft.Extensions.LocalAnalyzers.Json;
/// <summary>
/// Represents a reader that can read JsonValues.
/// </summary>
internal sealed class JsonReader
{
private readonly TextScanner _scanner;
private JsonReader(TextReader reader)
{
_scanner = new TextScanner(reader);
}
/// <summary>
/// Creates a JsonValue by using the given TextReader.
/// </summary>
/// <param name="reader">The TextReader used to read a JSON message.</param>
/// <returns>The parsed <see cref="JsonValue"/>.</returns>
public static JsonValue Parse(TextReader reader)
{
if (reader == null)
{
throw new ArgumentNullException(nameof(reader));
}
return new JsonReader(reader).Parse();
}
/// <summary>
/// Creates a JsonValue by reader the JSON message in the given string.
/// </summary>
/// <param name="source">The string containing the JSON message.</param>
/// <returns>The parsed <see cref="JsonValue"/>.</returns>
public static JsonValue Parse(string source)
{
if (source == null)
{
throw new ArgumentNullException(nameof(source));
}
using var reader = new StringReader(source);
return Parse(reader);
}
private string ReadJsonKey()
{
return ReadString();
}
private JsonValue ReadJsonValue()
{
_scanner.SkipWhitespace();
var next = _scanner.Peek();
if (char.IsNumber(next))
{
return ReadNumber();
}
return next switch
{
'{' => ReadObject(),
'[' => ReadArray(),
'"' => ReadString(),
'-' => ReadNumber(),
't' or 'f' => ReadBoolean(),
'n' => ReadNull(),
_ => throw new JsonParseException(
ParsingError.InvalidOrUnexpectedCharacter,
_scanner.Position),
};
}
private JsonValue ReadNull()
{
_scanner.Assert("null");
return JsonValue.Null;
}
private JsonValue ReadBoolean()
{
switch (_scanner.Peek())
{
case 't':
_scanner.Assert("true");
return true;
default:
_scanner.Assert("false");
return false;
}
}
private void ReadDigits(StringBuilder builder)
{
while (true)
{
int next = _scanner.Peek(throwAtEndOfFile: false);
if (next == -1 || !char.IsNumber((char)next))
{
return;
}
_ = builder.Append(_scanner.Read());
}
}
private JsonValue ReadNumber()
{
var builder = new StringBuilder();
if (_scanner.Peek() == '-')
{
_ = builder.Append(_scanner.Read());
}
if (_scanner.Peek() == '0')
{
_ = builder.Append(_scanner.Read());
}
else
{
ReadDigits(builder);
}
if (_scanner.Peek(throwAtEndOfFile: false) == '.')
{
_ = builder.Append(_scanner.Read());
ReadDigits(builder);
}
if (_scanner.Peek(throwAtEndOfFile: false) == 'e' || _scanner.Peek(throwAtEndOfFile: false) == 'E')
{
_ = builder.Append(_scanner.Read());
var next = _scanner.Peek();
switch (next)
{
case '+':
case '-':
_ = builder.Append(_scanner.Read());
break;
}
ReadDigits(builder);
}
return double.Parse(
builder.ToString(),
CultureInfo.InvariantCulture);
}
private string ReadString()
{
var builder = new StringBuilder();
_scanner.Assert('"');
while (true)
{
var errorPosition = _scanner.Position;
var c = _scanner.Read();
if (c == '\\')
{
errorPosition = _scanner.Position;
c = _scanner.Read();
_ = char.ToLowerInvariant(c) switch
{
'"' or '\\' or '/' => builder.Append(c),
'b' => builder.Append('\b'),
'f' => builder.Append('\f'),
'n' => builder.Append('\n'),
'r' => builder.Append('\r'),
't' => builder.Append('\t'),
'u' => builder.Append(ReadUnicodeLiteral()),
_ => throw new JsonParseException(
ParsingError.InvalidOrUnexpectedCharacter,
errorPosition),
};
}
else if (c == '"')
{
break;
}
else
{
if (char.IsControl(c))
{
throw new JsonParseException(
ParsingError.InvalidOrUnexpectedCharacter,
errorPosition);
}
_ = builder.Append(c);
}
}
return builder.ToString();
}
private int ReadHexDigit()
{
var errorPosition = _scanner.Position;
#pragma warning disable S109 // Magic numbers should not be used
return char.ToUpperInvariant(_scanner.Read()) switch
{
'0' => 0,
'1' => 1,
'2' => 2,
'3' => 3,
'4' => 4,
'5' => 5,
'6' => 6,
'7' => 7,
'8' => 8,
'9' => 9,
'A' => 10,
'B' => 11,
'C' => 12,
'D' => 13,
'E' => 14,
'F' => 15,
_ => throw new JsonParseException(
ParsingError.InvalidOrUnexpectedCharacter,
errorPosition),
};
}
private char ReadUnicodeLiteral()
{
int value = 0;
value += ReadHexDigit() * 4096; // 16^3
value += ReadHexDigit() * 256; // 16^2
value += ReadHexDigit() * 16; // 16^1
value += ReadHexDigit(); // 16^0
return (char)value;
}
#pragma warning restore S109 // Magic numbers should not be used
private JsonObject ReadObject()
{
return ReadObject([]);
}
private JsonObject ReadObject(JsonObject jsonObject)
{
_scanner.Assert('{');
_scanner.SkipWhitespace();
if (_scanner.Peek() == '}')
{
_ = _scanner.Read();
}
else
{
while (true)
{
_scanner.SkipWhitespace();
var errorPosition = _scanner.Position;
var key = ReadJsonKey();
if (jsonObject.ContainsKey(key))
{
throw new JsonParseException(
ParsingError.DuplicateObjectKeys,
errorPosition);
}
_scanner.SkipWhitespace();
_scanner.Assert(':');
_scanner.SkipWhitespace();
var value = ReadJsonValue();
_ = jsonObject.Add(key, value);
_scanner.SkipWhitespace();
errorPosition = _scanner.Position;
var next = _scanner.Read();
if (next == ',')
{
// Allow trailing commas in objects
_scanner.SkipWhitespace();
if (_scanner.Peek() == '}')
{
next = _scanner.Read();
}
}
if (next == '}')
{
break;
}
else if (next != ',')
{
throw new JsonParseException(
ParsingError.InvalidOrUnexpectedCharacter,
errorPosition);
}
}
}
return jsonObject;
}
private JsonArray ReadArray()
{
return ReadArray([]);
}
private JsonArray ReadArray(JsonArray jsonArray)
{
_scanner.Assert('[');
_scanner.SkipWhitespace();
if (_scanner.Peek() == ']')
{
_ = _scanner.Read();
}
else
{
while (true)
{
_scanner.SkipWhitespace();
var value = ReadJsonValue();
_ = jsonArray.Add(value);
_scanner.SkipWhitespace();
var errorPosition = _scanner.Position;
var next = _scanner.Read();
if (next == ',')
{
// Allow trailing commas in arrays
_scanner.SkipWhitespace();
if (_scanner.Peek() == ']')
{
next = _scanner.Read();
}
}
if (next == ']')
{
break;
}
else if (next != ',')
{
throw new JsonParseException(
ParsingError.InvalidOrUnexpectedCharacter,
errorPosition);
}
}
}
return jsonArray;
}
private JsonValue Parse()
{
_scanner.SkipWhitespace();
return ReadJsonValue();
}
}

Просмотреть файл

@ -0,0 +1,622 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// Forked from StyleCop.Analyzers repo.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
namespace Microsoft.Extensions.LocalAnalyzers.Json;
/// <summary>
/// A wrapper object that contains a valid JSON value.
/// </summary>
[DebuggerDisplay("{ToString(),nq}", Type = "JsonValue({Type})")]
[DebuggerTypeProxy(typeof(JsonValueDebugView))]
[SuppressMessage("Major Bug", "S1244:Floating point numbers should not be tested for equality",
Justification = "Would require unnecessary refactor.")]
internal readonly struct JsonValue : IEquatable<JsonValue>
{
/// <summary>
/// Represents a <see langword="null" /> JsonValue.
/// </summary>
public static readonly JsonValue Null = new(JsonValueType.Null, default, null);
private readonly object? _reference;
private readonly double _value;
/// <summary>
/// Initializes a new instance of the <see cref="JsonValue"/> struct, representing a Boolean value.
/// </summary>
/// <param name="value">The value to be wrapped.</param>
public JsonValue(bool? value)
{
if (!value.HasValue)
{
this = Null;
return;
}
Type = JsonValueType.Boolean;
_reference = null;
_value = value.Value ? 1 : 0;
}
/// <summary>
/// Initializes a new instance of the <see cref="JsonValue"/> struct, representing a Number value.
/// </summary>
/// <param name="value">The value to be wrapped.</param>
public JsonValue(double? value)
{
if (!value.HasValue)
{
this = Null;
return;
}
Type = JsonValueType.Number;
_reference = null;
_value = value.Value;
}
/// <summary>
/// Initializes a new instance of the <see cref="JsonValue"/> struct, representing a String value.
/// </summary>
/// <param name="value">The value to be wrapped.</param>
public JsonValue(string? value)
{
if (value is null)
{
this = Null;
return;
}
Type = JsonValueType.String;
_value = default;
_reference = value;
}
/// <summary>
/// Initializes a new instance of the <see cref="JsonValue"/> struct, representing a JsonObject.
/// </summary>
/// <param name="value">The value to be wrapped.</param>
public JsonValue(JsonObject? value)
{
if (value is null)
{
this = Null;
return;
}
Type = JsonValueType.Object;
_value = default;
_reference = value;
}
/// <summary>
/// Initializes a new instance of the <see cref="JsonValue"/> struct, representing a Array reference value.
/// </summary>
/// <param name="value">The value to be wrapped.</param>
public JsonValue(JsonArray? value)
{
if (value is null)
{
this = Null;
return;
}
Type = JsonValueType.Array;
_value = default;
_reference = value;
}
/// <summary>
/// Initializes a new instance of the <see cref="JsonValue"/> struct.
/// </summary>
/// <param name="type">The Json type of the JsonValue.</param>
/// <param name="value">
/// The internal value of the JsonValue.
/// This is used when the Json type is Number or Boolean.
/// </param>
/// <param name="reference">
/// The internal value reference of the JsonValue.
/// This value is used when the Json type is String, JsonObject, or JsonArray.
/// </param>
private JsonValue(JsonValueType type, double value, object? reference)
{
Type = type;
_value = value;
_reference = reference;
}
/// <summary>
/// Gets the type of this JsonValue.
/// </summary>
/// <value>The type of this JsonValue.</value>
public JsonValueType Type { get; }
/// <summary>
/// Gets a value indicating whether this JsonValue is Null.
/// </summary>
/// <value>A value indicating whether this JsonValue is Null.</value>
public bool IsNull => Type == JsonValueType.Null;
/// <summary>
/// Gets a value indicating whether this JsonValue is a Boolean.
/// </summary>
/// <value>A value indicating whether this JsonValue is a Boolean.</value>
public bool IsBoolean => Type == JsonValueType.Boolean;
/// <summary>
/// Gets a value indicating whether this JsonValue is an Integer.
/// </summary>
/// <value>A value indicating whether this JsonValue is an Integer.</value>
#pragma warning disable S2589 // Boolean expressions should not be gratuitous
public bool IsInteger => IsNumber && unchecked((int)_value) == _value;
#pragma warning restore S2589 // Boolean expressions should not be gratuitous
/// <summary>
/// Gets a value indicating whether this JsonValue is a Number.
/// </summary>
/// <value>A value indicating whether this JsonValue is a Number.</value>
public bool IsNumber => Type == JsonValueType.Number;
/// <summary>
/// Gets a value indicating whether this JsonValue is a String.
/// </summary>
/// <value>A value indicating whether this JsonValue is a String.</value>
public bool IsString => Type == JsonValueType.String;
/// <summary>
/// Gets a value indicating whether this JsonValue is a JsonObject.
/// </summary>
/// <value>A value indicating whether this JsonValue is a JsonObject.</value>
public bool IsJsonObject => Type == JsonValueType.Object;
/// <summary>
/// Gets a value indicating whether this JsonValue is a JsonArray.
/// </summary>
/// <value>A value indicating whether this JsonValue is a JsonArray.</value>
public bool IsJsonArray => Type == JsonValueType.Array;
/// <summary>
/// Gets a value indicating whether this JsonValue represents a DateTime.
/// </summary>
/// <value>A value indicating whether this JsonValue represents a DateTime.</value>
public bool IsDateTime => AsDateTime != null;
/// <summary>
/// Gets a value indicating whether this value is true or false.
/// </summary>
/// <value>This value as a Boolean type.</value>
public bool AsBoolean => Type switch
{
JsonValueType.Boolean => _value == 1,
JsonValueType.Number => _value != 0,
JsonValueType.String => !string.IsNullOrEmpty((string?)_reference),
JsonValueType.Object or JsonValueType.Array => true,
_ => false,
};
/// <summary>
/// Gets this value as an Integer type.
/// </summary>
/// <value>This value as an Integer type.</value>
public int AsInteger
{
get
{
var current = AsNumber;
if (current >= int.MaxValue)
{
return int.MaxValue;
}
if (_value <= int.MinValue)
{
return int.MinValue;
}
return (int)_value;
}
}
/// <summary>
/// Gets this value as a Number type.
/// </summary>
/// <value>This value as a Number type.</value>
public double AsNumber => Type switch
{
JsonValueType.Boolean => _value == 1 ? 1 : 0,
JsonValueType.Number => _value,
JsonValueType.String => double.TryParse((string?)_reference, NumberStyles.Float, CultureInfo.InvariantCulture, out var number)
? number
: 0,
_ => 0
};
/// <summary>
/// Gets this value as a String type.
/// </summary>
/// <value>This value as a String type.</value>
public string? AsString => Type switch
{
JsonValueType.Boolean => (_value == 1)
? "true"
: "false",
JsonValueType.Number => _value.ToString(CultureInfo.InvariantCulture),
JsonValueType.String => (string?)_reference,
_ => null,
};
/// <summary>
/// Gets this value as an JsonObject.
/// </summary>
/// <value>This value as an JsonObject.</value>
#pragma warning disable S1168 // Empty arrays and collections should be returned instead of null
public JsonObject? AsJsonObject => IsJsonObject ? (JsonObject?)_reference : null;
/// <summary>
/// Gets this value as an JsonArray.
/// </summary>
/// <value>This value as an JsonArray.</value>
public JsonArray? AsJsonArray => IsJsonArray ? (JsonArray?)_reference : null;
#pragma warning restore S1168 // Empty arrays and collections should be returned instead of null
/// <summary>
/// Gets this value as a system.DateTime.
/// </summary>
/// <value>This value as a system.DateTime.</value>
public DateTime? AsDateTime => IsString && DateTime.TryParse((string?)_reference ?? string.Empty, out var value)
? value
: null;
/// <summary>
/// Gets this (inner) value as a System.object.
/// </summary>
/// <value>This (inner) value as a System.object.</value>
public object? AsObject => Type switch
{
JsonValueType.Boolean or JsonValueType.Number => _value,
JsonValueType.String or JsonValueType.Object or JsonValueType.Array => _reference,
_ => null
};
/// <summary>
/// Gets or sets the value associated with the specified key.
/// </summary>
/// <param name="key">The key of the value to get or set.</param>
/// <exception cref="System.InvalidOperationException">
/// Thrown when this JsonValue is not a JsonObject.
/// </exception>
public JsonValue this[string key]
{
get
{
if (IsJsonObject)
{
return ((JsonObject)_reference!)[key];
}
else
{
throw new InvalidOperationException("This value does not represent a JsonObject.");
}
}
set
{
if (IsJsonObject)
{
((JsonObject)_reference!)[key] = value;
}
else
{
throw new InvalidOperationException("This value does not represent a JsonObject.");
}
}
}
/// <summary>
/// Gets or sets the value at the specified index.
/// </summary>
/// <param name="index">The zero-based index of the value to get or set.</param>
/// <exception cref="InvalidOperationException">
/// Thrown when this <see cref="JsonValue"/> is not a <see cref="JsonArray"/>.
/// </exception>
public JsonValue this[int index]
{
get
{
if (IsJsonArray)
{
return ((JsonArray)_reference!)[index];
}
else
{
throw new InvalidOperationException("This value does not represent a JsonArray.");
}
}
set
{
if (IsJsonArray)
{
((JsonArray)_reference!)[index] = value;
}
else
{
throw new InvalidOperationException("This value does not represent a JsonArray.");
}
}
}
/// <summary>
/// Converts the given nullable boolean into a JsonValue.
/// </summary>
/// <param name="value">The value to be converted.</param>
public static implicit operator JsonValue(bool? value)
{
return new JsonValue(value);
}
/// <summary>
/// Converts the given nullable double into a JsonValue.
/// </summary>
/// <param name="value">The value to be converted.</param>
public static implicit operator JsonValue(double? value)
{
return new JsonValue(value);
}
/// <summary>
/// Converts the given string into a JsonValue.
/// </summary>
/// <param name="value">The value to be converted.</param>
public static implicit operator JsonValue(string value)
{
return new JsonValue(value);
}
/// <summary>
/// Converts the given JsonObject into a JsonValue.
/// </summary>
/// <param name="value">The value to be converted.</param>
public static implicit operator JsonValue(JsonObject value)
{
return new JsonValue(value);
}
/// <summary>
/// Converts the given JsonArray into a JsonValue.
/// </summary>
/// <param name="value">The value to be converted.</param>
public static implicit operator JsonValue(JsonArray value)
{
return new JsonValue(value);
}
/// <summary>
/// Converts the given DateTime? into a JsonValue.
/// </summary>
/// <remarks>
/// <para>The DateTime value will be stored as a string using ISO 8601 format,
/// since JSON does not define a DateTime type.</para>
/// </remarks>
/// <param name="value">The value to be converted.</param>
public static implicit operator JsonValue(DateTime? value)
{
return value == null
? Null
: new JsonValue(value.Value.ToString("o", CultureInfo.InvariantCulture));
}
/// <summary>
/// Converts the given JsonValue into an Int.
/// </summary>
/// <param name="jsonValue">The JsonValue to be converted.</param>
public static explicit operator int(JsonValue jsonValue)
{
return jsonValue.IsInteger ? jsonValue.AsInteger : 0;
}
/// <summary>
/// Converts the given JsonValue into a nullable Int.
/// </summary>
/// <param name="jsonValue">The JsonValue to be converted.</param>
/// <exception cref="System.InvalidCastException">
/// Throws System.InvalidCastException when the inner value type of the
/// JsonValue is not the desired type of the conversion.
/// </exception>
public static explicit operator int?(JsonValue jsonValue)
{
return jsonValue.IsNull ? null : (int)jsonValue;
}
/// <summary>
/// Converts the given JsonValue into a Bool.
/// </summary>
/// <param name="jsonValue">The JsonValue to be converted.</param>
public static explicit operator bool(JsonValue jsonValue)
{
return jsonValue.IsBoolean && jsonValue._value == 1;
}
/// <summary>
/// Converts the given JsonValue into a nullable Bool.
/// </summary>
/// <param name="jsonValue">The JsonValue to be converted.</param>
/// <exception cref="System.InvalidCastException">
/// Throws System.InvalidCastException when the inner value type of the
/// JsonValue is not the desired type of the conversion.
/// </exception>
public static explicit operator bool?(JsonValue jsonValue)
{
return jsonValue.IsNull ? null : (bool)jsonValue;
}
/// <summary>
/// Converts the given JsonValue into a Double.
/// </summary>
/// <param name="jsonValue">The JsonValue to be converted.</param>
public static explicit operator double(JsonValue jsonValue)
{
return jsonValue.IsNumber ? jsonValue._value : double.NaN;
}
/// <summary>
/// Converts the given JsonValue into a nullable Double.
/// </summary>
/// <param name="jsonValue">The JsonValue to be converted.</param>
/// <exception cref="System.InvalidCastException">
/// Throws System.InvalidCastException when the inner value type of the
/// JsonValue is not the desired type of the conversion.
/// </exception>
public static explicit operator double?(JsonValue jsonValue)
{
return jsonValue.IsNull
? null
: (double)jsonValue;
}
/// <summary>
/// Converts the given JsonValue into a String.
/// </summary>
/// <param name="jsonValue">The JsonValue to be converted.</param>
public static explicit operator string?(JsonValue jsonValue)
{
return jsonValue.IsString || jsonValue.IsNull
? jsonValue._reference as string
: null;
}
/// <summary>
/// Converts the given JsonValue into a JsonObject.
/// </summary>
/// <param name="jsonValue">The JsonValue to be converted.</param>
public static explicit operator JsonObject?(JsonValue jsonValue)
{
return jsonValue.IsJsonObject || jsonValue.IsNull ? jsonValue._reference as JsonObject : null;
}
/// <summary>
/// Converts the given JsonValue into a JsonArray.
/// </summary>
/// <param name="jsonValue">The JsonValue to be converted.</param>
public static explicit operator JsonArray?(JsonValue jsonValue)
{
return jsonValue.IsJsonArray || jsonValue.IsNull ? jsonValue._reference as JsonArray : null;
}
/// <summary>
/// Converts the given JsonValue into a DateTime.
/// </summary>
/// <param name="jsonValue">The JsonValue to be converted.</param>
public static explicit operator DateTime(JsonValue jsonValue)
{
return jsonValue.AsDateTime ?? DateTime.MinValue;
}
/// <summary>
/// Converts the given JsonValue into a nullable DateTime.
/// </summary>
/// <param name="jsonValue">The JsonValue to be converted.</param>
public static explicit operator DateTime?(JsonValue jsonValue)
{
return jsonValue.IsDateTime || jsonValue.IsNull
? jsonValue.AsDateTime
: null;
}
/// <summary>
/// Returns a value indicating whether the two given JsonValues are equal.
/// </summary>
/// <param name="a">First JsonValue to compare.</param>
/// <param name="b">Second JsonValue to compare.</param>
public static bool operator ==(JsonValue a, JsonValue b)
{
return (a.Type == b.Type)
&& (a._value == b._value)
&& Equals(a._reference, b._reference);
}
/// <summary>
/// Returns a value indicating whether the two given JsonValues are unequal.
/// </summary>
/// <param name="a">First JsonValue to compare.</param>
/// <param name="b">Second JsonValue to compare.</param>
public static bool operator !=(JsonValue a, JsonValue b)
{
return !(a == b);
}
/// <summary>
/// Returns a JsonValue by parsing the given string.
/// </summary>
/// <param name="text">The JSON-formatted string to be parsed.</param>
/// <returns>The <see cref="JsonValue"/> representing the parsed text.</returns>
public static JsonValue Parse(string text)
{
return JsonReader.Parse(text);
}
public bool Equals(JsonValue other)
{
return other == this;
}
/// <inheritdoc/>
public override bool Equals(object? obj)
{
if (obj is JsonValue jv)
{
return this == jv;
}
return IsNull && obj is null;
}
/// <inheritdoc/>
public override int GetHashCode()
{
var r = _reference != null ? EqualityComparer<object>.Default.GetHashCode(_reference) : 1;
return IsNull
? Type.GetHashCode()
: Type.GetHashCode()
^ _value.GetHashCode()
^ r;
}
[ExcludeFromCodeCoverage]
private sealed class JsonValueDebugView
{
private readonly JsonValue _jsonValue;
[SuppressMessage("Major Code Smell", "S1144:Unused private types or members should be removed", Justification = "Used by debugger.")]
public JsonValueDebugView(JsonValue jsonValue)
{
_jsonValue = jsonValue;
}
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
#pragma warning disable S1168 // Empty arrays and collections should be returned instead of null
public JsonObject? ObjectView => _jsonValue.IsJsonObject
? (JsonObject?)_jsonValue._reference
: null;
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
public JsonArray? ArrayView => _jsonValue.IsJsonArray
? (JsonArray?)_jsonValue._reference
: null;
#pragma warning restore S1168 // Empty arrays and collections should be returned instead of null
public JsonValueType Type => _jsonValue.Type;
public object? Value => _jsonValue.IsJsonObject || _jsonValue.IsJsonArray
? _jsonValue._reference
: null;
}
}

Просмотреть файл

@ -0,0 +1,42 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// Forked from StyleCop.Analyzers repo.
namespace Microsoft.Extensions.LocalAnalyzers.Json;
/// <summary>
/// Enumerates the types of Json values.
/// </summary>
internal enum JsonValueType
{
/// <summary>
/// A <see langword="null" /> value.
/// </summary>
Null = 0,
/// <summary>
/// A boolean value.
/// </summary>
Boolean,
/// <summary>
/// A number value.
/// </summary>
Number,
/// <summary>
/// A string value.
/// </summary>
String,
/// <summary>
/// An object value.
/// </summary>
Object,
/// <summary>
/// An array value.
/// </summary>
Array,
}

Просмотреть файл

@ -0,0 +1,33 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// Forked from StyleCop.Analyzers repo.
namespace Microsoft.Extensions.LocalAnalyzers.Json;
/// <summary>
/// Enumerates the types of errors that can occur when parsing a JSON message.
/// </summary>
public enum ParsingError
{
/// <summary>
/// Indicates that the cause of the error is unknown.
/// </summary>
Unknown = 0,
/// <summary>
/// Indicates that the text ended before the message could be parsed.
/// </summary>
IncompleteMessage,
/// <summary>
/// Indicates that a JsonObject contains more than one key with the same name.
/// </summary>
DuplicateObjectKeys,
/// <summary>
/// Indicates that the parser encountered and invalid or unexpected character.
/// </summary>
InvalidOrUnexpectedCharacter,
}

Просмотреть файл

@ -0,0 +1,30 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// Forked from StyleCop.Analyzers repo.
namespace Microsoft.Extensions.LocalAnalyzers.Json;
/// <summary>
/// Represents a position within a plain text resource.
/// </summary>
#pragma warning disable CA1815 // Override equals and operator equals on value types
public readonly struct TextPosition
#pragma warning restore CA1815 // Override equals and operator equals on value types
{
/// <summary>
/// Gets the column position, 0-based.
/// </summary>
public long Column { get; }
/// <summary>
/// Gets the line position, 0-based.
/// </summary>
public long Line { get; }
public TextPosition(long column, long line)
{
Column = column;
Line = line;
}
}

Просмотреть файл

@ -0,0 +1,215 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// Forked from StyleCop.Analyzers repo.
using System.Globalization;
using System.IO;
namespace Microsoft.Extensions.LocalAnalyzers.Json;
/// <summary>
/// Represents a text scanner that reads one character at a time.
/// </summary>
internal sealed class TextScanner
{
private readonly TextReader _reader;
/// <summary>
/// Initializes a new instance of the <see cref="TextScanner"/> class.
/// </summary>
/// <param name="reader">The TextReader to read the text.</param>
public TextScanner(TextReader reader)
{
_reader = reader;
}
/// <summary>
/// Gets the position of the scanner within the text.
/// </summary>
/// <value>The position of the scanner within the text.</value>
public TextPosition Position { get; private set; }
/// <summary>
/// Reads the next character in the stream without changing the current position.
/// </summary>
/// <returns>The next character in the stream.</returns>
public char Peek() => (char)Peek(throwAtEndOfFile: true);
/// <summary>
/// Reads the next character in the stream without changing the current position.
/// </summary>
/// <param name="throwAtEndOfFile"><see langword="true"/> to throw an exception if the end of the file is
/// reached; otherwise, <see langword="false"/>.</param>
/// <returns>The next character in the stream, or -1 if the end of the file is reached with
/// <paramref name="throwAtEndOfFile"/> set to <see langword="false"/>.</returns>
public int Peek(bool throwAtEndOfFile)
{
var next = _reader.Peek();
if (next == -1 && throwAtEndOfFile)
{
throw new JsonParseException(ParsingError.IncompleteMessage, Position);
}
return next;
}
/// <summary>
/// Reads the next character in the stream, advancing the text position.
/// </summary>
/// <returns>The next character in the stream.</returns>
public char Read()
{
var next = _reader.Read();
if (next == -1)
{
throw new JsonParseException(ParsingError.IncompleteMessage, Position);
}
else
{
Position = next == '\n'
? new(0, Position.Line + 1)
: new(Position.Column + 1, Position.Line);
return (char)next;
}
}
/// <summary>
/// Advances the scanner to next non-whitespace character.
/// </summary>
public void SkipWhitespace()
{
while (true)
{
char next = Peek();
if (char.IsWhiteSpace(next))
{
_ = Read();
continue;
}
else if (next == '/')
{
SkipComment();
continue;
}
break;
}
}
/// <summary>
/// Verifies that the given character matches the next character in the stream.
/// If the characters do not match, an exception will be thrown.
/// </summary>
/// <param name="next">The expected character.</param>
public void Assert(char next)
{
var errorPosition = Position;
if (Read() != next)
{
throw new JsonParseException(
string.Format(CultureInfo.InvariantCulture, "Parser expected '{0}'", next),
ParsingError.InvalidOrUnexpectedCharacter,
errorPosition);
}
}
/// <summary>
/// Verifies that the given string matches the next characters in the stream.
/// If the strings do not match, an exception will be thrown.
/// </summary>
/// <param name="next">The expected string.</param>
public void Assert(string next)
{
for (var i = 0; i < next.Length; i += 1)
{
Assert(next[i]);
}
}
private void SkipComment()
{
// First character is the first slash
_ = Read();
switch (Peek())
{
case '/':
SkipLineComment();
return;
case '*':
SkipBlockComment();
return;
default:
throw new JsonParseException(
string.Format(CultureInfo.InvariantCulture, "Parser expected '{0}'", Peek()),
ParsingError.InvalidOrUnexpectedCharacter,
Position);
}
}
private void SkipLineComment()
{
// First character is the second '/' of the opening '//'
_ = Read();
while (true)
{
switch (_reader.Peek())
{
case '\n':
// Reached the end of the line
_ = Read();
return;
case -1:
return;
default:
_ = Read();
break;
}
}
}
private void SkipBlockComment()
{
// First character is the '*' of the opening '/*'
_ = Read();
bool foundStar = false;
while (true)
{
switch (_reader.Peek())
{
case '*':
_ = Read();
foundStar = true;
break;
case '/':
_ = Read();
if (foundStar)
{
return;
}
foundStar = false;
break;
case -1:
return;
default:
_ = Read();
foundStar = false;
break;
}
}
}
}

Просмотреть файл

@ -2,7 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Text.Json.Serialization;
using Microsoft.Extensions.LocalAnalyzers.Json;
namespace Microsoft.Extensions.LocalAnalyzers.ApiLifecycle.Model;
@ -10,10 +10,20 @@ internal sealed class Assembly
{
public static readonly Assembly Empty = new();
public string Name { get; set; } = string.Empty;
public string Name { get; }
public TypeDef[] Types { get; }
[JsonPropertyName("Types")]
public TypeDef[] Types { get; set; } = Array.Empty<TypeDef>();
public Assembly(JsonObject value)
{
Name = value[nameof(Name)].AsString ?? string.Empty;
Types = value.GetValueArray<TypeDef>(nameof(Types));
}
private Assembly()
{
Name = string.Empty;
Types = Array.Empty<TypeDef>();
}
public override string ToString() => Name;
}

Просмотреть файл

@ -1,13 +1,26 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using Microsoft.Extensions.LocalAnalyzers.Json;
namespace Microsoft.Extensions.LocalAnalyzers.ApiLifecycle.Model;
internal sealed class Field
{
public Stage Stage { get; set; } = Stage.Experimental;
public Stage Stage { get; }
public string Member { get; }
public string Member { get; set; } = string.Empty;
public Field(JsonObject value)
{
Member = value[nameof(Member)].AsString ?? string.Empty;
var enumString = value[nameof(Stage)].AsString;
_ = Enum.TryParse<Stage>(enumString, out var stage);
Stage = stage;
}
public override string ToString() => $"{Member}:{Stage}";
}

Просмотреть файл

@ -1,13 +1,31 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using Microsoft.Extensions.LocalAnalyzers.Json;
namespace Microsoft.Extensions.LocalAnalyzers.ApiLifecycle.Model;
internal sealed class Method
{
public Stage Stage { get; set; } = Stage.Experimental;
public Stage Stage { get; }
public string Member { get; }
public string Member { get; set; } = string.Empty;
public Method(JsonObject value)
{
Member = value[nameof(Member)].AsString ?? string.Empty;
var enumString = value[nameof(Stage)].AsString;
if (Enum.TryParse<Stage>(enumString, out var stage))
{
Stage = stage;
}
else
{
Stage = Stage.Experimental;
}
}
public override string ToString() => $"{Member}:{Stage}";
}

Просмотреть файл

@ -1,13 +1,26 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using Microsoft.Extensions.LocalAnalyzers.Json;
namespace Microsoft.Extensions.LocalAnalyzers.ApiLifecycle.Model;
internal sealed class Prop
{
public Stage Stage { get; set; } = Stage.Experimental;
public Stage Stage { get; }
public string Member { get; }
public string Member { get; set; } = string.Empty;
public Prop(JsonObject value)
{
Member = value[nameof(Member)].AsString ?? string.Empty;
var stageString = value[nameof(Stage)].AsString;
_ = Enum.TryParse<Stage>(stageString, out var stage);
Stage = stage;
}
public override string ToString() => $"{Member}:{Stage}";
}

Просмотреть файл

@ -2,24 +2,32 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using Microsoft.Extensions.LocalAnalyzers.Json;
namespace Microsoft.Extensions.LocalAnalyzers.ApiLifecycle.Model;
internal sealed class TypeDef
{
public string ModifiersAndName { get; set; } = string.Empty;
public string ModifiersAndName { get; }
public string[] Constraints { get; }
public string[] BaseTypes { get; }
public Stage Stage { get; }
public Method[] Methods { get; }
public Prop[] Properties { get; }
public Field[] Fields { get; }
public string[] Constraints { get; set; } = Array.Empty<string>();
public TypeDef(JsonObject value)
{
ModifiersAndName = Utils.StripBaseAndConstraints(value["Type"].AsString ?? string.Empty);
Constraints = Utils.GetConstraints(value["Type"].AsString ?? string.Empty);
BaseTypes = Utils.GetBaseTypes(value["Type"].AsString ?? string.Empty);
_ = Enum.TryParse<Stage>(value[nameof(Stage)].AsString, out var stage);
public string[] BaseTypes { get; set; } = Array.Empty<string>();
public Stage Stage { get; set; } = Stage.Experimental;
public Method[] Methods { get; set; } = Array.Empty<Method>();
public Prop[] Properties { get; set; } = Array.Empty<Prop>();
public Field[] Fields { get; set; } = Array.Empty<Field>();
Stage = stage;
Methods = value.GetValueArray<Method>(nameof(Methods));
Properties = value.GetValueArray<Prop>(nameof(Properties));
Fields = value.GetValueArray<Field>(nameof(Fields));
}
public override string ToString() => $"{ModifiersAndName}:{Stage}";
}

Просмотреть файл

@ -1,63 +0,0 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace Microsoft.Extensions.LocalAnalyzers.ApiLifecycle.Model;
internal sealed class TypeDefConverter : JsonConverter<TypeDef>
{
public override TypeDef? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
var r = new TypeDef();
var currDepth = reader.CurrentDepth;
while (reader.Read())
{
if (currDepth == reader.CurrentDepth && reader.TokenType == JsonTokenType.EndObject)
{
break;
}
if (reader.TokenType == JsonTokenType.PropertyName)
{
if (reader.ValueTextEquals("Type"))
{
_ = reader.Read();
var value = reader.GetString() ?? string.Empty;
r.ModifiersAndName = Utils.StripBaseAndConstraints(value);
r.Constraints = Utils.GetConstraints(value);
r.BaseTypes = Utils.GetBaseTypes(value);
}
else if (reader.ValueTextEquals("Stage"))
{
_ = reader.Read();
var value = reader.GetString() ?? string.Empty;
_ = Enum.TryParse<Stage>(value, out var stage);
r.Stage = stage;
}
else if (reader.ValueTextEquals("Methods"))
{
r.Methods = JsonSerializer.Deserialize<Method[]>(ref reader, options) ?? Array.Empty<Method>();
}
else if (reader.ValueTextEquals("Properties"))
{
r.Properties = JsonSerializer.Deserialize<Prop[]>(ref reader, options) ?? Array.Empty<Prop>();
}
else if (reader.ValueTextEquals("Fields"))
{
r.Fields = JsonSerializer.Deserialize<Field[]>(ref reader, options) ?? Array.Empty<Field>();
}
}
}
return r;
}
public override void Write(Utf8JsonWriter writer, TypeDef value, JsonSerializerOptions options) => throw new NotSupportedException("We don't need this functionality.");
}

Просмотреть файл

@ -4,25 +4,15 @@
using System;
using System.IO;
using System.Linq;
using System.Text.Json;
using System.Text.Json.Serialization;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.Extensions.LocalAnalyzers.ApiLifecycle.Model;
using Microsoft.Extensions.LocalAnalyzers.Json;
namespace Microsoft.Extensions.LocalAnalyzers.ApiLifecycle;
internal static class ModelLoader
{
private static JsonSerializerOptions _serializationOptions = new()
{
Converters =
{
new TypeDefConverter(),
new JsonStringEnumConverter<Stage>()
}
};
#pragma warning disable RS1012 // Start action has no registered actions
internal static bool TryLoadAssemblyModel(CompilationStartAnalysisContext context, out Assembly? assembly)
#pragma warning restore RS1012 // Start action has no registered actions
@ -71,9 +61,11 @@ internal static class ModelLoader
#pragma warning disable CA1031 // Do not catch general exception types
try
{
assembly = JsonSerializer.Deserialize<Assembly>(publicInterface!, _serializationOptions);
using var reader = new StringReader(publicInterface);
var value = JsonReader.Parse(reader);
if (assembly == null || !assembly.Name.Contains(assemblyName))
assembly = new Assembly(value.AsJsonObject!);
if (!assembly.Name.Contains(assemblyName))
{
return false;
}

Просмотреть файл

@ -3,7 +3,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
namespace Microsoft.Extensions.LocalAnalyzers.ApiLifecycle;
@ -13,7 +12,6 @@ internal static class Utils
private static readonly char[] _colon = { ':' };
private static readonly char[] _comma = { ',' };
[SuppressMessage("Major Code Smell", "S109:Magic numbers should not be used", Justification = "Would add more burden than context in this case.")]
public static string[] GetConstraints(string typeSignature)
{
var whereClauseIndex = typeSignature.IndexOf(" where ", StringComparison.Ordinal);
@ -25,9 +23,11 @@ internal static class Utils
var substrings = typeSignature.Split(_colon);
#pragma warning disable S109 // Magic numbers should not be used
return substrings.Length == 2
? substrings[1].Split(_comma).Select(x => x.Trim()).ToArray()
: substrings[2].Split(_comma).Select(x => x.Trim()).ToArray();
#pragma warning restore S109 // Magic numbers should not be used
}
public static string StripBaseAndConstraints(string typeSignature)

Просмотреть файл

@ -9,8 +9,6 @@
<PropertyGroup>
<SkipLocalAnalyzers>true</SkipLocalAnalyzers>
<AnalyzerLanguage>cs</AnalyzerLanguage>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<IncludeBuildOutput>false</IncludeBuildOutput>
</PropertyGroup>
<PropertyGroup>
@ -30,10 +28,6 @@
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />
<PackageReference Include="System.Text.Json" PrivateAssets="all" GeneratePathProperty="true" />
<None Include="$(OutputPath)\$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
<None Include="$(PkgSystem_Text_Json)\lib\netstandard2.0\*.dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
</ItemGroup>
<ItemGroup>

Просмотреть файл

@ -31,9 +31,8 @@ internal sealed class ExceptionSummarizer : IExceptionSummarizer
public ExceptionSummary Summarize(Exception exception)
{
_ = Throw.IfNull(exception);
var exceptionType = exception.GetType();
var exceptionTypeName = exceptionType.Name;
var exceptionTypeName = exception.GetType().Name;
// find a match for the exception type or a base type thereof
var type = exceptionType;

Просмотреть файл

@ -1,6 +1,6 @@
# Microsoft.Extensions.Diagnostics.Testing
This library provides utilities for convenient testing of logging and metering functionality.
Hand-crafted fakes to make telemetry-related testing easier.
## Install the package
@ -18,85 +18,6 @@ Or directly in the C# project file:
</ItemGroup>
```
## Usage Example
### Logs collection
The `FakeLogger` is the implementation of the `Microsoft.Extensions.Logging.ILogger` that collects log messages
in a list of log records. It is designed to be used for validation that the functionality under
test emits the expected log messages:
```csharp
[Fact]
public void TestMethod()
{
var fakeLogger = new FakeLogger<TheClassUnderTest>();
// Run the functionality that is supposed to write log messages
var classUnderTest = new TheClassUnderTest(fakeLogger);
classUnderTest.DoSomething();
var loggedRecords = fakeLogger.Collector.GetSnapshot();
// Assert that the expected messages were logged
Assert.Equal(2, loggedRecords.Count);
Assert.Equal("Something is executing", loggedRecords[0].Message);
Assert.Equal("Code completed successfully", loggedRecords[1].Message);
}
```
The `FakeLoggerServiceCollectionExtensions` and `FakeLoggerBuilderExtensions` types provide extension methods
for integrating the fake logging into the dependency injection container.
These extension methods register the `FakeLogCollector` - the in-memory holder of log messages
and the `FakeLoggerProvider` - the implementation of `Microsoft.Extensions.Logging.ILoggerProvider` that returns `FakeLogger` instances.
The following example shows the usage of fake logging in combination with the dependency injection container in a unit test:
```csharp
[Fact]
public void TestMethod()
{
using var serviceProvider = new ServiceCollection()
.AddFakeLogging()
.AddSingleton<TheClassUnderTest>()
.BuildServiceProvider();
// The "ILogger" is injected by DI as a constructor parameter to "TheClassUnderTest":
var classUnderTest = serviceProvider.GetRequiredService<TheClassUnderTest>();
// Run the functionality that is supposed to write log messages
classUnderTest.DoSomething();
var logCollector = serviceProvider.GetFakeLogCollector();
var loggedRecords = logCollector.GetSnapshot();
// Assert that the expected messages were logged
Assert.Equal(2, loggedRecords.Count);
Assert.Equal("Something is executing", loggedRecords[0].Message);
Assert.Equal("Code completed successfully", loggedRecords[1].Message);
}
```
### Metrics collection
The `MetricCollector` is a utility class that can be used to test that metrics are published correctly by a metering instrument:
```csharp
[Fact]
public void TestMethod()
{
using var meter = new Meter("MyMeter");
var counterInstrument = meter.CreateCounter<long>("request.counter");
using var collector = new MetricCollector<long>(meter, "request.counter");
// Record some metric
counterInstrument.Add(3);
// Assert that the metric was published
Assert.NotNull(collector.LastMeasurement);
Assert.Equal(3, collector.LastMeasurement.Value);
}
```
## Feedback & Contributing

Просмотреть файл

@ -37,18 +37,18 @@ Define a context and a receiver that will be used as inputs to dynamically confi
internal partial class WeatherForecastContext // Note class must be partial
{
public Guid UserId { get; set; }
public string? CountryOrRegion { get; set; }
public string? Country { get; set; }
}
internal class CountryOrRegionContextReceiver : IOptionsContextReceiver
internal class CountryContextReceiver : IOptionsContextReceiver
{
public string? CountryOrRegion { get; private set; }
public string? Country { get; private set; }
public void Receive<T>(string key, T value)
{
if (key == nameof(CountryOrRegion))
if (key == nameof(Country))
{
CountryOrRegion = value?.ToString();
Country = value?.ToString();
}
}
}
@ -93,15 +93,15 @@ The options can be configured with both global options (ForecastDays), and optio
using var host = FakeHost.CreateBuilder()
.ConfigureServices(services => services
.Configure<WeatherForecastOptions>(options => options.ForecastDays = 7)
.Configure<WeatherForecastOptions>(ConfigureTemperatureScaleBasedOnCountryOrRegion)
.Configure<WeatherForecastOptions>(ConfigureTemperatureScaleBasedOnCountry)
.AddSingleton<WeatherForecastService>())
.Build();
static void ConfigureTemperatureScaleBasedOnCountryOrRegion(IOptionsContext context, WeatherForecastOptions options)
static void ConfigureTemperatureScaleBasedOnCountry(IOptionsContext context, WeatherForecastOptions options)
{
CountryOrRegionContextReceiver receiver = new();
CountryContextReceiver receiver = new();
context.PopulateReceiver(receiver);
if (receiver.CountryOrRegion == "US")
if (receiver.Country == "US")
{
options.TemperatureScale = "Fahrenheit";
}
@ -113,8 +113,8 @@ And lastly, the service is called with some context.
```csharp
var forecastService = host.Services.GetRequiredService<WeatherForecastService>();
var usForcast = await forecastService.GetForecast(new WeatherForecastContext { CountryOrRegion = "US" }, CancellationToken.None);
var caForcast = await forecastService.GetForecast(new WeatherForecastContext { CountryOrRegion = "CA" }, CancellationToken.None);
var usForcast = await forecastService.GetForecast(new WeatherForecastContext { Country = "US" }, CancellationToken.None);
var caForcast = await forecastService.GetForecast(new WeatherForecastContext { Country = "CA" }, CancellationToken.None);
```
## Feedback & Contributing

Просмотреть файл

@ -4,7 +4,7 @@
namespace Microsoft.Extensions.Diagnostics.Enrichment;
/// <summary>
/// Represents a component that augments log records with additional properties.
/// Augments log records with additional properties.
/// </summary>
public interface ILogEnricher
{

Просмотреть файл

@ -4,13 +4,13 @@
namespace Microsoft.Extensions.Diagnostics.Enrichment;
/// <summary>
/// Represents a component that augments log records with additional properties that are unchanging over the life of the object.
/// A component that augments log records with additional properties which are unchanging over the life of the object.
/// </summary>
public interface IStaticLogEnricher
{
/// <summary>
/// Collects tags for a log record.
/// Called to collect tags for a log record.
/// </summary>
/// <param name="collector">Where the enricher puts the tags it produces.</param>
/// <param name="collector">Where the enricher puts the tags it is producing.</param>
void Enrich(IEnrichmentTagCollector collector);
}

Просмотреть файл

@ -7,7 +7,7 @@ using Microsoft.Extensions.Compliance.Classification;
namespace Microsoft.Extensions.Logging;
/// <summary>
/// Represents a custom tag provider and enables it to emit tags.
/// Interface given to custom tag providers, enabling them to emit tags.
/// </summary>
/// <remarks>
/// See <see cref="TagProviderAttribute"/> for details on how this interface is used.
@ -21,7 +21,7 @@ public interface ITagCollector
/// <param name="tagValue">The value of the tag to add.</param>
/// <exception cref="ArgumentNullException"><paramref name="tagName"/> is <see langword="null"/>.</exception>
/// <exception cref="ArgumentException"><paramref name="tagName" /> is empty or contains exclusively whitespace,
/// or a tag of the same name has already been added.
/// or when a tag of the same name has already been added.
/// </exception>
void Add(string tagName, object? tagValue);
@ -33,7 +33,7 @@ public interface ITagCollector
/// <param name="classifications">The data classifications of the tag value.</param>
/// <exception cref="ArgumentNullException"><paramref name="tagName"/> is <see langword="null"/>.</exception>
/// <exception cref="ArgumentException"><paramref name="tagName" /> is empty or contains exclusively whitespace,
/// or a tag of the same name has already been added.
/// or when a tag of the same name has already been added.
/// </exception>
void Add(string tagName, object? tagValue, DataClassificationSet classifications);
}

Просмотреть файл

@ -27,7 +27,7 @@ public sealed partial class LoggerMessageState
public KeyValuePair<string, object?>[] TagArray => _tags;
/// <summary>
/// Gets the array of redacted tags.
/// Gets the array of tags.
/// </summary>
public KeyValuePair<string, object?>[] RedactedTagArray => _redactedTags;
@ -57,7 +57,7 @@ public sealed partial class LoggerMessageState
}
/// <summary>
/// Allocates some room to put some classified tags.
/// Allocates some room to put some tags.
/// </summary>
/// <param name="count">The amount of space to allocate.</param>
/// <returns>The index in the <see cref="ClassifiedTagArray"/> where to store the classified tags.</returns>
@ -113,12 +113,12 @@ public sealed partial class LoggerMessageState
}
/// <summary>
/// Gets the number of unclassified tags currently in this instance.
/// Gets a value indicating the number of unclassified tags currently in this instance.
/// </summary>
public int TagsCount { get; private set; }
/// <summary>
/// Gets the number of classified tags currently in this instance.
/// Gets a value indicating the number of classified tags currently in this instance.
/// </summary>
public int ClassifiedTagsCount { get; private set; }

Просмотреть файл

@ -7,10 +7,10 @@ using System.Diagnostics;
namespace Microsoft.Extensions.Diagnostics.Metrics;
/// <summary>
/// Provides information to guide the production of a strongly typed histogram metric factory method and associated type.
/// Provides information to guide the production of a strongly-typed histogram metric factory method and associated type.
/// </summary>
/// <remarks>
/// This attribute is applied to a method that has the following constraints:
/// This attribute is applied to a method which has the following constraints:
/// <list type="bullet">
/// <item><description>Must be a partial method.</description></item>
/// <item><description>Must return <c>metricName</c> as the type. A class with that name will be generated.</description></item>
@ -35,7 +35,7 @@ public sealed class HistogramAttribute : Attribute
/// <summary>
/// Initializes a new instance of the <see cref="HistogramAttribute"/> class.
/// </summary>
/// <param name="tagNames">A variable array of tag names.</param>
/// <param name="tagNames">variable array of tag names.</param>
public HistogramAttribute(params string[] tagNames)
{
TagNames = tagNames;
@ -63,7 +63,7 @@ public sealed class HistogramAttribute : Attribute
/// </code>
/// </example>
/// <remarks>
/// In this example, the metric name is <c>SampleMetric</c>. When <c>Name</c> is not provided,
/// In this example the metric name is <c>SampleMetric</c>. When <c>Name</c> is not provided
/// the return type of the method is used as metric name. In this example, this would
/// be <c>RequestLatency</c> if <c>Name</c> wasn't provided.
/// </remarks>

Просмотреть файл

@ -9,14 +9,14 @@ namespace Microsoft.Extensions.Diagnostics.Metrics;
#pragma warning disable SA1649 // File name should match first type name
/// <summary>
/// Provides information to guide the production of a strongly typed histogram metric factory method and associated type.
/// Provides information to guide the production of a strongly-typed histogram metric factory method and associated type.
/// </summary>
/// <typeparam name="T">
/// The type of value the histogram will hold, which is limited to <see cref="byte"/>, <see cref="short"/>, <see cref="int"/>, <see cref="long"/>,
/// <see cref="float"/>, <see cref="double"/>, or <see cref="decimal"/>.
/// </typeparam>
/// <remarks>
/// This attribute is applied to a method that has the following constraints:
/// This attribute is applied to a method which has the following constraints:
/// <list type="bullet">
/// <item><description>Must be a partial method.</description></item>
/// <item><description>Must return <c>metricName</c> as the type. A class with that name will be generated.</description></item>
@ -42,7 +42,7 @@ public sealed class HistogramAttribute<T> : Attribute
/// <summary>
/// Initializes a new instance of the <see cref="HistogramAttribute{T}"/> class.
/// </summary>
/// <param name="tagNames">A variable array of tag names.</param>
/// <param name="tagNames">variable array of tag names.</param>
public HistogramAttribute(params string[] tagNames)
{
TagNames = tagNames;
@ -72,8 +72,8 @@ public sealed class HistogramAttribute<T> : Attribute
/// </code>
/// </example>
/// <remarks>
/// In this example, the metric name is <c>SampleMetric</c>. When <c>Name</c> is not provided,
/// the return type of the method is used as the metric name. In this example, this would
/// In this example the metric name is <c>SampleMetric</c>. When <c>Name</c> is not provided
/// the return type of the method is used as metric name. In this example, this would
/// be <c>RequestLatency</c> if <c>Name</c> wasn't provided.
/// </remarks>
public string? Name { get; set; }

Просмотреть файл

@ -31,9 +31,6 @@ public class LoggerEnrichmentOptions
/// <summary>
/// Gets or sets a value indicating whether to consult debugging files (PDB files) when producing stack traces.
/// </summary>
/// <value>
/// The default value is <see langword="false"/>.
/// </value>
/// <remarks>
/// Reading available debugging files produces richer stack traces, but can cost a substantial amount of time
/// to generate. As a result, this option should only be turned on in development scenarios, not for production use.

Просмотреть файл

@ -27,7 +27,7 @@ public static class LoggingEnrichmentExtensions
/// Enables enrichment functionality within the logging infrastructure.
/// </summary>
/// <param name="builder">The dependency injection container to add logging to.</param>
/// <param name="configure">Delegate to fine-tune the options.</param>
/// <param name="configure">Delegate the fine-tune the options.</param>
/// <returns>The value of <paramref name="builder"/>.</returns>
public static ILoggingBuilder EnableEnrichment(this ILoggingBuilder builder, Action<LoggerEnrichmentOptions> configure)
{

Просмотреть файл

@ -296,4 +296,4 @@
]
}
]
}
}

Просмотреть файл

@ -59,7 +59,7 @@ public class FakeTimeProvider : TimeProvider
/// <remarks>
/// This defaults to <see cref="TimeSpan.Zero"/>.
/// </remarks>
/// <exception cref="ArgumentOutOfRangeException">The time value is set to less than <see cref="TimeSpan.Zero"/>.</exception>
/// <exception cref="ArgumentOutOfRangeException">if the time value is set to less than <see cref="TimeSpan.Zero"/>.</exception>
public TimeSpan AutoAdvanceAmount
{
get => _autoAdvanceAmount;
@ -89,7 +89,7 @@ public class FakeTimeProvider : TimeProvider
/// Sets the date and time in the UTC time zone.
/// </summary>
/// <param name="value">The date and time in the UTC time zone.</param>
/// <exception cref="ArgumentOutOfRangeException">The supplied time value is before the current time.</exception>
/// <exception cref="ArgumentOutOfRangeException">if the supplied time value is before the curent time.</exception>
public void SetUtcNow(DateTimeOffset value)
{
lock (Waiters)
@ -115,7 +115,7 @@ public class FakeTimeProvider : TimeProvider
/// marches forward automatically in hardware, for the fake time provider the application is responsible for
/// doing this explicitly by calling this method.
/// </remarks>
/// <exception cref="ArgumentOutOfRangeException">The time value is less than <see cref="TimeSpan.Zero"/>.</exception>
/// <exception cref="ArgumentOutOfRangeException">if the time value is less than <see cref="TimeSpan.Zero"/>.</exception>
public void Advance(TimeSpan delta)
{
_ = Throw.IfLessThan(delta.Ticks, 0);

Просмотреть файл

@ -4,6 +4,7 @@
using System.Collections.Generic;
using Microsoft.Extensions.ObjectPool;
#pragma warning disable CA1716
namespace Microsoft.Shared.Pools;
/// <summary>
@ -18,7 +19,7 @@ internal sealed class PooledListPolicy<T> : PooledObjectPolicy<List<T>>
{
}
public override List<T> Create() => [];
public override List<T> Create() => new();
public override bool Return(List<T> obj)
{

Просмотреть файл

@ -122,7 +122,7 @@ public static class ArraysTests
Assembly.GetAssembly(typeof(ImmutableDictionary<,>))!,
Assembly.GetAssembly(typeof(FrozenDictionary<,>))!,
},
new[] { Source });
new[] { Source }).ConfigureAwait(false);
Assert.Equal(54, d.Count);
for (int i = 0; i < d.Count; i++)

Просмотреть файл

@ -44,7 +44,7 @@ public static class LegacyCollectionTests
Assembly.GetAssembly(typeof(System.Collections.Queue))!,
Assembly.GetAssembly(typeof(System.Collections.Specialized.HybridDictionary))!
},
new[] { Source });
new[] { Source }).ConfigureAwait(false);
Assert.Equal(8, d.Count);
for (int i = 0; i < d.Count; i++)

Просмотреть файл

@ -92,7 +92,7 @@ static partial class Log
new CallAnalyzer(),
new LegacyLoggingFixer(),
new[] { Assembly.GetAssembly(typeof(ILogger))!, Assembly.GetAssembly(typeof(LoggerMessageAttribute))! },
new[] { OriginalSource, OriginalTarget });
new[] { OriginalSource, OriginalTarget }).ConfigureAwait(false);
var actualSource = l[0];
var actualTarget = l[1];
@ -170,7 +170,7 @@ static partial class Log
new CallAnalyzer(),
new LegacyLoggingFixer(),
new[] { Assembly.GetAssembly(typeof(ILogger))! },
new[] { OriginalSource, OriginalTarget });
new[] { OriginalSource, OriginalTarget }).ConfigureAwait(false);
actualSource = l[0];
actualTarget = l[1];
@ -234,7 +234,7 @@ static partial class Log
new LegacyLoggingFixer(),
new[] { Assembly.GetAssembly(typeof(ILogger))!, Assembly.GetAssembly(typeof(LoggerMessageAttribute))! },
new[] { OriginalSource },
extraFile: "Log.cs");
extraFile: "Log.cs").ConfigureAwait(false);
var actualSource = l[0];
var actualTarget = l[1];
@ -297,7 +297,7 @@ static partial class Log
new LegacyLoggingFixer(),
new[] { Assembly.GetAssembly(typeof(ILogger))!, Assembly.GetAssembly(typeof(LoggerMessageAttribute))! },
new[] { OriginalSource },
extraFile: "Log.cs");
extraFile: "Log.cs").ConfigureAwait(false);
var actualSource = l[0];
var actualTarget = l[1];
@ -358,7 +358,7 @@ static partial class Log
new LegacyLoggingFixer(),
new[] { Assembly.GetAssembly(typeof(ILogger))!, Assembly.GetAssembly(typeof(LoggerMessageAttribute))! },
new[] { OriginalSource },
extraFile: "Log.cs");
extraFile: "Log.cs").ConfigureAwait(false);
var actualSource = l[0];
var actualTarget = l[1];
@ -434,7 +434,7 @@ static partial class Log
new LegacyLoggingFixer(),
new[] { Assembly.GetAssembly(typeof(ILogger))!, Assembly.GetAssembly(typeof(LoggerMessageAttribute))! },
new[] { OriginalSource },
extraFile: "Log.cs");
extraFile: "Log.cs").ConfigureAwait(false);
var actualSource = l[0];
var actualTarget = l[1];
@ -684,7 +684,7 @@ static partial class Log
new CallAnalyzer(),
new LegacyLoggingFixer(),
new[] { Assembly.GetAssembly(typeof(ILogger))!, Assembly.GetAssembly(typeof(LoggerMessageAttribute))! },
new[] { OrriginalSource, OrriginalTarget });
new[] { OrriginalSource, OrriginalTarget }).ConfigureAwait(false);
var actualSource = l[0];
var actualTarget = l[1];
@ -746,7 +746,7 @@ logger.Hello();
new CallAnalyzer(),
new LegacyLoggingFixer(),
new[] { Assembly.GetAssembly(typeof(ILogger))!, Assembly.GetAssembly(typeof(LoggerMessageAttribute))! },
new[] { OrriginalSource, OrriginalTarget });
new[] { OrriginalSource, OrriginalTarget }).ConfigureAwait(false);
var actualSource = l[0];
var actualTarget = l[1];

Просмотреть файл

@ -73,7 +73,7 @@ public static partial class LegacyLoggingTests
new LegacyLoggingFixer(),
new[] { Assembly.GetAssembly(typeof(ILogger))!, Assembly.GetAssembly(typeof(LoggerMessageAttribute))! },
new[] { OriginalSource, OriginalTarget },
defaultNamespace: "Example");
defaultNamespace: "Example").ConfigureAwait(false);
var actualSource = l[0];
var actualTarget = l[1];
@ -166,7 +166,7 @@ public static partial class LegacyLoggingTests
new LegacyLoggingFixer(),
new[] { Assembly.GetAssembly(typeof(ILogger))!, Assembly.GetAssembly(typeof(LoggerMessageAttribute))! },
new[] { OriginalSource, OriginalTarget },
defaultNamespace: "Example");
defaultNamespace: "Example").ConfigureAwait(false);
var actualSource = l[0];
var actualTarget = l[1];
@ -230,7 +230,7 @@ namespace Example
new[] { Assembly.GetAssembly(typeof(ILogger))!, Assembly.GetAssembly(typeof(LoggerMessageAttribute))! },
new[] { OriginalSource },
extraFile: "Log.cs",
defaultNamespace: "Example");
defaultNamespace: "Example").ConfigureAwait(false);
var actualSource = l[0];
var actualTarget = l[1];
@ -290,7 +290,7 @@ namespace Example
new LegacyLoggingFixer(),
new[] { Assembly.GetAssembly(typeof(ILogger))!, Assembly.GetAssembly(typeof(LoggerMessageAttribute))! },
new[] { OriginalSource, OriginalTarget },
defaultNamespace: "Example");
defaultNamespace: "Example").ConfigureAwait(false);
var actualSource = l[0];
var actualTarget = l[1];
@ -364,7 +364,7 @@ namespace Example
new LegacyLoggingFixer(),
new[] { Assembly.GetAssembly(typeof(ILogger))!, Assembly.GetAssembly(typeof(LoggerMessageAttribute))! },
new[] { OriginalSource, OriginalTarget },
defaultNamespace: "Example.Example2");
defaultNamespace: "Example.Example2").ConfigureAwait(false);
var actualSource = l[0];
var actualTarget = l[1];
@ -441,7 +441,7 @@ namespace Example.Example2
new[] { Assembly.GetAssembly(typeof(ILogger))!, Assembly.GetAssembly(typeof(LoggerMessageAttribute))! },
new[] { OriginalSource, OriginalTarget },
extraFile: "Log.cs",
defaultNamespace: "Example.Example2");
defaultNamespace: "Example.Example2").ConfigureAwait(false);
var actualSource = l[0];
var actualTarget = l[2];
@ -523,7 +523,7 @@ namespace Example.Example2
new LegacyLoggingFixer(),
new[] { Assembly.GetAssembly(typeof(ILogger))!, Assembly.GetAssembly(typeof(LoggerMessageAttribute))! },
new[] { OriginalSource, OriginalTarget },
defaultNamespace: "Example");
defaultNamespace: "Example").ConfigureAwait(false);
var actualSource = l[0];
var actualTarget = l[1];
@ -611,7 +611,7 @@ namespace Example.Example2
new LegacyLoggingFixer(),
new[] { Assembly.GetAssembly(typeof(ILogger))!, Assembly.GetAssembly(typeof(LoggerMessageAttribute))! },
new[] { OriginalSource, OriginalTarget },
defaultNamespace: "Example");
defaultNamespace: "Example").ConfigureAwait(false);
var actualSource = l[0];
var actualTarget = l[1];
@ -683,7 +683,7 @@ namespace Example
new[] { OriginalSource, OriginalTarget },
sourceNames: new[] { "primary.cs", "Log.cs" },
extraFile: "Log2.cs",
defaultNamespace: "Example");
defaultNamespace: "Example").ConfigureAwait(false);
var actualSource = l[0];
var actualTarget = l[2];
@ -754,7 +754,7 @@ namespace Example
},
new[] { Assembly.GetAssembly(typeof(ILogger))!, Assembly.GetAssembly(typeof(LoggerMessageAttribute))! },
new[] { OriginalSource, OriginalTarget },
defaultNamespace: "Example");
defaultNamespace: "Example").ConfigureAwait(false);
var actualSource = l[0];
var actualTarget = l[1];
@ -819,7 +819,7 @@ namespace Example
proj.CommitChanges();
var targetDoc = proj.FindDocument("target.cs");
var targetRoot = await targetDoc.GetSyntaxRootAsync(CancellationToken.None);
var targetRoot = await targetDoc.GetSyntaxRootAsync(CancellationToken.None).ConfigureAwait(false);
var targetClass = targetRoot!.FindNode(RoslynTestUtils.MakeTextSpan(TargetSourceCode, 0)) as ClassDeclarationSyntax;
var invocationDoc = proj.FindDocument("invocation.cs");
@ -828,7 +828,7 @@ namespace Example
var (invocationExpression, details) = await f.CheckIfCanFixAsync(
invocationDoc,
InvocationSourceCode.MakeTextSpan(0),
CancellationToken.None);
CancellationToken.None).ConfigureAwait(false);
Assert.NotNull(invocationExpression);
Assert.NotNull(details);
@ -839,7 +839,7 @@ namespace Example
invocationDoc,
invocationExpression!,
details!,
CancellationToken.None);
CancellationToken.None).ConfigureAwait(false);
Assert.Equal("TestA", methodName);
Assert.False(existing);
@ -852,7 +852,7 @@ namespace Example
(invocationExpression, details) = await f.CheckIfCanFixAsync(
invocationDoc,
RoslynTestUtils.MakeTextSpan(InvocationSourceCode, 0),
CancellationToken.None);
CancellationToken.None).ConfigureAwait(false);
Assert.Null(invocationExpression);
Assert.Null(details);
@ -865,7 +865,7 @@ namespace Example
(invocationExpression, details) = await f.CheckIfCanFixAsync(
invocationDoc,
RoslynTestUtils.MakeTextSpan(InvocationSourceCode, 0),
CancellationToken.None);
CancellationToken.None).ConfigureAwait(false);
Assert.Null(invocationExpression);
Assert.Null(details);
@ -878,7 +878,7 @@ namespace Example
(invocationExpression, details) = await f.CheckIfCanFixAsync(
invocationDoc,
RoslynTestUtils.MakeTextSpan(InvocationSourceCode, 0),
CancellationToken.None);
CancellationToken.None).ConfigureAwait(false);
Assert.Null(invocationExpression);
Assert.Null(details);
@ -891,7 +891,7 @@ namespace Example
(invocationExpression, details) = await f.CheckIfCanFixAsync(
invocationDoc,
RoslynTestUtils.MakeTextSpan(InvocationSourceCode, 0),
CancellationToken.None);
CancellationToken.None).ConfigureAwait(false);
Assert.NotNull(invocationExpression);
Assert.NotNull(details);
@ -902,7 +902,7 @@ namespace Example
invocationDoc,
invocationExpression!,
details!,
CancellationToken.None);
CancellationToken.None).ConfigureAwait(false);
Assert.Equal("TestA", methodName);
Assert.False(existing);
@ -915,7 +915,7 @@ namespace Example
(invocationExpression, details) = await f.CheckIfCanFixAsync(
invocationDoc,
RoslynTestUtils.MakeTextSpan(InvocationSourceCode, 0),
CancellationToken.None);
CancellationToken.None).ConfigureAwait(false);
Assert.Null(invocationExpression);
Assert.Null(details);
@ -928,7 +928,7 @@ namespace Example
(invocationExpression, details) = await f.CheckIfCanFixAsync(
invocationDoc,
RoslynTestUtils.MakeTextSpan(InvocationSourceCode, 0),
CancellationToken.None);
CancellationToken.None).ConfigureAwait(false);
Assert.NotNull(invocationExpression);
Assert.NotNull(details);
@ -939,7 +939,7 @@ namespace Example
invocationDoc,
invocationExpression!,
details!,
CancellationToken.None);
CancellationToken.None).ConfigureAwait(false);
Assert.Equal("TestA", methodName);
Assert.False(existing);

Просмотреть файл

@ -29,11 +29,9 @@ public static class SplitTests
var d = await RoslynTestUtils.RunAnalyzer(
new CallAnalyzer(),
null,
new[] { Source });
new[] { Source }).ConfigureAwait(false);
#pragma warning disable xUnit2013 // Do not use equality check to check for collection size.
Assert.Equal(1, d.Count);
#pragma warning restore xUnit2013 // Do not use equality check to check for collection size.
for (int i = 0; i < d.Count; i++)
{
Source.AssertDiagnostic(i, DiagDescriptors.Split, d[i]);

Просмотреть файл

@ -56,7 +56,7 @@ public static class StartsEndsWithTests
var d = await RoslynTestUtils.RunAnalyzer(
new CallAnalyzer(),
null,
new[] { Source });
new[] { Source }).ConfigureAwait(false);
Assert.Equal(8, d.Count);
@ -114,7 +114,7 @@ public static class StartsEndsWithTests
var d = await RoslynTestUtils.RunAnalyzer(
new CallAnalyzer(),
null,
new[] { Source });
new[] { Source }).ConfigureAwait(false);
Assert.Equal(8, d.Count);

Просмотреть файл

@ -77,7 +77,7 @@ public static class StaticTimeTests
var d = await RoslynTestUtils.RunAnalyzer(
new CallAnalyzer(),
_staticTimeReferences,
new[] { Source });
new[] { Source }).ConfigureAwait(false);
Assert.Equal(17, d.Count);
for (int i = 0; i < d.Count; i++)

Просмотреть файл

@ -46,7 +46,7 @@ public static class ValueTupleTests
var d = await RoslynTestUtils.RunAnalyzer(
new CallAnalyzer(),
null,
new[] { Source });
new[] { Source }).ConfigureAwait(false);
Assert.Equal(16, d.Count);
for (int i = 0; i < d.Count; i++)

Просмотреть файл

@ -37,11 +37,9 @@ public static class CoalesceAnalyzerTests
var d = await RoslynTestUtils.RunAnalyzer(
new CoalesceAnalyzer(),
null,
new[] { Source });
new[] { Source }).ConfigureAwait(false);
#pragma warning disable xUnit2013 // Do not use equality check to check for collection size.
Assert.Equal(0, d.Count);
#pragma warning restore xUnit2013 // Do not use equality check to check for collection size.
}
[Fact]
@ -94,7 +92,7 @@ public static class CoalesceAnalyzerTests
var d = await RoslynTestUtils.RunAnalyzer(
new CoalesceAnalyzer(),
null,
new[] { Source });
new[] { Source }).ConfigureAwait(false);
Assert.Equal(4, d.Count);
for (int i = 0; i < d.Count; i++)
@ -162,7 +160,7 @@ public static class CoalesceAnalyzerTests
var d = await RoslynTestUtils.RunAnalyzer(
new CoalesceAnalyzer(),
null,
new[] { Source });
new[] { Source }).ConfigureAwait(false);
Assert.Equal(5, d.Count);
for (int i = 0; i < d.Count; i++)

Просмотреть файл

@ -104,7 +104,7 @@ public static class ConditionalAccessAnalyzerTests
var d = await RoslynTestUtils.RunAnalyzer(
new ConditionalAccessAnalyzer(),
null,
new[] { Source });
new[] { Source }).ConfigureAwait(false);
#if NET6_0_OR_GREATER
Assert.Equal(8, d.Count);

Просмотреть файл

@ -70,7 +70,7 @@ namespace Example
new MakeExeTypesInternalFixer(),
null,
new[] { Source },
asExecutable: true);
asExecutable: true).ConfigureAwait(false);
Assert.Equal(ExpectedFixedSource.Replace("\r\n", "\n", StringComparison.Ordinal), actualFixedSources[0]);
}
@ -156,11 +156,9 @@ namespace Example
new MakeExeTypesInternalAnalyzer(),
null,
new[] { Source },
asExecutable: true);
asExecutable: true).ConfigureAwait(false);
#pragma warning disable xUnit2013 // Do not use equality check to check for collection size.
Assert.Equal(1, d.Count);
#pragma warning restore xUnit2013 // Do not use equality check to check for collection size.
for (int i = 0; i < d.Count; i++)
{
Source.AssertDiagnostic(i, DiagDescriptors.MakeExeTypesInternal, d[i]);

Просмотреть файл

@ -146,7 +146,7 @@ internal static class RoslynTestUtils
}
catch (ArgumentOutOfRangeException)
{
Assert.Fail($"Unexpected warning {actual}");
Assert.True(false, $"Unexpected warning {actual}");
}
}

Просмотреть файл

@ -58,16 +58,14 @@ public class UsingToStringInLoggersTests
var generated = await RoslynTestUtils.RunGenerator(
new LoggingGenerator(),
References,
new[] { Source });
new[] { Source }).ConfigureAwait(false);
#pragma warning disable xUnit2013 // Do not use equality check to check for collection size.
Assert.Equal(0, generated.diagnostics.Count);
#pragma warning restore xUnit2013 // Do not use equality check to check for collection size.
var fullDiags = await RoslynTestUtils.RunAnalyzer(
new UsingToStringInLoggersAnalyzer(),
References,
new[] { Source, generated.generatedSources[0].SourceText.ToString() });
new[] { Source, generated.generatedSources[0].SourceText.ToString() }).ConfigureAwait(false);
var d = RoslynTestUtils.FilterDiagnostics(fullDiags, DiagDescriptors.UsingToStringInLoggers);
@ -115,10 +113,8 @@ public class UsingToStringInLoggersTests
var d = await RoslynTestUtils.RunAnalyzer(
new UsingToStringInLoggersAnalyzer(),
References,
new[] { Source });
new[] { Source }).ConfigureAwait(false);
#pragma warning disable xUnit2013 // Do not use equality check to check for collection size.
Assert.Equal(0, d.Count);
#pragma warning restore xUnit2013 // Do not use equality check to check for collection size.
}
}

Просмотреть файл

@ -0,0 +1,78 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using Microsoft.Extensions.LocalAnalyzers.ApiLifecycle.Model;
using Xunit;
namespace Microsoft.Extensions.LocalAnalyzers.ApiLifecycle.Test;
public class AnalysisModelTest
{
[Fact]
public void Field_Fallbacks_To_NotNull_Defaults_When_Value_Not_Found_In_Json()
{
var field = new Field([]);
Assert.Equal(string.Empty, field.Member);
Assert.Equal(Stage.Experimental, field.Stage);
}
[Fact]
public void PublicMember_Fallbacks_To_NotNull_Defaults_When_Value_Not_Found_In_Json()
{
var member = new TypeDef([]);
Assert.Equal(string.Empty, member.ModifiersAndName);
Assert.Equal(Stage.Experimental, member.Stage);
Assert.Equal(Array.Empty<Field>(), member.Fields);
Assert.Equal(Array.Empty<string>(), member.BaseTypes);
Assert.Equal(Array.Empty<string>(), member.Constraints);
Assert.Equal(Array.Empty<Method>(), member.Methods);
Assert.Equal(Array.Empty<Prop>(), member.Properties);
}
[Fact]
public void Prop_Fallbacks_To_NotNull_Defaults_When_Value_Not_Found_In_Json()
{
var prop = new Prop([]);
Assert.Equal(string.Empty, prop.Member);
Assert.Equal(Stage.Experimental, prop.Stage);
}
[Fact]
public void PackageAnalysis_Fallbacks_To_NotNull_Defaults_When_Value_Not_Found_In_Json()
{
var analysis = new AssemblyAnalysis(Assembly.Empty);
Assert.Equal(Assembly.Empty, analysis.Assembly);
Assert.Empty(analysis.MissingProperties);
Assert.Empty(analysis.MissingBaseTypes);
Assert.Empty(analysis.FoundInBaseline);
Assert.Empty(analysis.NotFoundInBaseline);
Assert.Empty(analysis.MissingTypes);
Assert.Empty(analysis.MissingConstraints);
Assert.Empty(analysis.MissingFields);
Assert.Empty(analysis.MissingMethods);
Assert.Empty(analysis.MissingProperties);
}
[Fact]
public void Package_Fallbacks_To_NotNull_Defaults_When_Value_Not_Found_In_Json()
{
var package = new Assembly([]);
Assert.Equal(Array.Empty<TypeDef>(), package.Types);
Assert.Equal(string.Empty, package.Name);
}
[Fact]
public void Method_FallbacksTo_NotNull_Defaults_When_Value_Not_Found_In_Json()
{
var method = new Method([]);
Assert.Equal(string.Empty, method.Member);
Assert.Equal(Stage.Experimental, method.Stage);
}
}

Просмотреть файл

@ -39,7 +39,7 @@ public class ApiLifecycleAnalyzerTest
},
options: options,
testAssemblyName: testAssemblyName)
;
.ConfigureAwait(false);
Assert.Equal(expectedDiagnostics, diagnostics.Count);
@ -65,7 +65,7 @@ public class ApiLifecycleAnalyzerTest
},
options: options,
testAssemblyName: testAssemblyName)
;
.ConfigureAwait(false);
Assert.Equal(expectedDiagnostics, diagnostics.Count);
@ -77,7 +77,7 @@ public class ApiLifecycleAnalyzerTest
}
}
public static IEnumerable<Assembly> References => new[]
public static IEnumerable<System.Reflection.Assembly> References => new[]
{
Assembly.GetAssembly(typeof(ObsoleteAttribute))!,
Assembly.GetAssembly(typeof(EditorBrowsableAttribute))!,

Просмотреть файл

@ -37,7 +37,7 @@ public static class ToInvariantStringTests
var d = await RoslynTestUtils.RunAnalyzer(
new CallAnalyzer(),
null,
new[] { Source });
new[] { Source }).ConfigureAwait(false);
Assert.Equal(4, d.Count);
for (int i = 0; i < d.Count; i++)

Просмотреть файл

@ -28,7 +28,7 @@ public static class UseThrowsTests
var d = await RoslynTestUtils.RunAnalyzer(
new CallAnalyzer(),
_references,
new[] { original });
new[] { original }).ConfigureAwait(false);
Assert.Single(d);
original.AssertDiagnostic(0, DiagDescriptors.ThrowsStatement, d[0]);
@ -42,7 +42,7 @@ public static class UseThrowsTests
var d = await RoslynTestUtils.RunAnalyzer(
new CallAnalyzer(),
_references,
new[] { original });
new[] { original }).ConfigureAwait(false);
Assert.Empty(d);
}
@ -276,7 +276,7 @@ namespace Example
var d = await RoslynTestUtils.RunAnalyzer(
new CallAnalyzer(),
_references,
new[] { original });
new[] { original }).ConfigureAwait(false);
Assert.Single(d);
original.AssertDiagnostic(0, DiagDescriptors.ThrowsExpression, d[0]);

Просмотреть файл

@ -0,0 +1,143 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// Forked from StyleCop.Analyzers repo.
using System;
using System.Collections;
using System.Collections.Generic;
using Xunit;
namespace Microsoft.Extensions.LocalAnalyzers.Json.Test;
public class JsonArrayTest
{
[Fact]
public void TestConstructor()
{
var obj = new JsonArray();
Assert.Equal(0, obj.Count);
var obj1 = new JsonArray(1, "test1");
Assert.Equal(2, obj1.Count);
Assert.Equal(1, obj1[0].AsInteger);
Assert.Equal("test1", obj1[1].AsString);
var obj2 = new JsonArray { 1, "test2" };
Assert.Equal(2, obj2.Count);
Assert.Equal(1, obj2[0].AsInteger);
Assert.Equal("test2", obj2[1].AsString);
Assert.Throws<ArgumentNullException>("values", () => new JsonArray(default!));
}
[Fact]
public void TestIndexer()
{
var obj = new JsonArray(1);
Assert.Equal(1, obj.Count);
Assert.Equal(1, obj[0].AsInteger);
Assert.Equal(JsonValue.Null, obj[1]);
Assert.Equal(JsonValue.Null, obj[-1]);
obj[0] = 2;
Assert.Equal(2, obj[0].AsInteger);
Assert.ThrowsAny<ArgumentOutOfRangeException>(() => obj[-1] = 0);
Assert.ThrowsAny<ArgumentException>(() => obj[1] = 0);
}
[Fact]
public void TestInsert()
{
var obj = new JsonArray(1);
Assert.Equal(1, obj.Count);
Assert.Equal(1, obj[0].AsInteger);
// Insert at end
Assert.Same(obj, obj.Insert(obj.Count, 2));
Assert.Equal(2, obj.Count);
Assert.Equal(1, obj[0].AsInteger);
Assert.Equal(2, obj[1].AsInteger);
// Insert at beginning
Assert.Same(obj, obj.Insert(0, 0));
Assert.Equal(3, obj.Count);
Assert.Equal(0, obj[0].AsInteger);
Assert.Equal(1, obj[1].AsInteger);
Assert.Equal(2, obj[2].AsInteger);
Assert.ThrowsAny<ArgumentOutOfRangeException>(() => obj.Insert(-1, 0));
Assert.ThrowsAny<ArgumentException>(() => obj.Insert(obj.Count + 1, 0));
}
[Fact]
public void TestRemove()
{
var obj = new JsonArray(0, 1, 2);
Assert.Equal(3, obj.Count);
Assert.ThrowsAny<ArgumentOutOfRangeException>(() => obj.Remove(-1));
Assert.ThrowsAny<ArgumentException>(() => obj.Remove(obj.Count));
Assert.Same(obj, obj.Remove(1));
Assert.Equal(2, obj.Count);
Assert.Equal(0, obj[0].AsInteger);
Assert.Equal(2, obj[1].AsInteger);
}
[Fact]
public void TestClear()
{
var obj = new JsonArray(0, 1, 2);
Assert.Equal(3, obj.Count);
Assert.Same(obj, obj.Clear());
Assert.Equal(0, obj.Count);
Assert.Same(obj, obj.Clear());
Assert.Equal(0, obj.Count);
}
[Fact]
public void TestContains()
{
var obj = new JsonArray("a", "b", "c");
Assert.True(obj.Contains("b"));
obj.Remove(1);
Assert.False(obj.Contains("b"));
Assert.False(obj.Contains(JsonValue.Null));
}
[Fact]
public void TestIndexOf()
{
var obj = new JsonArray("a", "b", "c");
Assert.Equal(1, obj.IndexOf("b"));
Assert.Equal(2, obj.IndexOf("c"));
obj.Remove(1);
Assert.Equal(-1, obj.IndexOf("b"));
Assert.Equal(1, obj.IndexOf("c"));
Assert.Equal(-1, obj.IndexOf(JsonValue.Null));
}
[Fact]
public void TestEnumerators()
{
var obj = new JsonArray("a", "b", "c");
using var genericEnumerator = obj.GetEnumerator();
var legacyEnumerator = ((IEnumerable)obj).GetEnumerator();
for (int i = 0; i < obj.Count; i++)
{
Assert.True(genericEnumerator.MoveNext());
Assert.True(legacyEnumerator.MoveNext());
Assert.Equal(obj[i], genericEnumerator.Current);
Assert.Equal(obj[i], legacyEnumerator.Current);
Assert.Equal(genericEnumerator.Current, legacyEnumerator.Current);
}
}
}

Просмотреть файл

@ -0,0 +1,112 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// Forked from StyleCop.Analyzers repo.
using System;
using System.Collections;
using System.Collections.Generic;
using Xunit;
namespace Microsoft.Extensions.LocalAnalyzers.Json.Test;
public class JsonObjectTest
{
[Fact]
public void TestCount()
{
var obj = new JsonObject();
Assert.Equal(0, obj.Count);
obj["x"] = "value";
Assert.Equal(1, obj.Count);
obj["y"] = "value";
Assert.Equal(2, obj.Count);
obj["x"] = "value2";
Assert.Equal(2, obj.Count);
Assert.True(obj.Remove("x"));
Assert.Equal(1, obj.Count);
Assert.False(obj.Remove("x"));
Assert.Equal(1, obj.Count);
obj["z"] = "value3";
Assert.Equal(2, obj.Count);
Assert.Same(obj, obj.Clear());
Assert.Equal(0, obj.Count);
}
[Fact]
public void TestAdd()
{
var obj = new JsonObject();
Assert.Equal(JsonValue.Null, obj["x"]);
Assert.False(obj.ContainsKey("x"));
Assert.Same(obj, obj.Add("x"));
Assert.Equal(JsonValue.Null, obj["x"]);
Assert.True(obj.ContainsKey("x"));
}
[Fact]
public void TestEnumerator()
{
var obj = new JsonObject
{
["x"] = "x1",
["y"] = "y1"
};
foreach (var value in obj)
{
Assert.Equal(typeof(KeyValuePair<string, JsonValue>), value.GetType());
Assert.Equal(value.Value, obj[value.Key]);
}
IEnumerable<JsonValue> genericEnumerable = obj;
foreach (var value in genericEnumerable)
{
Assert.True(obj.Contains(value));
}
IEnumerable legacyEnumerable = obj;
foreach (var value in legacyEnumerable)
{
Assert.IsType<KeyValuePair<string, JsonValue>>(value);
Assert.True(obj.Contains(((KeyValuePair<string, JsonValue>)value).Value));
}
}
[Fact]
public void TestRename()
{
var obj = new JsonObject { ["x"] = "value1", ["y"] = "value2" };
Assert.Equal(2, obj.Count);
var value = obj["x"].AsString;
Assert.False(obj.ContainsKey("z"));
Assert.Same(obj, obj.Rename("x", "z"));
Assert.Same(value, obj["z"].AsString);
Assert.False(obj.ContainsKey("x"));
Assert.Equal(2, obj.Count);
// Renaming can overwrite a value
Assert.Same(obj, obj.Rename("z", "y"));
Assert.Same(value, obj["y"].AsString);
Assert.Equal(1, obj.Count);
// Renaming to the same name does nothing
Assert.Same(obj, obj.Rename("y", "y"));
Assert.Same(value, obj["y"].AsString);
Assert.Equal(1, obj.Count);
// Renaming a non-existent element is not a problem, and does not overwrite the target
Assert.Same(obj, obj.Rename("bogus", "y"));
Assert.Equal(1, obj.Count);
Assert.Same(value, obj["y"].AsString);
}
}

Просмотреть файл

@ -0,0 +1,20 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// Forked from StyleCop.Analyzers repo.
using System;
using Xunit;
namespace Microsoft.Extensions.LocalAnalyzers.Json.Test;
public class JsonParseExceptionTest
{
[Fact]
public void TestDefaultConstructor()
{
var ex = new JsonParseException();
Assert.Equal(ParsingError.Unknown, ex.Error);
Assert.False(string.IsNullOrEmpty(ex.Message));
}
}

Просмотреть файл

@ -0,0 +1,94 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// Forked from StyleCop.Analyzers repo.
using System;
using System.IO;
using Xunit;
namespace Microsoft.Extensions.LocalAnalyzers.Json.Test;
public class JsonReaderTest
{
[Fact]
public void TestKeyMatchesPreviousValue()
{
var jsonObject = JsonValue.Parse("{ \"x\": \"value\", \"value\": \"value\" }");
Assert.NotEqual(jsonObject, JsonValue.Null);
Assert.Equal("value", jsonObject["x"].AsString);
Assert.Equal("value", jsonObject["value"].AsString);
Assert.Equal(jsonObject["x"], jsonObject["value"]);
}
[Fact]
public void TestDuplicateKeys()
{
Assert.ThrowsAny<JsonParseException>(() => JsonValue.Parse("{ \"x\": \"value\", \"x\": \"value\" }"));
}
[Fact]
public void TestParse()
{
Assert.Equal("true", JsonReader.Parse("true").AsString);
using (var reader = new StringReader("true"))
{
Assert.Equal("true", JsonReader.Parse(reader).AsString);
}
Assert.Throws<ArgumentNullException>("source", () => JsonReader.Parse(default(string)!));
Assert.Throws<ArgumentNullException>("reader", () => JsonReader.Parse(default(TextReader)!));
}
[Fact]
public void TestNumbers()
{
Assert.Equal(0, JsonReader.Parse("0").AsInteger);
Assert.Equal(0, JsonReader.Parse("-0").AsInteger);
Assert.Equal(-1, JsonReader.Parse("-1").AsInteger);
Assert.Equal(-1.0, JsonReader.Parse("-1.0").AsNumber);
Assert.Equal(-1e1, JsonReader.Parse("-1e1").AsNumber);
Assert.Equal(-1E1, JsonReader.Parse("-1E1").AsNumber);
Assert.Equal(-1E+1, JsonReader.Parse("-1E+1").AsNumber);
Assert.Equal(-10E-1, JsonReader.Parse("-10E-1").AsNumber);
}
[Fact]
public void TestEscapeSequences()
{
Assert.Equal("\"", JsonReader.Parse("\"\\\"\"").AsString);
Assert.Equal("\\", JsonReader.Parse("\"\\\\\"").AsString);
Assert.Equal("/", JsonReader.Parse("\"\\/\"").AsString);
Assert.Equal("\b", JsonReader.Parse("\"\\b\"").AsString);
Assert.Equal("\f", JsonReader.Parse("\"\\f\"").AsString);
Assert.Equal("\n", JsonReader.Parse("\"\\n\"").AsString);
Assert.Equal("\r", JsonReader.Parse("\"\\r\"").AsString);
Assert.Equal("\t", JsonReader.Parse("\"\\t\"").AsString);
Assert.Equal("\u0123\u4567\u89AB\uCDEF", JsonReader.Parse("\"\\u0123\\u4567\\u89AB\\uCDEF\"").AsString);
var ex = Assert.Throws<JsonParseException>(() => JsonReader.Parse("\"\\x\""));
Assert.Equal(ParsingError.InvalidOrUnexpectedCharacter, ex.Error);
Assert.Equal(0, ex.Position.Line);
Assert.Equal(2, ex.Position.Column);
ex = Assert.Throws<JsonParseException>(() => JsonReader.Parse("\"\\u11GA\""));
Assert.Equal(ParsingError.InvalidOrUnexpectedCharacter, ex.Error);
Assert.Equal(0, ex.Position.Line);
Assert.Equal(5, ex.Position.Column);
ex = Assert.Throws<JsonParseException>(() => JsonReader.Parse("\"\r\""));
Assert.Equal(ParsingError.InvalidOrUnexpectedCharacter, ex.Error);
Assert.Equal(0, ex.Position.Line);
Assert.Equal(1, ex.Position.Column);
}
[Fact]
public void TestArrayMissingComma()
{
var ex = Assert.ThrowsAny<JsonParseException>(() => JsonReader.Parse("[ 1 2 ]"));
Assert.Equal(ParsingError.InvalidOrUnexpectedCharacter, ex.Error);
Assert.Equal(0, ex.Position.Line);
Assert.Equal(4, ex.Position.Column);
}
}

Просмотреть файл

@ -0,0 +1,56 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// Forked from StyleCop.Analyzers repo.
using System;
using Xunit;
namespace Microsoft.Extensions.LocalAnalyzers.Json.Test;
public class JsonScannerTest
{
[Fact]
public void TestUnexpectedLookahead()
{
JsonParseException ex;
ex = Assert.ThrowsAny<JsonParseException>(() => JsonValue.Parse("trUe"));
Assert.Equal(ParsingError.InvalidOrUnexpectedCharacter, ex.Error);
Assert.Equal(0, ex.Position.Line);
Assert.Equal(2, ex.Position.Column);
ex = Assert.ThrowsAny<JsonParseException>(() => JsonValue.Parse("tr"));
Assert.Equal(ParsingError.IncompleteMessage, ex.Error);
Assert.Equal(0, ex.Position.Line);
Assert.Equal(2, ex.Position.Column);
}
[Fact]
public void TestIncompleteComment()
{
var ex = Assert.ThrowsAny<JsonParseException>(() => JsonValue.Parse("{ /1 }"));
Assert.Equal(ParsingError.InvalidOrUnexpectedCharacter, ex.Error);
Assert.Contains("'1'", ex.Message);
Assert.Equal(0, ex.Position.Line);
Assert.Equal(3, ex.Position.Column);
ex = Assert.ThrowsAny<JsonParseException>(() => JsonValue.Parse("{ // ignored text }"));
Assert.Equal(ParsingError.IncompleteMessage, ex.Error);
ex = Assert.ThrowsAny<JsonParseException>(() => JsonValue.Parse("{ /* ignored text }"));
Assert.Equal(ParsingError.IncompleteMessage, ex.Error);
}
[Fact]
public void TestBlockCommentTermination()
{
var obj = JsonValue.Parse("{ /* * / */ }");
Assert.Equal(JsonValueType.Object, obj.Type);
Assert.Equal(0, obj.AsJsonObject?.Count);
}
}

Просмотреть файл

@ -0,0 +1,350 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// Forked from StyleCop.Analyzers repo.
using System;
using System.Globalization;
using Xunit;
namespace Microsoft.Extensions.LocalAnalyzers.Json.Test;
public class JsonValueTest
{
[Fact]
public void TestJsonValueConstructors()
{
// JsonValue(bool?)
Assert.True(new JsonValue(true).IsBoolean);
Assert.True(new JsonValue(true).AsBoolean);
Assert.True(new JsonValue(false).IsBoolean);
Assert.False(new JsonValue(false).AsBoolean);
Assert.True(new JsonValue(default(bool?)).IsNull);
Assert.False(new JsonValue(default(bool?)).IsBoolean);
Assert.False(new JsonValue(default(bool?)).AsBoolean);
// JsonValue(double?)
Assert.True(new JsonValue(1.0).IsNumber);
Assert.Equal(1.0, new JsonValue(1.0).AsNumber);
Assert.True(new JsonValue(default(double?)).IsNull);
Assert.False(new JsonValue(default(double?)).IsNumber);
Assert.Equal(0.0, new JsonValue(default(double?)).AsNumber);
// JsonValue(string)
Assert.True(new JsonValue(string.Empty).IsString);
Assert.True(new JsonValue("text").IsString);
Assert.Equal("text", new JsonValue("text").AsString);
Assert.True(new JsonValue(default(string)).IsNull);
Assert.False(new JsonValue(default(string)).IsString);
Assert.Null(new JsonValue(default(string)).AsString);
// JsonValue(JsonObject)
Assert.True(new JsonValue(new JsonObject()).IsJsonObject);
Assert.IsType<JsonObject>(new JsonValue(new JsonObject()).AsJsonObject);
Assert.True(new JsonValue(default(JsonObject)).IsNull);
Assert.False(new JsonValue(default(JsonObject)).IsJsonObject);
Assert.Null(new JsonValue(default(JsonObject)).AsJsonObject);
// JsonValue(JsonArray)
Assert.True(new JsonValue(new JsonArray()).IsJsonArray);
Assert.IsType<JsonArray>(new JsonValue(new JsonArray()).AsJsonArray);
Assert.True(new JsonValue(default(JsonArray)).IsNull);
Assert.False(new JsonValue(default(JsonArray)).IsJsonArray);
Assert.Null(new JsonValue(default(JsonArray)).AsJsonArray);
Assert.Equal("interface Microsoft.Extensions.Metrics.IHistogram2<in T> where T : struct",
new JsonValue("interface Microsoft.Extensions.Metrics.IHistogram2<in T> where T : struct").AsString);
}
[Fact]
public void TestIsInteger()
{
Assert.False(new JsonValue(false).IsInteger);
Assert.True(new JsonValue(1.0).IsInteger);
Assert.False(new JsonValue(1.1).IsInteger);
Assert.False(new JsonValue(double.PositiveInfinity).IsInteger);
}
[Fact]
public void TestIsDateTime()
{
Assert.False(new JsonValue(false).IsDateTime);
Assert.False(new JsonValue("Some text").IsDateTime);
Assert.True(new JsonValue(DateTime.Now.ToString("o", CultureInfo.InvariantCulture)).IsDateTime);
}
[Fact]
public void TestAsBoolean()
{
Assert.False(new JsonValue(false).AsBoolean);
Assert.False(new JsonValue(0.0).AsBoolean);
Assert.False(new JsonValue(string.Empty).AsBoolean);
Assert.False(new JsonValue(default(JsonObject)).AsBoolean);
Assert.True(new JsonValue(true).AsBoolean);
Assert.True(new JsonValue(1.0).AsBoolean);
Assert.True(new JsonValue("text").AsBoolean);
Assert.True(new JsonValue(new JsonObject()).AsBoolean);
Assert.True(new JsonValue(new JsonArray()).AsBoolean);
}
[Fact]
public void TestAsInteger()
{
Assert.Equal(int.MaxValue, new JsonValue(uint.MaxValue).AsInteger);
Assert.Equal(int.MinValue, new JsonValue(long.MinValue).AsInteger);
Assert.Equal(0, new JsonValue(0.5).AsInteger);
Assert.Equal(1, new JsonValue(1).AsInteger);
}
[Fact]
public void TestAsNumber()
{
Assert.Equal(0.0, new JsonValue(false).AsNumber);
Assert.Equal(1.0, new JsonValue(true).AsNumber);
Assert.Equal(1.0, new JsonValue(1.0).AsNumber);
Assert.Equal(1.0, new JsonValue("1.0").AsNumber);
Assert.Equal(0, new JsonValue("text").AsNumber);
Assert.Equal(0.0, new JsonValue(new JsonObject()).AsNumber);
Assert.Equal(0.0, new JsonValue(default(JsonObject)).AsNumber);
Assert.Equal(0.0, new JsonValue(new JsonArray()).AsNumber);
}
[Fact]
public void TestAsNumbersUsingCultureWithNonStandardNumberFormat()
{
Assert.Equal(1.0, new JsonValue("1.0").AsNumber);
}
[Fact]
public void TestAsString()
{
Assert.Equal("false", new JsonValue(false).AsString);
Assert.Equal("true", new JsonValue(true).AsString);
Assert.Equal("0.5", new JsonValue(0.5).AsString);
Assert.Equal("1", new JsonValue(1.0).AsString);
Assert.Equal("text", new JsonValue("text").AsString);
Assert.Null(new JsonValue(new JsonObject()).AsString);
Assert.Null(new JsonValue(default(JsonObject)).AsString);
Assert.Null(new JsonValue(new JsonArray()).AsString);
}
[Fact]
public void TestAsStringUsingCultureWithNonStandardNumberFormat()
{
Assert.Equal("0.5", new JsonValue(0.5).AsString);
}
[Fact]
public void TestAsJsonObject()
{
Assert.Null(new JsonValue(false).AsJsonObject);
Assert.IsType<JsonObject>(new JsonValue(new JsonObject()).AsJsonObject);
Assert.Null(new JsonValue(default(JsonObject)).AsJsonObject);
}
[Fact]
public void TestAsJsonArray()
{
Assert.Null(new JsonValue(false).AsJsonArray);
Assert.IsType<JsonArray>(new JsonValue(new JsonArray()).AsJsonArray);
Assert.Null(new JsonValue(default(JsonArray)).AsJsonArray);
}
[Fact]
public void TestAsDateTime()
{
Assert.Null(new JsonValue(false).AsDateTime);
Assert.Null(new JsonValue("Some text").AsDateTime);
var now = new DateTime(2016, 1, 20, 5, 12, 33, DateTimeKind.Local);
Assert.Equal(now, new JsonValue(now.ToString("o", CultureInfo.InvariantCulture)).AsDateTime);
}
[Fact]
public void TestAsObject()
{
Assert.Equal(0.0, new JsonValue(false).AsObject);
Assert.Equal(1.0, new JsonValue(true).AsObject);
Assert.Equal(1.0, new JsonValue(1.0).AsObject);
Assert.Equal("1.0", new JsonValue("1.0").AsObject);
Assert.IsType<JsonObject>(new JsonValue(new JsonObject()).AsObject);
Assert.IsType<JsonArray>(new JsonValue(new JsonArray()).AsObject);
Assert.Null(new JsonValue(default(JsonObject)).AsObject);
}
[Fact]
public void TestStringIndexer()
{
Assert.ThrowsAny<InvalidOperationException>(() => new JsonValue(false)["key"]);
Assert.ThrowsAny<InvalidOperationException>(() => new JsonValue(false)[null!]);
Assert.ThrowsAny<InvalidOperationException>(() => new JsonValue(false) { ["key"] = "value" });
Assert.Equal(JsonValue.Null, new JsonValue(new JsonObject())["key"]);
var value = new JsonValue(new JsonObject()) { ["key"] = "value" };
Assert.Equal("value", value["key"].AsString);
Assert.ThrowsAny<ArgumentNullException>(() => new JsonValue(new JsonObject())[null!]);
}
[Fact]
public void TestIntegerIndexer()
{
Assert.ThrowsAny<InvalidOperationException>(() => new JsonValue(false)[0]);
Assert.ThrowsAny<InvalidOperationException>(() => new JsonValue(false)[-1]);
Assert.ThrowsAny<InvalidOperationException>(() => new JsonValue(false) { [0] = "value" });
Assert.Equal(JsonValue.Null, new JsonValue(new JsonArray())[0]);
Assert.Equal(JsonValue.Null, new JsonValue(new JsonArray())[-1]);
var value = new JsonValue(new JsonArray { "initial" });
Assert.Equal("initial", value[0].AsString);
value[0] = "value";
Assert.Equal("value", value[0].AsString);
}
[Fact]
public void TestConversionOperators()
{
// (JsonValue)(DateTime?)
DateTime time = DateTime.Now;
Assert.NotEqual(time, JsonValue.Null);
Assert.Equal(time.ToString("o", CultureInfo.InvariantCulture), ((JsonValue)time).AsString);
Assert.Equal(default(DateTime?), JsonValue.Null);
// (int)(JsonValue)
Assert.Equal(0, (int)new JsonValue(uint.MaxValue));
Assert.Equal(0, (int)new JsonValue(long.MinValue));
Assert.Equal(0, (int)new JsonValue(2.5));
Assert.Equal(1, (int)new JsonValue(1));
// (int?)(JsonValue)
Assert.Equal(0, (int?)new JsonValue(uint.MaxValue));
Assert.Equal(0, (int?)new JsonValue(long.MinValue));
Assert.Equal(0, (int?)new JsonValue(2.5));
Assert.Equal(1, (int?)new JsonValue(1));
Assert.Null((int?)JsonValue.Null);
Assert.Null((int?)new JsonValue(default(JsonObject)));
// (bool)(JsonValue)
Assert.False((bool)new JsonValue(false));
Assert.False((bool)new JsonValue(0.0));
Assert.False((bool)new JsonValue(string.Empty));
Assert.False((bool)new JsonValue(default(JsonObject)));
Assert.True((bool)new JsonValue(true));
Assert.False((bool)new JsonValue(1.0));
Assert.False((bool)new JsonValue("text"));
Assert.False((bool)new JsonValue(new JsonObject()));
Assert.False((bool)new JsonValue(new JsonArray()));
// (bool?)(JsonValue)
Assert.False((bool?)new JsonValue(false));
Assert.False((bool?)new JsonValue(0.0));
Assert.False((bool?)new JsonValue(string.Empty));
Assert.True((bool?)new JsonValue(true));
Assert.False((bool?)new JsonValue(1.0));
Assert.False((bool?)new JsonValue("text"));
Assert.False((bool?)new JsonValue(new JsonObject()));
Assert.False((bool?)new JsonValue(new JsonArray()));
Assert.Null((bool?)JsonValue.Null);
Assert.Null((bool?)new JsonValue(default(JsonObject)));
// (double)(JsonValue)
Assert.Equal(double.NaN, (double)new JsonValue(false));
Assert.Equal(double.NaN, (double)new JsonValue(true));
Assert.Equal(1.0, (double)new JsonValue(1.0));
Assert.Equal(double.NaN, (double)new JsonValue("1.0"));
Assert.Equal(double.NaN, (double)new JsonValue(new JsonObject()));
Assert.Equal(double.NaN, (double)new JsonValue(new JsonArray()));
Assert.Equal(double.NaN, (double)JsonValue.Null);
Assert.Equal(double.NaN, (double)new JsonValue(default(JsonObject)));
// (double?)(JsonValue)
Assert.Equal(double.NaN, (double?)new JsonValue(false));
Assert.Equal(double.NaN, (double?)new JsonValue(true));
Assert.Equal(1.0, (double?)new JsonValue(1.0));
Assert.Equal(double.NaN, (double?)new JsonValue("1.0"));
Assert.Equal(double.NaN, (double?)new JsonValue(new JsonObject()));
Assert.Equal(double.NaN, (double?)new JsonValue(new JsonArray()));
Assert.Null((double?)JsonValue.Null);
Assert.Null((double?)new JsonValue(default(JsonObject)));
// (string)(JsonValue)
Assert.Null((string?)new JsonValue(false));
Assert.Null((string?)new JsonValue(true));
Assert.Null((string?)new JsonValue(1.0));
Assert.Equal("text", (string?)new JsonValue("text"));
Assert.Null((string?)new JsonValue(new JsonObject()));
Assert.Null((string?)new JsonValue(default(JsonObject)));
Assert.Null((string?)new JsonValue(new JsonArray()));
// (JsonObject)(JsonValue)
Assert.Null((JsonObject?)new JsonValue(false));
Assert.IsType<JsonObject>((JsonObject?)new JsonValue(new JsonObject()));
Assert.Null((JsonObject?)new JsonValue(default(JsonObject)));
// (JsonArray)(JsonValue)
Assert.Null((JsonArray?)new JsonValue(false));
Assert.IsType<JsonArray>((JsonArray?)new JsonValue(new JsonArray()));
Assert.Null((JsonArray?)new JsonValue(default(JsonArray)));
// (DateTime)(JsonValue)
Assert.Equal(DateTime.MinValue, (DateTime)new JsonValue(false));
Assert.Equal(DateTime.MinValue, (DateTime)new JsonValue("Some text"));
var now = new DateTime(2016, 1, 20, 5, 12, 33, DateTimeKind.Local);
Assert.Equal(now, (DateTime)new JsonValue(now.ToString("o", CultureInfo.InvariantCulture)));
// (DateTime?)(JsonValue)
Assert.Null((DateTime?)new JsonValue(false));
Assert.Null((DateTime?)new JsonValue("Some text"));
Assert.Equal(now, (DateTime?)new JsonValue(now.ToString("o", CultureInfo.InvariantCulture)));
}
[Fact]
public void TestOpInequality()
{
Assert.False(JsonValue.Null != default);
Assert.True(new JsonValue(true) != new JsonValue(0));
}
[Fact]
public void TestEquals()
{
Assert.True(JsonValue.Null.Equals((object?)null));
Assert.True(JsonValue.Null.Equals(JsonValue.Null));
Assert.True(JsonValue.Null.Equals(default));
Assert.True(new JsonValue(true).Equals(new JsonValue(true)));
Assert.False(new JsonValue(true).Equals(new JsonValue(false)));
Assert.False(JsonValue.Null.Equals(1));
Assert.False(JsonValue.Null.Equals(new InvalidOperationException()));
}
[Fact]
public void TestGetHashCode()
{
Assert.Equal(JsonValue.Null.GetHashCode(), default(JsonValue).GetHashCode());
Assert.Equal(new JsonValue(1).GetHashCode(), new JsonValue(1).GetHashCode());
Assert.Equal(new JsonValue("text").GetHashCode(), new JsonValue(new string("text".ToCharArray())).GetHashCode());
}
[Fact]
public void TestParse()
{
Assert.True(JsonValue.Parse("true").IsBoolean);
Assert.True(JsonValue.Parse("1").IsInteger);
Assert.True(JsonValue.Parse("1.0").IsInteger);
Assert.True(JsonValue.Parse("1.0").IsNumber);
Assert.True(JsonValue.Parse("\"text\"").IsString);
Assert.True(JsonValue.Parse("null").IsNull);
Assert.True(JsonValue.Parse("{}").IsJsonObject);
Assert.True(JsonValue.Parse("[]").IsJsonArray);
Assert.ThrowsAny<JsonParseException>(() => JsonValue.Parse(string.Empty));
Assert.ThrowsAny<JsonParseException>(() => JsonValue.Parse("{"));
}
}

Просмотреть файл

@ -146,7 +146,7 @@ internal static class RoslynTestUtils
}
catch (ArgumentOutOfRangeException)
{
Assert.Fail($"Unexpected warning {actual}");
Assert.True(false, $"Unexpected warning {actual}");
}
}

Просмотреть файл

@ -102,7 +102,7 @@ public class GeneratorTests
code,
TestTaxonomy,
},
new OptionsProvider());
new OptionsProvider()).ConfigureAwait(false);
return d;
}
@ -120,11 +120,9 @@ public class GeneratorTests
{
Source,
},
new OptionsProvider());
new OptionsProvider()).ConfigureAwait(false);
#pragma warning disable xUnit2013 // Do not use equality check to check for collection size.
Assert.Equal(0, d.Count);
#pragma warning restore xUnit2013 // Do not use equality check to check for collection size.
}
private sealed class Options : AnalyzerConfigOptions

Просмотреть файл

@ -141,7 +141,7 @@ public class EmitterTests
typeof(ReadOnlySpan<>).Assembly
},
sources)
;
.ConfigureAwait(false);
Assert.Empty(d);
_ = Assert.Single(r);

Просмотреть файл

@ -26,7 +26,7 @@ public class SyntaxContextReceiverTests
File.ReadAllText("TestClasses/Record1.cs"),
};
var comp = await RoslynTestUtils.RunSyntaxContextReceiver(sut, new[] { typeof(OptionsContextAttribute).Assembly }, sources);
var comp = await RoslynTestUtils.RunSyntaxContextReceiver(sut, new[] { typeof(OptionsContextAttribute).Assembly }, sources).ConfigureAwait(true);
Assert.True(sut.TryGetTypeDeclarations(comp, out var typeDeclarations));
@ -49,7 +49,7 @@ public class SyntaxContextReceiverTests
File.ReadAllText("TestClasses/Record1.cs"),
};
var comp = await RoslynTestUtils.RunSyntaxContextReceiver(sut, Enumerable.Empty<Assembly>(), sources);
var comp = await RoslynTestUtils.RunSyntaxContextReceiver(sut, Enumerable.Empty<Assembly>(), sources).ConfigureAwait(true);
Assert.False(sut.TryGetTypeDeclarations(comp, out _));
}
@ -64,7 +64,7 @@ public class SyntaxContextReceiverTests
File.ReadAllText("TestClasses/Class2B.cs"),
};
var comp = await RoslynTestUtils.RunSyntaxContextReceiver(sut, new[] { typeof(OptionsContextAttribute).Assembly }, sources);
var comp = await RoslynTestUtils.RunSyntaxContextReceiver(sut, new[] { typeof(OptionsContextAttribute).Assembly }, sources).ConfigureAwait(true);
Assert.True(sut.TryGetTypeDeclarations(comp, out var typeDeclarations));
Assert.Single(typeDeclarations!);
@ -82,7 +82,7 @@ public class SyntaxContextReceiverTests
var sut = new ContextReceiver(CancellationToken.None);
var sources = new[] { File.ReadAllText("TestClasses/ClassWithNoAttribute.cs"), };
var comp = await RoslynTestUtils.RunSyntaxContextReceiver(sut, new[] { typeof(OptionsContextAttribute).Assembly }, sources);
var comp = await RoslynTestUtils.RunSyntaxContextReceiver(sut, new[] { typeof(OptionsContextAttribute).Assembly }, sources).ConfigureAwait(true);
Assert.True(sut.TryGetTypeDeclarations(comp, out var typeDeclarations));
Assert.Empty(typeDeclarations!);

Просмотреть файл

@ -47,7 +47,7 @@ public class EmitterTests
},
sources,
symbols)
;
.ConfigureAwait(false);
// we need this "Where()" hack because Roslyn 4.0 doesn't recognize #pragma warning disable for generator-produced warnings
#pragma warning disable S1067 // Expressions should not be too complex

Просмотреть файл

@ -978,7 +978,7 @@ public partial class ParserTests
}
else if (d.Count > 0)
{
Assert.Fail($"Expected no diagnostics, got {d.Count} diagnostics");
Assert.True(false, $"Expected no diagnostics, got {d.Count} diagnostics");
}
}
}

Просмотреть файл

@ -37,7 +37,7 @@ public class EmitterTests
Assembly.GetAssembly(typeof(HistogramAttribute<>))!,
},
sources)
;
.ConfigureAwait(false);
Assert.Empty(d);
Assert.Equal(2, r.Length);

Просмотреть файл

@ -140,7 +140,7 @@ internal static class RoslynTestUtils
}
else
{
Assert.Fail($"Unexpected diagnostics {actual}");
Assert.True(false, $"Unexpected diagnostics {actual}");
}
}
@ -155,7 +155,7 @@ internal static class RoslynTestUtils
expectedSpan = text.MakeTextSpan(spanNum);
if (expectedSpan == null)
{
Assert.Fail($"No span detected for diagnostic #{spanNum}, {d}");
Assert.True(false, $"No span detected for diagnostic #{spanNum}, {d}");
}
}
@ -173,7 +173,7 @@ internal static class RoslynTestUtils
if (text.MakeTextSpan(spanNum) != null)
{
Assert.Fail($"Diagnostic {spanNum} was not detected");
Assert.True(false, $"Diagnostic {spanNum} was not detected");
}
}

Просмотреть файл

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RootNamespace>Microsoft.AspNetCore.AsyncState.Test</RootNamespace>
<Description>Unit tests for Microsoft.AspNetCore.AsyncState.</Description>
@ -6,6 +6,8 @@
<PropertyGroup>
<TargetFrameworks>$(TestNetCoreTargetFrameworks)</TargetFrameworks>
<!-- Setting IsTrimmable to true so that the ILLink Analyzers are also used in this project. -->
<IsTrimmable Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))">true</IsTrimmable>
</PropertyGroup>
<ItemGroup>

Просмотреть файл

@ -56,7 +56,7 @@ public class AcceptanceTests
latencyContext.SetTag(tokenIssuer.GetTagToken(tagName), tagValue);
latencyContext.RecordMeasure(tokenIssuer.GetMeasureToken(measureName), measureValue);
await Task.Delay(taskTimeMs + 10); // Adding 10 ms buffer
await next.Invoke();
await next.Invoke().ConfigureAwait(false);
var ld = latencyContext!.LatencyData;
Assert.True(IsMatchByName(ld.Checkpoints, (c) => c.Name == checkpointName));
@ -73,9 +73,9 @@ public class AcceptanceTests
});
});
}))
.StartAsync();
.StartAsync().ConfigureAwait(false);
_ = await host.GetTestClient().GetAsync("/");
_ = await host.GetTestClient().GetAsync("/").ConfigureAwait(false);
await host.StopAsync();
Assert.True(isInLambda);

Просмотреть файл

@ -44,7 +44,7 @@ public class ChecpointAcceptanceTests
app.Use(async (context, next) =>
{
var latencyContext = context.RequestServices.GetRequiredService<ILatencyContext>();
await next.Invoke();
await next.Invoke().ConfigureAwait(false);
latencyContext.TryGetCheckpoint(RequestCheckpointConstants.ElapsedTillPipelineExitMiddleware, out var exitPipeline, out var exitPipelineFreq);
latencyContext.TryGetCheckpoint(RequestCheckpointConstants.ElapsedResponseProcessed, out var responseProcessed, out var responseProcessedFreq);
@ -59,7 +59,7 @@ public class ChecpointAcceptanceTests
}))
.StartAsync();
_ = await host.GetTestClient().GetAsync("/");
_ = await host.GetTestClient().GetAsync("/").ConfigureAwait(false);
Assert.True(reachedLambda);
Assert.InRange(exitPipelineValue, 0, 10_000);
@ -80,7 +80,7 @@ public class ChecpointAcceptanceTests
app.Use(async (context, next) =>
{
var latencyContext = context.RequestServices.GetRequiredService<ILatencyContext>();
await next.Invoke();
await next.Invoke().ConfigureAwait(false);
latencyContext.TryGetCheckpoint(RequestCheckpointConstants.ElapsedTillPipelineExitMiddleware, out var exitPipeline, out var exitPipelineFreq);
latencyContext.TryGetCheckpoint(RequestCheckpointConstants.ElapsedResponseProcessed, out var responseProcessed, out var responsedProcessedFreq);
exitPipelineValue = ((double)exitPipeline / exitPipelineFreq) * 1000;
@ -102,7 +102,7 @@ public class ChecpointAcceptanceTests
HttpResponseMessage? response = null;
var e = await Record.ExceptionAsync(async () => response = await host.GetTestClient().GetAsync("/"));
var e = await Record.ExceptionAsync(async () => response = await host.GetTestClient().GetAsync("/").ConfigureAwait(false));
Assert.Null(e);
Assert.NotNull(response);

Просмотреть файл

@ -61,7 +61,7 @@ public partial class AcceptanceTests
async (logCollector, client) =>
{
const string UserId = "testUserId";
using var response = await client.GetAsync($"/api/users/{UserId}/someTestData?{QueryParamName}=foo");
using var response = await client.GetAsync($"/api/users/{UserId}/someTestData?{QueryParamName}=foo").ConfigureAwait(false);
Assert.True(response.IsSuccessStatusCode);
await WaitForLogRecordsAsync(logCollector, TimeSpan.FromSeconds(30));
@ -96,7 +96,7 @@ public partial class AcceptanceTests
async (logCollector, client) =>
{
const string UserId = "testUserId";
using var response = await client.GetAsync($"/api/users/{UserId}/someTestData?{QueryParamName}=foo");
using var response = await client.GetAsync($"/api/users/{UserId}/someTestData?{QueryParamName}=foo").ConfigureAwait(false);
Assert.True(response.IsSuccessStatusCode);
await WaitForLogRecordsAsync(logCollector, TimeSpan.FromSeconds(30));
@ -142,7 +142,7 @@ public partial class AcceptanceTests
{
const string UserId = "testUserId";
const string NoDataClassParamValue = "someTestData";
using var response = await client.GetAsync($"/api/users/{UserId}/{NoDataClassParamValue}?{QueryParamName}=foo");
using var response = await client.GetAsync($"/api/users/{UserId}/{NoDataClassParamValue}?{QueryParamName}=foo").ConfigureAwait(false);
Assert.True(response.IsSuccessStatusCode);
await WaitForLogRecordsAsync(logCollector, TimeSpan.FromSeconds(30));
@ -186,7 +186,7 @@ public partial class AcceptanceTests
async (logCollector, client) =>
{
const string UserId = "testUserId";
using var response = await client.GetAsync($"/api/users/{UserId}/someTestData?{QueryParamName}=foo");
using var response = await client.GetAsync($"/api/users/{UserId}/someTestData?{QueryParamName}=foo").ConfigureAwait(false);
Assert.True(response.IsSuccessStatusCode);
await WaitForLogRecordsAsync(logCollector, TimeSpan.FromSeconds(30));
@ -227,7 +227,7 @@ public partial class AcceptanceTests
}),
async (logCollector, client) =>
{
using var response = await client.GetAsync(RequestPath);
using var response = await client.GetAsync(RequestPath).ConfigureAwait(false);
Assert.False(response.IsSuccessStatusCode);
await WaitForLogRecordsAsync(logCollector, TimeSpan.FromSeconds(30));

Просмотреть файл

@ -169,7 +169,7 @@ public partial class AcceptanceTests
const string Content = "Client: hello!";
using var content = new StringContent(Content);
using var response = await client.PostAsync("/", content);
using var response = await client.PostAsync("/", content).ConfigureAwait(false);
Assert.True(response.IsSuccessStatusCode);
await WaitForLogRecordsAsync(logCollector, _defaultLogTimeout);
@ -229,7 +229,7 @@ public partial class AcceptanceTests
const string Content = "Client: hello!";
using var content = new StringContent(Content, null, requestContentType);
using var response = await client.PostAsync("/", content);
using var response = await client.PostAsync("/", content).ConfigureAwait(false);
Assert.True(response.IsSuccessStatusCode);
await WaitForLogRecordsAsync(logCollector, _defaultLogTimeout);
@ -294,7 +294,7 @@ public partial class AcceptanceTests
};
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(MediaTypeNames.Application.Json));
using var response = await client.SendAsync(request);
using var response = await client.SendAsync(request).ConfigureAwait(false);
Assert.True(response.IsSuccessStatusCode);
await WaitForLogRecordsAsync(logCollector, _defaultLogTimeout, expectedRecords: 2);
@ -355,7 +355,7 @@ public partial class AcceptanceTests
using var httpMessage = new HttpRequestMessage(HttpMethod.Get, "/");
httpMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(MediaTypeNames.Application.Json));
using var response = await client.SendAsync(httpMessage);
using var response = await client.SendAsync(httpMessage).ConfigureAwait(false);
Assert.True(response.IsSuccessStatusCode);
await WaitForLogRecordsAsync(logCollector, _defaultLogTimeout);
@ -403,7 +403,7 @@ public partial class AcceptanceTests
},
async static (logCollector, client) =>
{
using var response = await client.DeleteAsync("/");
using var response = await client.DeleteAsync("/").ConfigureAwait(false);
Assert.True(response.IsSuccessStatusCode);
await WaitForLogRecordsAsync(logCollector, _defaultLogTimeout);
@ -445,7 +445,7 @@ public partial class AcceptanceTests
async static (logCollector, client) =>
{
const string RequestPath = "/api/users/123/add-task/345";
using var response = await client.GetAsync(RequestPath);
using var response = await client.GetAsync(RequestPath).ConfigureAwait(false);
Assert.True(response.IsSuccessStatusCode);
await WaitForLogRecordsAsync(logCollector, _defaultLogTimeout);
@ -475,7 +475,7 @@ public partial class AcceptanceTests
},
async static (logCollector, client) =>
{
using var response = await client.DeleteAsync("/");
using var response = await client.DeleteAsync("/").ConfigureAwait(false);
Assert.True(response.IsSuccessStatusCode);
await WaitForLogRecordsAsync(logCollector, _defaultLogTimeout, expectedRecords: 2);
@ -508,12 +508,12 @@ public partial class AcceptanceTests
static x => x.AddHttpLoggingRedaction().AddHttpLogging(x => x.CombineLogs = false),
async static (logCollector, client) =>
{
using var firstResponse = await client.DeleteAsync("/");
using var firstResponse = await client.DeleteAsync("/").ConfigureAwait(false);
Assert.True(firstResponse.IsSuccessStatusCode);
await WaitForLogRecordsAsync(logCollector, _defaultLogTimeout, expectedRecords: 2);
using var secondResponse = await client.DeleteAsync("/");
using var secondResponse = await client.DeleteAsync("/").ConfigureAwait(false);
Assert.True(secondResponse.IsSuccessStatusCode);
await WaitForLogRecordsAsync(logCollector, _defaultLogTimeout, expectedRecords: 4);
@ -533,18 +533,20 @@ public partial class AcceptanceTests
var sixthRecord = logRecords[5].StructuredState;
Assert.Equal(5, firstRecord!.Count);
Assert.Single(secondRecord!);
Assert.Equal(1, secondRecord!.Count);
Assert.Equal(5, fourthRecord!.Count);
Assert.Single(fithRecord!);
Assert.Equal(1, fithRecord!.Count);
Assert.DoesNotContain(firstRecord, x => x.Key == HttpLoggingTagNames.StatusCode);
Assert.DoesNotContain(firstRecord, x => x.Key == HttpLoggingTagNames.Duration);
Assert.DoesNotContain(secondRecord!, x => x.Key == HttpLoggingTagNames.Duration);
Assert.DoesNotContain(secondRecord, x => x.Key == HttpLoggingTagNames.Duration);
Assert.DoesNotContain(fourthRecord, x => x.Key == HttpLoggingTagNames.StatusCode);
Assert.DoesNotContain(fourthRecord, x => x.Key == HttpLoggingTagNames.Duration);
Assert.DoesNotContain(fithRecord!, x => x.Key == HttpLoggingTagNames.Duration);
Assert.DoesNotContain(fithRecord, x => x.Key == HttpLoggingTagNames.Duration);
Assert.Single(secondRecord!, x => x.Key == HttpLoggingTagNames.StatusCode && x.Value == responseStatus);
Assert.Single(fithRecord!, x => x.Key == HttpLoggingTagNames.StatusCode && x.Value == responseStatus);
Assert.Equal(1, secondRecord!.Count);
Assert.Equal(1, fithRecord!.Count);
Assert.Single(secondRecord, x => x.Key == HttpLoggingTagNames.StatusCode && x.Value == responseStatus);
Assert.Single(fithRecord, x => x.Key == HttpLoggingTagNames.StatusCode && x.Value == responseStatus);
Assert.Equal(2, thirdRecord!.Count);
Assert.Equal(2, sixthRecord!.Count);
@ -664,7 +666,7 @@ public partial class AcceptanceTests
async static (logCollector, client) =>
{
using var content = new StringContent("Client: hello!");
using var response = await client.PostAsync("/", content);
using var response = await client.PostAsync("/", content).ConfigureAwait(false);
Assert.True(response.IsSuccessStatusCode);
@ -694,7 +696,7 @@ public partial class AcceptanceTests
}),
async (logCollector, client) =>
{
using var response = await client.GetAsync(httpPath);
using var response = await client.GetAsync(httpPath).ConfigureAwait(false);
Assert.True(response.IsSuccessStatusCode);
@ -724,7 +726,7 @@ public partial class AcceptanceTests
}),
async (logCollector, client) =>
{
using var response = await client.GetAsync("");
using var response = await client.GetAsync("").ConfigureAwait(false);
Assert.True(response.IsSuccessStatusCode);
Assert.Equal(0, logCollector.Count);
@ -740,7 +742,7 @@ public partial class AcceptanceTests
.AddHttpLogEnricher<ThrowingEnricher>(),
async (logCollector, client) =>
{
using var response = await client.GetAsync("");
using var response = await client.GetAsync("").ConfigureAwait(false);
Assert.True(response.IsSuccessStatusCode);
await WaitForLogRecordsAsync(logCollector, _defaultLogTimeout);

Просмотреть файл

@ -76,9 +76,7 @@ public class ParserTests
{
var sv = new StringValues("csrftoken=u32t4o3tb3gg43");
Assert.True(CookieHeaderValueListParser.Instance.TryParse(sv, out var result, out var error));
#pragma warning disable xUnit2013 // Do not use equality check to check for collection size.
Assert.Equal(1, result.Count);
#pragma warning restore xUnit2013 // Do not use equality check to check for collection size.
Assert.Equal("csrftoken", result[0].Name.Value);
Assert.Equal("u32t4o3tb3gg43", result[0].Value.Value);
Assert.Null(error);
@ -204,9 +202,7 @@ public class ParserTests
{
var sv = new StringValues("text/html; charset=UTF-8");
Assert.True(MediaTypeHeaderValueListParser.Instance.TryParse(sv, out var result, out var error));
#pragma warning disable xUnit2013 // Do not use equality check to check for collection size.
Assert.Equal(1, result.Count);
#pragma warning restore xUnit2013 // Do not use equality check to check for collection size.
Assert.Equal("text/html", result[0].MediaType);
Assert.Equal("UTF-8", result[0].Charset);
Assert.Null(error);
@ -226,9 +222,7 @@ public class ParserTests
{
var sv = new StringValues("\"HelloWorld\"");
Assert.True(EntityTagHeaderValueListParser.Instance.TryParse(sv, out var result, out var error));
#pragma warning disable xUnit2013 // Do not use equality check to check for collection size.
Assert.Equal(1, result!.Count);
#pragma warning restore xUnit2013 // Do not use equality check to check for collection size.
Assert.Equal("\"HelloWorld\"", result[0].Tag);
Assert.Null(error);
}
@ -247,9 +241,7 @@ public class ParserTests
{
var sv = new StringValues("en-US");
Assert.True(StringWithQualityHeaderValueListParser.Instance.TryParse(sv, out var result, out var error));
#pragma warning disable xUnit2013 // Do not use equality check to check for collection size.
Assert.Equal(1, result!.Count);
#pragma warning restore xUnit2013 // Do not use equality check to check for collection size.
Assert.Equal("en-US", result[0].Value);
Assert.Null(error);
}
@ -309,9 +301,7 @@ public class ParserTests
var sv = new StringValues("bytes=200-1000");
Assert.True(RangeHeaderValueParser.Instance.TryParse(sv, out var result, out var error));
Assert.Equal("bytes", result!.Unit);
#pragma warning disable xUnit2013 // Do not use equality check to check for collection size.
Assert.Equal(1, result.Ranges.Count);
#pragma warning restore xUnit2013 // Do not use equality check to check for collection size.
Assert.Equal(200, result.Ranges.Single().From);
Assert.Equal(1000, result.Ranges.Single().To);
Assert.Null(error);

Просмотреть файл

@ -29,7 +29,7 @@ public class AsyncStateTests
return Task.CompletedTask;
}
await SetAsyncContext(state, context, token);
await SetAsyncContext(state, context, token).ConfigureAwait(false);
Assert.Same(context, state.Get(token));
}

Просмотреть файл

@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
@ -220,9 +220,7 @@ public class RedactionFakesAcceptanceTests
Assert.Equal(1, collector.LastRedactorRequested.SequenceNumber);
Assert.Equal(dc, collector.LastRedactorRequested.DataClassifications);
#pragma warning disable xUnit2013 // Do not use equality check to check for collection size.
Assert.Equal(1, collector.AllRedactorRequests.Count);
#pragma warning restore xUnit2013 // Do not use equality check to check for collection size.
}
[Fact]

Просмотреть файл

@ -413,6 +413,6 @@ public static class MetricCollectorTests
snap = collector.GetMeasurementSnapshot(true);
Assert.Equal(3, snap.Count);
Assert.Empty(collector.GetMeasurementSnapshot());
Assert.Equal(0, collector.GetMeasurementSnapshot().Count);
}
}

Просмотреть файл

@ -77,7 +77,7 @@ public class HttpLatencyTelemetryHandlerTest
};
using var client = new System.Net.Http.HttpClient(handler);
await client.SendAsync(req, It.IsAny<CancellationToken>());
await client.SendAsync(req, It.IsAny<CancellationToken>()).ConfigureAwait(false);
Assert.Null(context.Get());
}

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше