Merge pull request dotnet/extensions#2155 from dotnet-maestro-bot/merge/release/3.0-to-master

[automated] Merge branch 'release/3.0' => 'master'\n\nCommit migrated from 3f8ee552a0
This commit is contained in:
John Luo 2019-08-13 13:52:44 -07:00 committed by GitHub
commit a980601d83
41 changed files with 1466 additions and 211 deletions

View File

@ -1,11 +1,16 @@
<!-- This file is automatically generated. --> <!-- This file is automatically generated. -->
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks> <TargetFrameworks>netstandard2.0;netcoreapp5.0</TargetFrameworks>
</PropertyGroup> </PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'"> <ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<Compile Include="Microsoft.Extensions.Configuration.KeyPerFile.netstandard2.0.cs" /> <Compile Include="Microsoft.Extensions.Configuration.KeyPerFile.netstandard2.0.cs" />
<Reference Include="Microsoft.Extensions.Configuration" /> <Reference Include="Microsoft.Extensions.Configuration" />
<Reference Include="Microsoft.Extensions.FileProviders.Physical" /> <Reference Include="Microsoft.Extensions.FileProviders.Physical" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp5.0'">
<Compile Include="Microsoft.Extensions.Configuration.KeyPerFile.netcoreapp5.0.cs" />
<Reference Include="Microsoft.Extensions.Configuration" />
<Reference Include="Microsoft.Extensions.FileProviders.Physical" />
</ItemGroup>
</Project> </Project>

View File

@ -0,0 +1,29 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.Extensions.Configuration
{
public static partial class KeyPerFileConfigurationBuilderExtensions
{
public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddKeyPerFile(this Microsoft.Extensions.Configuration.IConfigurationBuilder builder, System.Action<Microsoft.Extensions.Configuration.KeyPerFile.KeyPerFileConfigurationSource> configureSource) { throw null; }
public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddKeyPerFile(this Microsoft.Extensions.Configuration.IConfigurationBuilder builder, string directoryPath, bool optional) { throw null; }
}
}
namespace Microsoft.Extensions.Configuration.KeyPerFile
{
public partial class KeyPerFileConfigurationProvider : Microsoft.Extensions.Configuration.ConfigurationProvider
{
public KeyPerFileConfigurationProvider(Microsoft.Extensions.Configuration.KeyPerFile.KeyPerFileConfigurationSource source) { }
public override void Load() { }
public override string ToString() { throw null; }
}
public partial class KeyPerFileConfigurationSource : Microsoft.Extensions.Configuration.IConfigurationSource
{
public KeyPerFileConfigurationSource() { }
public Microsoft.Extensions.FileProviders.IFileProvider FileProvider { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public System.Func<string, bool> IgnoreCondition { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public string IgnorePrefix { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public bool Optional { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public Microsoft.Extensions.Configuration.IConfigurationProvider Build(Microsoft.Extensions.Configuration.IConfigurationBuilder builder) { throw null; }
}
}

View File

@ -0,0 +1,29 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.Extensions.Configuration
{
public static partial class KeyPerFileConfigurationBuilderExtensions
{
public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddKeyPerFile(this Microsoft.Extensions.Configuration.IConfigurationBuilder builder, System.Action<Microsoft.Extensions.Configuration.KeyPerFile.KeyPerFileConfigurationSource> configureSource) { throw null; }
public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddKeyPerFile(this Microsoft.Extensions.Configuration.IConfigurationBuilder builder, string directoryPath, bool optional) { throw null; }
}
}
namespace Microsoft.Extensions.Configuration.KeyPerFile
{
public partial class KeyPerFileConfigurationProvider : Microsoft.Extensions.Configuration.ConfigurationProvider
{
public KeyPerFileConfigurationProvider(Microsoft.Extensions.Configuration.KeyPerFile.KeyPerFileConfigurationSource source) { }
public override void Load() { }
public override string ToString() { throw null; }
}
public partial class KeyPerFileConfigurationSource : Microsoft.Extensions.Configuration.IConfigurationSource
{
public KeyPerFileConfigurationSource() { }
public Microsoft.Extensions.FileProviders.IFileProvider FileProvider { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public System.Func<string, bool> IgnoreCondition { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public string IgnorePrefix { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public bool Optional { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public Microsoft.Extensions.Configuration.IConfigurationProvider Build(Microsoft.Extensions.Configuration.IConfigurationBuilder builder) { throw null; }
}
}

View File

@ -2,7 +2,8 @@
<PropertyGroup> <PropertyGroup>
<Description>Configuration provider that uses files in a directory for Microsoft.Extensions.Configuration.</Description> <Description>Configuration provider that uses files in a directory for Microsoft.Extensions.Configuration.</Description>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFrameworks>netstandard2.0;netcoreapp5.0</TargetFrameworks>
<TargetFrameworks Condition="'$(DotNetBuildFromSource)' == 'true'">netcoreapp5.0</TargetFrameworks>
<IsPackable>true</IsPackable> <IsPackable>true</IsPackable>
<IsShipping>true</IsShipping> <IsShipping>true</IsShipping>
</PropertyGroup> </PropertyGroup>

View File

@ -1,10 +1,14 @@
<!-- This file is automatically generated. --> <!-- This file is automatically generated. -->
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks> <TargetFrameworks>netstandard2.0;netcoreapp5.0</TargetFrameworks>
</PropertyGroup> </PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'"> <ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<Compile Include="Microsoft.Extensions.FileProviders.Embedded.netstandard2.0.cs" /> <Compile Include="Microsoft.Extensions.FileProviders.Embedded.netstandard2.0.cs" />
<Reference Include="Microsoft.Extensions.FileProviders.Abstractions" /> <Reference Include="Microsoft.Extensions.FileProviders.Abstractions" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp5.0'">
<Compile Include="Microsoft.Extensions.FileProviders.Embedded.netcoreapp5.0.cs" />
<Reference Include="Microsoft.Extensions.FileProviders.Abstractions" />
</ItemGroup>
</Project> </Project>

View File

@ -0,0 +1,39 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.Extensions.FileProviders
{
public partial class EmbeddedFileProvider : Microsoft.Extensions.FileProviders.IFileProvider
{
public EmbeddedFileProvider(System.Reflection.Assembly assembly) { }
public EmbeddedFileProvider(System.Reflection.Assembly assembly, string baseNamespace) { }
public Microsoft.Extensions.FileProviders.IDirectoryContents GetDirectoryContents(string subpath) { throw null; }
public Microsoft.Extensions.FileProviders.IFileInfo GetFileInfo(string subpath) { throw null; }
public Microsoft.Extensions.Primitives.IChangeToken Watch(string pattern) { throw null; }
}
public partial class ManifestEmbeddedFileProvider : Microsoft.Extensions.FileProviders.IFileProvider
{
public ManifestEmbeddedFileProvider(System.Reflection.Assembly assembly) { }
public ManifestEmbeddedFileProvider(System.Reflection.Assembly assembly, string root) { }
public ManifestEmbeddedFileProvider(System.Reflection.Assembly assembly, string root, System.DateTimeOffset lastModified) { }
public ManifestEmbeddedFileProvider(System.Reflection.Assembly assembly, string root, string manifestName, System.DateTimeOffset lastModified) { }
public System.Reflection.Assembly Assembly { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.Extensions.FileProviders.IDirectoryContents GetDirectoryContents(string subpath) { throw null; }
public Microsoft.Extensions.FileProviders.IFileInfo GetFileInfo(string subpath) { throw null; }
public Microsoft.Extensions.Primitives.IChangeToken Watch(string filter) { throw null; }
}
}
namespace Microsoft.Extensions.FileProviders.Embedded
{
public partial class EmbeddedResourceFileInfo : Microsoft.Extensions.FileProviders.IFileInfo
{
public EmbeddedResourceFileInfo(System.Reflection.Assembly assembly, string resourcePath, string name, System.DateTimeOffset lastModified) { }
public bool Exists { get { throw null; } }
public bool IsDirectory { get { throw null; } }
public System.DateTimeOffset LastModified { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public long Length { get { throw null; } }
public string Name { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public string PhysicalPath { get { throw null; } }
public System.IO.Stream CreateReadStream() { throw null; }
}
}

View File

@ -0,0 +1,39 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.Extensions.FileProviders
{
public partial class EmbeddedFileProvider : Microsoft.Extensions.FileProviders.IFileProvider
{
public EmbeddedFileProvider(System.Reflection.Assembly assembly) { }
public EmbeddedFileProvider(System.Reflection.Assembly assembly, string baseNamespace) { }
public Microsoft.Extensions.FileProviders.IDirectoryContents GetDirectoryContents(string subpath) { throw null; }
public Microsoft.Extensions.FileProviders.IFileInfo GetFileInfo(string subpath) { throw null; }
public Microsoft.Extensions.Primitives.IChangeToken Watch(string pattern) { throw null; }
}
public partial class ManifestEmbeddedFileProvider : Microsoft.Extensions.FileProviders.IFileProvider
{
public ManifestEmbeddedFileProvider(System.Reflection.Assembly assembly) { }
public ManifestEmbeddedFileProvider(System.Reflection.Assembly assembly, string root) { }
public ManifestEmbeddedFileProvider(System.Reflection.Assembly assembly, string root, System.DateTimeOffset lastModified) { }
public ManifestEmbeddedFileProvider(System.Reflection.Assembly assembly, string root, string manifestName, System.DateTimeOffset lastModified) { }
public System.Reflection.Assembly Assembly { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.Extensions.FileProviders.IDirectoryContents GetDirectoryContents(string subpath) { throw null; }
public Microsoft.Extensions.FileProviders.IFileInfo GetFileInfo(string subpath) { throw null; }
public Microsoft.Extensions.Primitives.IChangeToken Watch(string filter) { throw null; }
}
}
namespace Microsoft.Extensions.FileProviders.Embedded
{
public partial class EmbeddedResourceFileInfo : Microsoft.Extensions.FileProviders.IFileInfo
{
public EmbeddedResourceFileInfo(System.Reflection.Assembly assembly, string resourcePath, string name, System.DateTimeOffset lastModified) { }
public bool Exists { get { throw null; } }
public bool IsDirectory { get { throw null; } }
public System.DateTimeOffset LastModified { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public long Length { get { throw null; } }
public string Name { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public string PhysicalPath { get { throw null; } }
public System.IO.Stream CreateReadStream() { throw null; }
}
}

View File

@ -3,8 +3,10 @@
<PropertyGroup> <PropertyGroup>
<RootNamespace>Microsoft.Extensions.FileProviders</RootNamespace> <RootNamespace>Microsoft.Extensions.FileProviders</RootNamespace>
<Description>File provider for files in embedded resources for Microsoft.Extensions.FileProviders.</Description> <Description>File provider for files in embedded resources for Microsoft.Extensions.FileProviders.</Description>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFrameworks>netstandard2.0;netcoreapp5.0</TargetFrameworks>
<NuspecFile>$(MSBuildProjectName).nuspec</NuspecFile> <NuspecFile>$(MSBuildProjectName).multitarget.nuspec</NuspecFile>
<TargetFrameworks Condition="'$(DotNetBuildFromSource)' == 'true'">netcoreapp5.0</TargetFrameworks>
<NuspecFile Condition="'$(DotNetBuildFromSource)' == 'true'">$(MSBuildProjectName).netcoreapp5.0.nuspec</NuspecFile>
<IsPackable>true</IsPackable> <IsPackable>true</IsPackable>
<IsShipping>true</IsShipping> <IsShipping>true</IsShipping>
</PropertyGroup> </PropertyGroup>
@ -23,21 +25,12 @@
<SignedPackageFile Include="Microsoft.Extensions.FileProviders.Embedded.Manifest.Task.dll" Certificate="$(AssemblySigningCertName)" /> <SignedPackageFile Include="Microsoft.Extensions.FileProviders.Embedded.Manifest.Task.dll" Certificate="$(AssemblySigningCertName)" />
</ItemGroup> </ItemGroup>
<Target Name="PopulateNuspec" BeforeTargets="InitializeStandardNuspecProperties" DependsOnTargets="BuiltProjectOutputGroup;DocumentationProjectOutputGroup;DebugSymbolsProjectOutputGroup;"> <ItemGroup>
<PropertyGroup>
<_OutputBinary>@(BuiltProjectOutputGroupOutput)</_OutputBinary> <NuspecProperty Include="OutputBinary=$(OutputPath)**\$(AssemblyName).dll" />
<_OutputSymbol>@(DebugSymbolsProjectOutputGroupOutput)</_OutputSymbol> <NuspecProperty Include="OutputSymbol=$(OutputPath)**\$(AssemblyName).pdb" />
<_OutputDocumentation>@(DocumentationProjectOutputGroupOutput)</_OutputDocumentation> <NuspecProperty Include="OutputDocumentation=$(OutputPath)**\$(AssemblyName).xml" />
</PropertyGroup> <NuspecProperty Include="TaskAssemblyNetStandard=$(ArtifactsDir)bin\$(AssemblyName).Manifest.Task\$(Configuration)\netstandard2.0\$(AssemblyName).Manifest.Task.dll"/>
<ItemGroup> <NuspecProperty Include="TaskSymbolNetStandard=$(ArtifactsDir)bin\$(AssemblyName).Manifest.Task\$(Configuration)\netstandard2.0\$(AssemblyName).Manifest.Task.pdb" Condition="'$(DebugType)'!='embedded'"/>
<NuspecProperty Include="targetframework=$(TargetFramework)"/> </ItemGroup>
<NuspecProperty Include="AssemblyName=$(AssemblyName)"/>
<NuspecProperty Include="OutputBinary=$(_OutputBinary)"/>
<NuspecProperty Include="OutputSymbol=$(_OutputSymbol)"/>
<NuspecProperty Include="OutputDocumentation=$(_OutputDocumentation)"/>
<!-- Include the assembly and symbols from the tasks project -->
<NuspecProperty Include="TaskAssemblyNetStandard=$(ArtifactsDir)bin\$(AssemblyName).Manifest.Task\$(Configuration)\netstandard2.0\$(AssemblyName).Manifest.Task.dll"/>
<NuspecProperty Include="TaskSymbolNetStandard=$(ArtifactsDir)bin\$(AssemblyName).Manifest.Task\$(Configuration)\netstandard2.0\$(AssemblyName).Manifest.Task.pdb" Condition="'$(DebugType)'!='embedded'"/>
</ItemGroup>
</Target>
</Project> </Project>

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
$CommonMetadataElements$
<dependencies>
<group targetFramework=".NETCoreApp5.0">
<dependency id="Microsoft.Extensions.FileProviders.Abstractions" version="$version$" exclude="Build,Analyzers" />
</group>
<group targetFramework=".NETStandard2.0">
<dependency id="Microsoft.Extensions.FileProviders.Abstractions" version="$version$" exclude="Build,Analyzers" />
</group>
</dependencies>
</metadata>
<files>
<file src="$OutputBinary$" target="lib\" />
<file src="$OutputSymbol$" target="lib\" />
<file src="$OutputDocumentation$" target="lib\" />
<file src="build\**\*" target="build\" />
<file src="buildMultiTargeting\**\*" target="buildMultiTargeting\" />
<file src="$TaskAssemblyNetStandard$" target="tasks\netstandard2.0\$AssemblyName$.Manifest.Task.dll" />
<file src="$TaskSymbolNetStandard$" target="tasks\netstandard2.0\$AssemblyName$.Manifest.Task.pdb" />
</files>
</package>

View File

@ -3,16 +3,16 @@
<metadata> <metadata>
$CommonMetadataElements$ $CommonMetadataElements$
<dependencies> <dependencies>
<group targetFramework=".NETStandard2.0"> <group targetFramework=".NETCoreApp5.0">
<dependency id="Microsoft.Extensions.FileProviders.Abstractions" version="$version$" exclude="Build,Analyzers" /> <dependency id="Microsoft.Extensions.FileProviders.Abstractions" version="$version$" exclude="Build,Analyzers" />
</group> </group>
</dependencies> </dependencies>
</metadata> </metadata>
<files> <files>
<file src="$OutputBinary$" target="lib\$targetframework$\" /> <file src="$OutputBinary$" target="lib\" />
<file src="$OutputSymbol$" target="lib\$targetframework$\" /> <file src="$OutputSymbol$" target="lib\" />
<file src="$OutputDocumentation$" target="lib\$targetframework$\" /> <file src="$OutputDocumentation$" target="lib\" />
<file src="build\**\*" target="build\" /> <file src="build\**\*" target="build\" />
<file src="buildMultiTargeting\**\*" target="buildMultiTargeting\" /> <file src="buildMultiTargeting\**\*" target="buildMultiTargeting\" />
<file src="$TaskAssemblyNetStandard$" target="tasks\netstandard2.0\$AssemblyName$.Manifest.Task.dll" /> <file src="$TaskAssemblyNetStandard$" target="tasks\netstandard2.0\$AssemblyName$.Manifest.Task.dll" />

View File

@ -1,10 +1,14 @@
<!-- This file is automatically generated. --> <!-- This file is automatically generated. -->
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks> <TargetFrameworks>netstandard2.0;netcoreapp5.0</TargetFrameworks>
</PropertyGroup> </PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'"> <ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<Compile Include="Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions.netstandard2.0.cs" /> <Compile Include="Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions.netstandard2.0.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp5.0'">
<Compile Include="Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions.netcoreapp5.0.cs" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -0,0 +1,72 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.Extensions.Diagnostics.HealthChecks
{
public sealed partial class HealthCheckContext
{
public HealthCheckContext() { }
public Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckRegistration Registration { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
}
public sealed partial class HealthCheckRegistration
{
public HealthCheckRegistration(string name, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck instance, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable<string> tags) { }
public HealthCheckRegistration(string name, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck instance, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable<string> tags, System.TimeSpan? timeout) { }
public HealthCheckRegistration(string name, System.Func<System.IServiceProvider, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck> factory, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable<string> tags) { }
public HealthCheckRegistration(string name, System.Func<System.IServiceProvider, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck> factory, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable<string> tags, System.TimeSpan? timeout) { }
public System.Func<System.IServiceProvider, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck> Factory { get { throw null; } set { } }
public Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus FailureStatus { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public string Name { get { throw null; } set { } }
public System.Collections.Generic.ISet<string> Tags { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public System.TimeSpan Timeout { get { throw null; } set { } }
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public partial struct HealthCheckResult
{
private object _dummy;
private int _dummyPrimitive;
public HealthCheckResult(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus status, string description = null, System.Exception exception = null, System.Collections.Generic.IReadOnlyDictionary<string, object> data = null) { throw null; }
public System.Collections.Generic.IReadOnlyDictionary<string, object> Data { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public string Description { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public System.Exception Exception { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus Status { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public static Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckResult Degraded(string description = null, System.Exception exception = null, System.Collections.Generic.IReadOnlyDictionary<string, object> data = null) { throw null; }
public static Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckResult Healthy(string description = null, System.Collections.Generic.IReadOnlyDictionary<string, object> data = null) { throw null; }
public static Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckResult Unhealthy(string description = null, System.Exception exception = null, System.Collections.Generic.IReadOnlyDictionary<string, object> data = null) { throw null; }
}
public sealed partial class HealthReport
{
public HealthReport(System.Collections.Generic.IReadOnlyDictionary<string, Microsoft.Extensions.Diagnostics.HealthChecks.HealthReportEntry> entries, System.TimeSpan totalDuration) { }
public System.Collections.Generic.IReadOnlyDictionary<string, Microsoft.Extensions.Diagnostics.HealthChecks.HealthReportEntry> Entries { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus Status { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public System.TimeSpan TotalDuration { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public partial struct HealthReportEntry
{
private object _dummy;
private int _dummyPrimitive;
public HealthReportEntry(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus status, string description, System.TimeSpan duration, System.Exception exception, System.Collections.Generic.IReadOnlyDictionary<string, object> data) { throw null; }
public HealthReportEntry(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus status, string description, System.TimeSpan duration, System.Exception exception, System.Collections.Generic.IReadOnlyDictionary<string, object> data, System.Collections.Generic.IEnumerable<string> tags = null) { throw null; }
public System.Collections.Generic.IReadOnlyDictionary<string, object> Data { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public string Description { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public System.TimeSpan Duration { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public System.Exception Exception { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus Status { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public System.Collections.Generic.IEnumerable<string> Tags { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
public enum HealthStatus
{
Unhealthy = 0,
Degraded = 1,
Healthy = 2,
}
public partial interface IHealthCheck
{
System.Threading.Tasks.Task<Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckResult> CheckHealthAsync(Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckContext context, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
}
public partial interface IHealthCheckPublisher
{
System.Threading.Tasks.Task PublishAsync(Microsoft.Extensions.Diagnostics.HealthChecks.HealthReport report, System.Threading.CancellationToken cancellationToken);
}
}

View File

@ -0,0 +1,72 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.Extensions.Diagnostics.HealthChecks
{
public sealed partial class HealthCheckContext
{
public HealthCheckContext() { }
public Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckRegistration Registration { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
}
public sealed partial class HealthCheckRegistration
{
public HealthCheckRegistration(string name, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck instance, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable<string> tags) { }
public HealthCheckRegistration(string name, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck instance, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable<string> tags, System.TimeSpan? timeout) { }
public HealthCheckRegistration(string name, System.Func<System.IServiceProvider, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck> factory, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable<string> tags) { }
public HealthCheckRegistration(string name, System.Func<System.IServiceProvider, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck> factory, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable<string> tags, System.TimeSpan? timeout) { }
public System.Func<System.IServiceProvider, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck> Factory { get { throw null; } set { } }
public Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus FailureStatus { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public string Name { get { throw null; } set { } }
public System.Collections.Generic.ISet<string> Tags { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public System.TimeSpan Timeout { get { throw null; } set { } }
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public partial struct HealthCheckResult
{
private object _dummy;
private int _dummyPrimitive;
public HealthCheckResult(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus status, string description = null, System.Exception exception = null, System.Collections.Generic.IReadOnlyDictionary<string, object> data = null) { throw null; }
public System.Collections.Generic.IReadOnlyDictionary<string, object> Data { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public string Description { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public System.Exception Exception { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus Status { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public static Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckResult Degraded(string description = null, System.Exception exception = null, System.Collections.Generic.IReadOnlyDictionary<string, object> data = null) { throw null; }
public static Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckResult Healthy(string description = null, System.Collections.Generic.IReadOnlyDictionary<string, object> data = null) { throw null; }
public static Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckResult Unhealthy(string description = null, System.Exception exception = null, System.Collections.Generic.IReadOnlyDictionary<string, object> data = null) { throw null; }
}
public sealed partial class HealthReport
{
public HealthReport(System.Collections.Generic.IReadOnlyDictionary<string, Microsoft.Extensions.Diagnostics.HealthChecks.HealthReportEntry> entries, System.TimeSpan totalDuration) { }
public System.Collections.Generic.IReadOnlyDictionary<string, Microsoft.Extensions.Diagnostics.HealthChecks.HealthReportEntry> Entries { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus Status { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public System.TimeSpan TotalDuration { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public partial struct HealthReportEntry
{
private object _dummy;
private int _dummyPrimitive;
public HealthReportEntry(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus status, string description, System.TimeSpan duration, System.Exception exception, System.Collections.Generic.IReadOnlyDictionary<string, object> data) { throw null; }
public HealthReportEntry(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus status, string description, System.TimeSpan duration, System.Exception exception, System.Collections.Generic.IReadOnlyDictionary<string, object> data, System.Collections.Generic.IEnumerable<string> tags = null) { throw null; }
public System.Collections.Generic.IReadOnlyDictionary<string, object> Data { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public string Description { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public System.TimeSpan Duration { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public System.Exception Exception { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus Status { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public System.Collections.Generic.IEnumerable<string> Tags { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
public enum HealthStatus
{
Unhealthy = 0,
Degraded = 1,
Healthy = 2,
}
public partial interface IHealthCheck
{
System.Threading.Tasks.Task<Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckResult> CheckHealthAsync(Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckContext context, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
}
public partial interface IHealthCheckPublisher
{
System.Threading.Tasks.Task PublishAsync(Microsoft.Extensions.Diagnostics.HealthChecks.HealthReport report, System.Threading.CancellationToken cancellationToken);
}
}

View File

@ -7,7 +7,8 @@ Commonly Used Types
Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck
</Description> </Description>
<RootNamespace>Microsoft.Extensions.Diagnostics.HealthChecks</RootNamespace> <RootNamespace>Microsoft.Extensions.Diagnostics.HealthChecks</RootNamespace>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFrameworks>netstandard2.0;netcoreapp5.0</TargetFrameworks>
<TargetFrameworks Condition="'$(DotNetBuildFromSource)' == 'true'">netcoreapp5.0</TargetFrameworks>
<NoWarn>$(NoWarn);CS1591</NoWarn> <NoWarn>$(NoWarn);CS1591</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>diagnostics;healthchecks</PackageTags> <PackageTags>diagnostics;healthchecks</PackageTags>

View File

@ -1,7 +1,7 @@
<!-- This file is automatically generated. --> <!-- This file is automatically generated. -->
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks> <TargetFrameworks>netstandard2.0;netcoreapp5.0</TargetFrameworks>
</PropertyGroup> </PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'"> <ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<Compile Include="Microsoft.Extensions.Diagnostics.HealthChecks.netstandard2.0.cs" /> <Compile Include="Microsoft.Extensions.Diagnostics.HealthChecks.netstandard2.0.cs" />
@ -9,4 +9,10 @@
<Reference Include="Microsoft.Extensions.Hosting.Abstractions" /> <Reference Include="Microsoft.Extensions.Hosting.Abstractions" />
<Reference Include="Microsoft.Extensions.Options" /> <Reference Include="Microsoft.Extensions.Options" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp5.0'">
<Compile Include="Microsoft.Extensions.Diagnostics.HealthChecks.netcoreapp5.0.cs" />
<Reference Include="Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions" />
<Reference Include="Microsoft.Extensions.Hosting.Abstractions" />
<Reference Include="Microsoft.Extensions.Options" />
</ItemGroup>
</Project> </Project>

View File

@ -0,0 +1,59 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.Extensions.DependencyInjection
{
public static partial class HealthChecksBuilderAddCheckExtensions
{
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck instance, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable<string> tags) { throw null; }
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck instance, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus = default(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus?), System.Collections.Generic.IEnumerable<string> tags = null, System.TimeSpan? timeout = default(System.TimeSpan?)) { throw null; }
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck<T>(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable<string> tags) where T : class, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck { throw null; }
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck<T>(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus = default(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus?), System.Collections.Generic.IEnumerable<string> tags = null, System.TimeSpan? timeout = default(System.TimeSpan?)) where T : class, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck { throw null; }
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddTypeActivatedCheck<T>(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable<string> tags, params object[] args) where T : class, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck { throw null; }
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddTypeActivatedCheck<T>(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable<string> tags, System.TimeSpan timeout, params object[] args) where T : class, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck { throw null; }
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddTypeActivatedCheck<T>(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, params object[] args) where T : class, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck { throw null; }
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddTypeActivatedCheck<T>(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, params object[] args) where T : class, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck { throw null; }
}
public static partial class HealthChecksBuilderDelegateExtensions
{
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddAsyncCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func<System.Threading.CancellationToken, System.Threading.Tasks.Task<Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckResult>> check, System.Collections.Generic.IEnumerable<string> tags) { throw null; }
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddAsyncCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func<System.Threading.CancellationToken, System.Threading.Tasks.Task<Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckResult>> check, System.Collections.Generic.IEnumerable<string> tags = null, System.TimeSpan? timeout = default(System.TimeSpan?)) { throw null; }
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddAsyncCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func<System.Threading.Tasks.Task<Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckResult>> check, System.Collections.Generic.IEnumerable<string> tags) { throw null; }
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddAsyncCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func<System.Threading.Tasks.Task<Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckResult>> check, System.Collections.Generic.IEnumerable<string> tags = null, System.TimeSpan? timeout = default(System.TimeSpan?)) { throw null; }
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func<Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckResult> check, System.Collections.Generic.IEnumerable<string> tags) { throw null; }
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func<Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckResult> check, System.Collections.Generic.IEnumerable<string> tags = null, System.TimeSpan? timeout = default(System.TimeSpan?)) { throw null; }
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func<System.Threading.CancellationToken, Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckResult> check, System.Collections.Generic.IEnumerable<string> tags) { throw null; }
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func<System.Threading.CancellationToken, Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckResult> check, System.Collections.Generic.IEnumerable<string> tags = null, System.TimeSpan? timeout = default(System.TimeSpan?)) { throw null; }
}
public static partial class HealthCheckServiceCollectionExtensions
{
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddHealthChecks(this Microsoft.Extensions.DependencyInjection.IServiceCollection services) { throw null; }
}
public partial interface IHealthChecksBuilder
{
Microsoft.Extensions.DependencyInjection.IServiceCollection Services { get; }
Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder Add(Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckRegistration registration);
}
}
namespace Microsoft.Extensions.Diagnostics.HealthChecks
{
public sealed partial class HealthCheckPublisherOptions
{
public HealthCheckPublisherOptions() { }
public System.TimeSpan Delay { get { throw null; } set { } }
public System.TimeSpan Period { get { throw null; } set { } }
public System.Func<Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckRegistration, bool> Predicate { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public System.TimeSpan Timeout { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
}
public abstract partial class HealthCheckService
{
protected HealthCheckService() { }
public abstract System.Threading.Tasks.Task<Microsoft.Extensions.Diagnostics.HealthChecks.HealthReport> CheckHealthAsync(System.Func<Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckRegistration, bool> predicate, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
public System.Threading.Tasks.Task<Microsoft.Extensions.Diagnostics.HealthChecks.HealthReport> CheckHealthAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
}
public sealed partial class HealthCheckServiceOptions
{
public HealthCheckServiceOptions() { }
public System.Collections.Generic.ICollection<Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckRegistration> Registrations { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
}

View File

@ -0,0 +1,59 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.Extensions.DependencyInjection
{
public static partial class HealthChecksBuilderAddCheckExtensions
{
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck instance, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable<string> tags) { throw null; }
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck instance, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus = default(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus?), System.Collections.Generic.IEnumerable<string> tags = null, System.TimeSpan? timeout = default(System.TimeSpan?)) { throw null; }
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck<T>(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable<string> tags) where T : class, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck { throw null; }
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck<T>(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus = default(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus?), System.Collections.Generic.IEnumerable<string> tags = null, System.TimeSpan? timeout = default(System.TimeSpan?)) where T : class, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck { throw null; }
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddTypeActivatedCheck<T>(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable<string> tags, params object[] args) where T : class, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck { throw null; }
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddTypeActivatedCheck<T>(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, System.Collections.Generic.IEnumerable<string> tags, System.TimeSpan timeout, params object[] args) where T : class, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck { throw null; }
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddTypeActivatedCheck<T>(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus, params object[] args) where T : class, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck { throw null; }
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddTypeActivatedCheck<T>(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, params object[] args) where T : class, Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck { throw null; }
}
public static partial class HealthChecksBuilderDelegateExtensions
{
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddAsyncCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func<System.Threading.CancellationToken, System.Threading.Tasks.Task<Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckResult>> check, System.Collections.Generic.IEnumerable<string> tags) { throw null; }
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddAsyncCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func<System.Threading.CancellationToken, System.Threading.Tasks.Task<Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckResult>> check, System.Collections.Generic.IEnumerable<string> tags = null, System.TimeSpan? timeout = default(System.TimeSpan?)) { throw null; }
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddAsyncCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func<System.Threading.Tasks.Task<Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckResult>> check, System.Collections.Generic.IEnumerable<string> tags) { throw null; }
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddAsyncCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func<System.Threading.Tasks.Task<Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckResult>> check, System.Collections.Generic.IEnumerable<string> tags = null, System.TimeSpan? timeout = default(System.TimeSpan?)) { throw null; }
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func<Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckResult> check, System.Collections.Generic.IEnumerable<string> tags) { throw null; }
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func<Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckResult> check, System.Collections.Generic.IEnumerable<string> tags = null, System.TimeSpan? timeout = default(System.TimeSpan?)) { throw null; }
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func<System.Threading.CancellationToken, Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckResult> check, System.Collections.Generic.IEnumerable<string> tags) { throw null; }
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddCheck(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string name, System.Func<System.Threading.CancellationToken, Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckResult> check, System.Collections.Generic.IEnumerable<string> tags = null, System.TimeSpan? timeout = default(System.TimeSpan?)) { throw null; }
}
public static partial class HealthCheckServiceCollectionExtensions
{
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddHealthChecks(this Microsoft.Extensions.DependencyInjection.IServiceCollection services) { throw null; }
}
public partial interface IHealthChecksBuilder
{
Microsoft.Extensions.DependencyInjection.IServiceCollection Services { get; }
Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder Add(Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckRegistration registration);
}
}
namespace Microsoft.Extensions.Diagnostics.HealthChecks
{
public sealed partial class HealthCheckPublisherOptions
{
public HealthCheckPublisherOptions() { }
public System.TimeSpan Delay { get { throw null; } set { } }
public System.TimeSpan Period { get { throw null; } set { } }
public System.Func<Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckRegistration, bool> Predicate { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public System.TimeSpan Timeout { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
}
public abstract partial class HealthCheckService
{
protected HealthCheckService() { }
public abstract System.Threading.Tasks.Task<Microsoft.Extensions.Diagnostics.HealthChecks.HealthReport> CheckHealthAsync(System.Func<Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckRegistration, bool> predicate, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
public System.Threading.Tasks.Task<Microsoft.Extensions.Diagnostics.HealthChecks.HealthReport> CheckHealthAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
}
public sealed partial class HealthCheckServiceOptions
{
public HealthCheckServiceOptions() { }
public System.Collections.Generic.ICollection<Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckRegistration> Registrations { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
}

View File

@ -6,7 +6,8 @@ Commonly Used Types:
Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckService Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckService
Microsoft.Extensions.Diagnostics.HealthChecks.IHealthChecksBuilder Microsoft.Extensions.Diagnostics.HealthChecks.IHealthChecksBuilder
</Description> </Description>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFrameworks>netstandard2.0;netcoreapp5.0</TargetFrameworks>
<TargetFrameworks Condition="'$(DotNetBuildFromSource)' == 'true'">netcoreapp5.0</TargetFrameworks>
<NoWarn>$(NoWarn);CS1591</NoWarn> <NoWarn>$(NoWarn);CS1591</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>diagnostics;healthchecks</PackageTags> <PackageTags>diagnostics;healthchecks</PackageTags>

View File

@ -1,10 +1,14 @@
<!-- This file is automatically generated. --> <!-- This file is automatically generated. -->
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks> <TargetFrameworks>netstandard2.0;netcoreapp5.0</TargetFrameworks>
</PropertyGroup> </PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'"> <ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<Compile Include="Microsoft.JSInterop.netstandard2.0.cs" /> <Compile Include="Microsoft.JSInterop.netstandard2.0.cs" />
<Reference Include="System.Text.Json" /> <Reference Include="System.Text.Json" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp5.0'">
<Compile Include="Microsoft.JSInterop.netcoreapp5.0.cs" />
</ItemGroup>
</Project> </Project>

View File

@ -0,0 +1,64 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.JSInterop
{
public static partial class DotNetDispatcher
{
public static void BeginInvoke(string callId, string assemblyName, string methodIdentifier, long dotNetObjectId, string argsJson) { }
public static void EndInvoke(string arguments) { }
public static string Invoke(string assemblyName, string methodIdentifier, long dotNetObjectId, string argsJson) { throw null; }
[Microsoft.JSInterop.JSInvokableAttribute("DotNetDispatcher.ReleaseDotNetObject")]
public static void ReleaseDotNetObject(long dotNetObjectId) { }
}
public static partial class DotNetObjectRef
{
public static Microsoft.JSInterop.DotNetObjectRef<TValue> Create<TValue>(TValue value) where TValue : class { throw null; }
}
public sealed partial class DotNetObjectRef<TValue> : System.IDisposable where TValue : class
{
internal DotNetObjectRef() { }
public TValue Value { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public void Dispose() { }
}
public partial interface IJSInProcessRuntime : Microsoft.JSInterop.IJSRuntime
{
T Invoke<T>(string identifier, params object[] args);
}
public partial interface IJSRuntime
{
System.Threading.Tasks.Task<TValue> InvokeAsync<TValue>(string identifier, System.Collections.Generic.IEnumerable<object> args, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
System.Threading.Tasks.Task<TValue> InvokeAsync<TValue>(string identifier, params object[] args);
}
public partial class JSException : System.Exception
{
public JSException(string message) { }
public JSException(string message, System.Exception innerException) { }
}
public abstract partial class JSInProcessRuntimeBase : Microsoft.JSInterop.JSRuntimeBase, Microsoft.JSInterop.IJSInProcessRuntime, Microsoft.JSInterop.IJSRuntime
{
protected JSInProcessRuntimeBase() { }
protected abstract string InvokeJS(string identifier, string argsJson);
public TValue Invoke<TValue>(string identifier, params object[] args) { throw null; }
}
[System.AttributeUsageAttribute(System.AttributeTargets.Method, AllowMultiple=true)]
public partial class JSInvokableAttribute : System.Attribute
{
public JSInvokableAttribute() { }
public JSInvokableAttribute(string identifier) { }
public string Identifier { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
public static partial class JSRuntime
{
public static void SetCurrentJSRuntime(Microsoft.JSInterop.IJSRuntime instance) { }
}
public abstract partial class JSRuntimeBase : Microsoft.JSInterop.IJSRuntime
{
protected JSRuntimeBase() { }
protected System.TimeSpan? DefaultAsyncTimeout { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
protected abstract void BeginInvokeJS(long taskId, string identifier, string argsJson);
protected internal abstract void EndInvokeDotNet(string callId, bool success, object resultOrError, string assemblyName, string methodIdentifier, long dotNetObjectId);
public System.Threading.Tasks.Task<T> InvokeAsync<T>(string identifier, System.Collections.Generic.IEnumerable<object> args, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public System.Threading.Tasks.Task<T> InvokeAsync<T>(string identifier, params object[] args) { throw null; }
}
}

View File

@ -0,0 +1,64 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.JSInterop
{
public static partial class DotNetDispatcher
{
public static void BeginInvoke(string callId, string assemblyName, string methodIdentifier, long dotNetObjectId, string argsJson) { }
public static void EndInvoke(string arguments) { }
public static string Invoke(string assemblyName, string methodIdentifier, long dotNetObjectId, string argsJson) { throw null; }
[Microsoft.JSInterop.JSInvokableAttribute("DotNetDispatcher.ReleaseDotNetObject")]
public static void ReleaseDotNetObject(long dotNetObjectId) { }
}
public static partial class DotNetObjectRef
{
public static Microsoft.JSInterop.DotNetObjectRef<TValue> Create<TValue>(TValue value) where TValue : class { throw null; }
}
public sealed partial class DotNetObjectRef<TValue> : System.IDisposable where TValue : class
{
internal DotNetObjectRef() { }
public TValue Value { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public void Dispose() { }
}
public partial interface IJSInProcessRuntime : Microsoft.JSInterop.IJSRuntime
{
T Invoke<T>(string identifier, params object[] args);
}
public partial interface IJSRuntime
{
System.Threading.Tasks.Task<TValue> InvokeAsync<TValue>(string identifier, System.Collections.Generic.IEnumerable<object> args, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
System.Threading.Tasks.Task<TValue> InvokeAsync<TValue>(string identifier, params object[] args);
}
public partial class JSException : System.Exception
{
public JSException(string message) { }
public JSException(string message, System.Exception innerException) { }
}
public abstract partial class JSInProcessRuntimeBase : Microsoft.JSInterop.JSRuntimeBase, Microsoft.JSInterop.IJSInProcessRuntime, Microsoft.JSInterop.IJSRuntime
{
protected JSInProcessRuntimeBase() { }
protected abstract string InvokeJS(string identifier, string argsJson);
public TValue Invoke<TValue>(string identifier, params object[] args) { throw null; }
}
[System.AttributeUsageAttribute(System.AttributeTargets.Method, AllowMultiple=true)]
public partial class JSInvokableAttribute : System.Attribute
{
public JSInvokableAttribute() { }
public JSInvokableAttribute(string identifier) { }
public string Identifier { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
public static partial class JSRuntime
{
public static void SetCurrentJSRuntime(Microsoft.JSInterop.IJSRuntime instance) { }
}
public abstract partial class JSRuntimeBase : Microsoft.JSInterop.IJSRuntime
{
protected JSRuntimeBase() { }
protected System.TimeSpan? DefaultAsyncTimeout { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
protected abstract void BeginInvokeJS(long taskId, string identifier, string argsJson);
protected internal abstract void EndInvokeDotNet(string callId, bool success, object resultOrError, string assemblyName, string methodIdentifier, long dotNetObjectId);
public System.Threading.Tasks.Task<T> InvokeAsync<T>(string identifier, System.Collections.Generic.IEnumerable<object> args, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public System.Threading.Tasks.Task<T> InvokeAsync<T>(string identifier, params object[] args) { throw null; }
}
}

View File

@ -7,6 +7,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Runtime.ExceptionServices; using System.Runtime.ExceptionServices;
using System.Text;
using System.Text.Json; using System.Text.Json;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -18,7 +19,6 @@ namespace Microsoft.JSInterop
public static class DotNetDispatcher public static class DotNetDispatcher
{ {
internal static readonly JsonEncodedText DotNetObjectRefKey = JsonEncodedText.Encode("__dotNetObject"); internal static readonly JsonEncodedText DotNetObjectRefKey = JsonEncodedText.Encode("__dotNetObject");
private static readonly Type[] EndInvokeParameterTypes = new Type[] { typeof(long), typeof(bool), typeof(JSAsyncCallResult) };
private static readonly ConcurrentDictionary<AssemblyKey, IReadOnlyDictionary<string, (MethodInfo, Type[])>> _cachedMethodsByAssembly private static readonly ConcurrentDictionary<AssemblyKey, IReadOnlyDictionary<string, (MethodInfo, Type[])>> _cachedMethodsByAssembly
= new ConcurrentDictionary<AssemblyKey, IReadOnlyDictionary<string, (MethodInfo, Type[])>>(); = new ConcurrentDictionary<AssemblyKey, IReadOnlyDictionary<string, (MethodInfo, Type[])>>();
@ -74,7 +74,6 @@ namespace Microsoft.JSInterop
// code has to implement its own way of returning async results. // code has to implement its own way of returning async results.
var jsRuntimeBaseInstance = (JSRuntimeBase)JSRuntime.Current; var jsRuntimeBaseInstance = (JSRuntimeBase)JSRuntime.Current;
// Using ExceptionDispatchInfo here throughout because we want to always preserve // Using ExceptionDispatchInfo here throughout because we want to always preserve
// original stack traces. // original stack traces.
object syncResult = null; object syncResult = null;
@ -165,81 +164,64 @@ namespace Microsoft.JSInterop
} }
} }
private static object[] ParseArguments(string methodIdentifier, string argsJson, Type[] parameterTypes) internal static object[] ParseArguments(string methodIdentifier, string arguments, Type[] parameterTypes)
{ {
if (parameterTypes.Length == 0) if (parameterTypes.Length == 0)
{ {
return Array.Empty<object>(); return Array.Empty<object>();
} }
// There's no direct way to say we want to deserialize as an array with heterogenous var utf8JsonBytes = Encoding.UTF8.GetBytes(arguments);
// entry types (e.g., [string, int, bool]), so we need to deserialize in two phases. var reader = new Utf8JsonReader(utf8JsonBytes);
var jsonDocument = JsonDocument.Parse(argsJson); if (!reader.Read() || reader.TokenType != JsonTokenType.StartArray)
var shouldDisposeJsonDocument = true;
try
{ {
if (jsonDocument.RootElement.ValueKind != JsonValueKind.Array) throw new JsonException("Invalid JSON");
{
throw new ArgumentException($"Expected a JSON array but got {jsonDocument.RootElement.ValueKind}.");
}
var suppliedArgsLength = jsonDocument.RootElement.GetArrayLength();
if (suppliedArgsLength != parameterTypes.Length)
{
throw new ArgumentException($"In call to '{methodIdentifier}', expected {parameterTypes.Length} parameters but received {suppliedArgsLength}.");
}
// Second, convert each supplied value to the type expected by the method
var suppliedArgs = new object[parameterTypes.Length];
var index = 0;
foreach (var item in jsonDocument.RootElement.EnumerateArray())
{
var parameterType = parameterTypes[index];
if (parameterType == typeof(JSAsyncCallResult))
{
// We will pass the JsonDocument instance to JAsyncCallResult and make JSRuntimeBase
// responsible for disposing it.
shouldDisposeJsonDocument = false;
// For JS async call results, we have to defer the deserialization until
// later when we know what type it's meant to be deserialized as
suppliedArgs[index] = new JSAsyncCallResult(jsonDocument, item);
}
else if (IsIncorrectDotNetObjectRefUse(item, parameterType))
{
throw new InvalidOperationException($"In call to '{methodIdentifier}', parameter of type '{parameterType.Name}' at index {(index + 1)} must be declared as type 'DotNetObjectRef<{parameterType.Name}>' to receive the incoming value.");
}
else
{
suppliedArgs[index] = JsonSerializer.Deserialize(item.GetRawText(), parameterType, JsonSerializerOptionsProvider.Options);
}
index++;
}
if (shouldDisposeJsonDocument)
{
jsonDocument.Dispose();
}
return suppliedArgs;
}
catch
{
// Always dispose the JsonDocument in case of an error.
jsonDocument?.Dispose();
throw;
} }
static bool IsIncorrectDotNetObjectRefUse(JsonElement item, Type parameterType) var suppliedArgs = new object[parameterTypes.Length];
var index = 0;
while (index < parameterTypes.Length && reader.Read() && reader.TokenType != JsonTokenType.EndArray)
{
var parameterType = parameterTypes[index];
if (reader.TokenType == JsonTokenType.StartObject && IsIncorrectDotNetObjectRefUse(parameterType, reader))
{
throw new InvalidOperationException($"In call to '{methodIdentifier}', parameter of type '{parameterType.Name}' at index {(index + 1)} must be declared as type 'DotNetObjectRef<{parameterType.Name}>' to receive the incoming value.");
}
suppliedArgs[index] = JsonSerializer.Deserialize(ref reader, parameterType, JsonSerializerOptionsProvider.Options);
index++;
}
if (index < parameterTypes.Length)
{
// If we parsed fewer parameters, we can always make a definitive claim about how many parameters were received.
throw new ArgumentException($"The call to '{methodIdentifier}' expects '{parameterTypes.Length}' parameters, but received '{index}'.");
}
if (!reader.Read() || reader.TokenType != JsonTokenType.EndArray)
{
// Either we received more parameters than we expected or the JSON is malformed.
throw new JsonException($"Unexpected JSON token {reader.TokenType}. Ensure that the call to `{methodIdentifier}' is supplied with exactly '{parameterTypes.Length}' parameters.");
}
return suppliedArgs;
// Note that the JsonReader instance is intentionally not passed by ref (or an in parameter) since we want a copy of the original reader.
static bool IsIncorrectDotNetObjectRefUse(Type parameterType, Utf8JsonReader jsonReader)
{ {
// Check for incorrect use of DotNetObjectRef<T> at the top level. We know it's // Check for incorrect use of DotNetObjectRef<T> at the top level. We know it's
// an incorrect use if there's a object that looks like { '__dotNetObject': <some number> }, // an incorrect use if there's a object that looks like { '__dotNetObject': <some number> },
// but we aren't assigning to DotNetObjectRef{T}. // but we aren't assigning to DotNetObjectRef{T}.
return item.ValueKind == JsonValueKind.Object && if (jsonReader.Read() &&
item.TryGetProperty(DotNetObjectRefKey.EncodedUtf8Bytes, out _) && jsonReader.TokenType == JsonTokenType.PropertyName &&
!typeof(IDotNetObjectRef).IsAssignableFrom(parameterType); jsonReader.ValueTextEquals(DotNetObjectRefKey.EncodedUtf8Bytes))
{
// The JSON payload has the shape we expect from a DotNetObjectRef instance.
return !parameterType.IsGenericType || parameterType.GetGenericTypeDefinition() != typeof(DotNetObjectRef<>);
}
return false;
} }
} }
@ -248,9 +230,9 @@ namespace Microsoft.JSInterop
/// associated <see cref="Task"/> as completed. /// associated <see cref="Task"/> as completed.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// All exceptions from <see cref="EndInvoke(long, bool, JSAsyncCallResult)"/> are caught /// All exceptions from <see cref="EndInvoke"/> are caught
/// are delivered via JS interop to the JavaScript side when it requests confirmation, as /// are delivered via JS interop to the JavaScript side when it requests confirmation, as
/// the mechanism to call <see cref="EndInvoke(long, bool, JSAsyncCallResult)"/> relies on /// the mechanism to call <see cref="EndInvoke"/> relies on
/// using JS->.NET interop. This overload is meant for directly triggering completion callbacks /// using JS->.NET interop. This overload is meant for directly triggering completion callbacks
/// for .NET -> JS operations without going through JS interop, so the callsite for this /// for .NET -> JS operations without going through JS interop, so the callsite for this
/// method is responsible for handling any possible exception generated from the arguments /// method is responsible for handling any possible exception generated from the arguments
@ -263,16 +245,40 @@ namespace Microsoft.JSInterop
/// </exception> /// </exception>
public static void EndInvoke(string arguments) public static void EndInvoke(string arguments)
{ {
var parsedArgs = ParseArguments( var jsRuntimeBase = (JSRuntimeBase)JSRuntime.Current;
nameof(EndInvoke), ParseEndInvokeArguments(jsRuntimeBase, arguments);
arguments,
EndInvokeParameterTypes);
EndInvoke((long)parsedArgs[0], (bool)parsedArgs[1], (JSAsyncCallResult)parsedArgs[2]);
} }
private static void EndInvoke(long asyncHandle, bool succeeded, JSAsyncCallResult result) internal static void ParseEndInvokeArguments(JSRuntimeBase jsRuntimeBase, string arguments)
=> ((JSRuntimeBase)JSRuntime.Current).EndInvokeJS(asyncHandle, succeeded, result); {
var utf8JsonBytes = Encoding.UTF8.GetBytes(arguments);
// The payload that we're trying to parse is of the format
// [ taskId: long, success: boolean, value: string? | object ]
// where value is the .NET type T originally specified on InvokeAsync<T> or the error string if success is false.
// We parse the first two arguments and call in to JSRuntimeBase to deserialize the actual value.
var reader = new Utf8JsonReader(utf8JsonBytes);
if (!reader.Read() || reader.TokenType != JsonTokenType.StartArray)
{
throw new JsonException("Invalid JSON");
}
reader.Read();
var taskId = reader.GetInt64();
reader.Read();
var success = reader.GetBoolean();
reader.Read();
jsRuntimeBase.EndInvokeJS(taskId, success, ref reader);
if (!reader.Read() || reader.TokenType != JsonTokenType.EndArray)
{
throw new JsonException("Invalid JSON");
}
}
/// <summary> /// <summary>
/// Releases the reference to the specified .NET object. This allows the .NET runtime /// Releases the reference to the specified .NET object. This allows the .NET runtime
@ -362,7 +368,13 @@ namespace Microsoft.JSInterop
// In some edge cases this might force developers to explicitly call something on the // In some edge cases this might force developers to explicitly call something on the
// target assembly (from .NET) before they can invoke its allowed methods from JS. // target assembly (from .NET) before they can invoke its allowed methods from JS.
var loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies(); var loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies();
return loadedAssemblies.FirstOrDefault(a => new AssemblyKey(a).Equals(assemblyKey))
// Using LastOrDefault to workaround for https://github.com/dotnet/arcade/issues/2816.
// In most ordinary scenarios, we wouldn't have two instances of the same Assembly in the AppDomain
// so this doesn't change the outcome.
var assembly = loadedAssemblies.LastOrDefault(a => new AssemblyKey(a).Equals(assemblyKey));
return assembly
?? throw new ArgumentException($"There is no loaded assembly with the name '{assemblyKey.AssemblyName}'."); ?? throw new ArgumentException($"There is no loaded assembly with the name '{assemblyKey.AssemblyName}'.");
} }
@ -396,6 +408,5 @@ namespace Microsoft.JSInterop
public override int GetHashCode() => StringComparer.Ordinal.GetHashCode(AssemblyName); public override int GetHashCode() => StringComparer.Ordinal.GetHashCode(AssemblyName);
} }
} }
} }

View File

@ -1,36 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Text.Json;
namespace Microsoft.JSInterop
{
// This type takes care of a special case in handling the result of an async call from
// .NET to JS. The information about what type the result should be exists only on the
// corresponding TaskCompletionSource<T>. We don't have that information at the time
// that we deserialize the incoming argsJson before calling DotNetDispatcher.EndInvoke.
// Declaring the EndInvoke parameter type as JSAsyncCallResult defers the deserialization
// until later when we have access to the TaskCompletionSource<T>.
//
// There's no reason why developers would need anything similar to this in user code,
// because this is the mechanism by which we resolve the incoming argsJson to the correct
// user types before completing calls.
//
// It's marked as 'public' only because it has to be for use as an argument on a
// [JSInvokable] method.
/// <summary>
/// Intended for framework use only.
/// </summary>
internal sealed class JSAsyncCallResult
{
internal JSAsyncCallResult(JsonDocument document, JsonElement jsonElement)
{
JsonDocument = document;
JsonElement = jsonElement;
}
internal JsonElement JsonElement { get; }
internal JsonDocument JsonDocument { get; }
}
}

View File

@ -5,7 +5,6 @@ using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Runtime.ExceptionServices;
using System.Text.Json; using System.Text.Json;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -139,41 +138,37 @@ namespace Microsoft.JSInterop
string methodIdentifier, string methodIdentifier,
long dotNetObjectId); long dotNetObjectId);
internal void EndInvokeJS(long taskId, bool succeeded, JSAsyncCallResult asyncCallResult) internal void EndInvokeJS(long taskId, bool succeeded, ref Utf8JsonReader jsonReader)
{ {
using (asyncCallResult?.JsonDocument) if (!_pendingTasks.TryRemove(taskId, out var tcs))
{ {
if (!_pendingTasks.TryRemove(taskId, out var tcs)) // We should simply return if we can't find an id for the invocation.
{ // This likely means that the method that initiated the call defined a timeout and stopped waiting.
// We should simply return if we can't find an id for the invocation. return;
// This likely means that the method that initiated the call defined a timeout and stopped waiting. }
return;
}
CleanupTasksAndRegistrations(taskId); CleanupTasksAndRegistrations(taskId);
try
{
if (succeeded) if (succeeded)
{ {
var resultType = TaskGenericsUtil.GetTaskCompletionSourceResultType(tcs); var resultType = TaskGenericsUtil.GetTaskCompletionSourceResultType(tcs);
try
{ var result = JsonSerializer.Deserialize(ref jsonReader, resultType, JsonSerializerOptionsProvider.Options);
var result = asyncCallResult != null ? TaskGenericsUtil.SetTaskCompletionSourceResult(tcs, result);
JsonSerializer.Deserialize(asyncCallResult.JsonElement.GetRawText(), resultType, JsonSerializerOptionsProvider.Options) :
null;
TaskGenericsUtil.SetTaskCompletionSourceResult(tcs, result);
}
catch (Exception exception)
{
var message = $"An exception occurred executing JS interop: {exception.Message}. See InnerException for more details.";
TaskGenericsUtil.SetTaskCompletionSourceException(tcs, new JSException(message, exception));
}
} }
else else
{ {
var exceptionText = asyncCallResult?.JsonElement.ToString() ?? string.Empty; var exceptionText = jsonReader.GetString() ?? string.Empty;
TaskGenericsUtil.SetTaskCompletionSourceException(tcs, new JSException(exceptionText)); TaskGenericsUtil.SetTaskCompletionSourceException(tcs, new JSException(exceptionText));
} }
} }
catch (Exception exception)
{
var message = $"An exception occurred executing JS interop: {exception.Message}. See InnerException for more details.";
TaskGenericsUtil.SetTaskCompletionSourceException(tcs, new JSException(message, exception));
}
} }
} }
} }

View File

@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFrameworks>netstandard2.0;netcoreapp5.0</TargetFrameworks>
<TargetFrameworks Condition="'$(DotNetBuildFromSource)' == 'true'">netcoreapp5.0</TargetFrameworks>
<Description>Abstractions and features for interop between .NET and JavaScript code.</Description> <Description>Abstractions and features for interop between .NET and JavaScript code.</Description>
<PackageTags>javascript;interop</PackageTags> <PackageTags>javascript;interop</PackageTags>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
@ -9,7 +10,7 @@
<IsShipping>true</IsShipping> <IsShipping>true</IsShipping>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<Reference Include="System.Text.Json" /> <Reference Include="System.Text.Json" />
</ItemGroup> </ItemGroup>

View File

@ -2,15 +2,14 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
using System.ComponentModel.DataAnnotations;
using System.Linq; using System.Linq;
using System.Runtime.ExceptionServices; using System.Runtime.ExceptionServices;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Xunit; using Xunit;
namespace Microsoft.JSInterop.Tests namespace Microsoft.JSInterop
{ {
public class DotNetDispatcherTest public class DotNetDispatcherTest
{ {
@ -239,6 +238,72 @@ namespace Microsoft.JSInterop.Tests
Assert.StartsWith("There is no tracked object with id '1'.", ex.Message); Assert.StartsWith("There is no tracked object with id '1'.", ex.Message);
}); });
[Fact]
public Task EndInvoke_WithSuccessValue() => WithJSRuntime(jsRuntime =>
{
// Arrange
var testDTO = new TestDTO { StringVal = "Hello", IntVal = 4 };
var task = jsRuntime.InvokeAsync<TestDTO>("unimportant");
var argsJson = JsonSerializer.Serialize(new object[] { jsRuntime.LastInvocationAsyncHandle, true, testDTO }, JsonSerializerOptionsProvider.Options);
// Act
DotNetDispatcher.EndInvoke(argsJson);
// Assert
Assert.True(task.IsCompleted && task.Status == TaskStatus.RanToCompletion);
var result = task.Result;
Assert.Equal(testDTO.StringVal, result.StringVal);
Assert.Equal(testDTO.IntVal, result.IntVal);
});
[Fact]
public Task EndInvoke_WithErrorString() => WithJSRuntime(async jsRuntime =>
{
// Arrange
var expected = "Some error";
var task = jsRuntime.InvokeAsync<TestDTO>("unimportant");
var argsJson = JsonSerializer.Serialize(new object[] { jsRuntime.LastInvocationAsyncHandle, false, expected }, JsonSerializerOptionsProvider.Options);
// Act
DotNetDispatcher.EndInvoke(argsJson);
// Assert
var ex = await Assert.ThrowsAsync<JSException>(() => task);
Assert.Equal(expected, ex.Message);
});
[Fact(Skip = "https://github.com/aspnet/AspNetCore/issues/12357")]
public Task EndInvoke_AfterCancel() => WithJSRuntime(jsRuntime =>
{
// Arrange
var testDTO = new TestDTO { StringVal = "Hello", IntVal = 4 };
var cts = new CancellationTokenSource();
var task = jsRuntime.InvokeAsync<TestDTO>("unimportant", cts.Token);
var argsJson = JsonSerializer.Serialize(new object[] { jsRuntime.LastInvocationAsyncHandle, true, testDTO }, JsonSerializerOptionsProvider.Options);
// Act
cts.Cancel();
DotNetDispatcher.EndInvoke(argsJson);
// Assert
Assert.True(task.IsCanceled);
});
[Fact]
public Task EndInvoke_WithNullError() => WithJSRuntime(async jsRuntime =>
{
// Arrange
var task = jsRuntime.InvokeAsync<TestDTO>("unimportant");
var argsJson = JsonSerializer.Serialize(new object[] { jsRuntime.LastInvocationAsyncHandle, false, null }, JsonSerializerOptionsProvider.Options);
// Act
DotNetDispatcher.EndInvoke(argsJson);
// Assert
var ex = await Assert.ThrowsAsync<JSException>(() => task);
Assert.Empty(ex.Message);
});
[Fact] [Fact]
public Task CanInvokeInstanceMethodWithParams() => WithJSRuntime(jsRuntime => public Task CanInvokeInstanceMethodWithParams() => WithJSRuntime(jsRuntime =>
{ {
@ -261,10 +326,14 @@ namespace Microsoft.JSInterop.Tests
}); });
[Fact] [Fact]
public void CannotInvokeWithIncorrectNumberOfParams() public Task CannotInvokeWithFewerNumberOfParameters() => WithJSRuntime(jsRuntime =>
{ {
// Arrange // Arrange
var argsJson = JsonSerializer.Serialize(new object[] { 1, 2, 3, 4 }, JsonSerializerOptionsProvider.Options); var argsJson = JsonSerializer.Serialize(new object[]
{
new TestDTO { StringVal = "Another string", IntVal = 456 },
new[] { 100, 200 },
}, JsonSerializerOptionsProvider.Options);
// Act/Assert // Act/Assert
var ex = Assert.Throws<ArgumentException>(() => var ex = Assert.Throws<ArgumentException>(() =>
@ -272,8 +341,30 @@ namespace Microsoft.JSInterop.Tests
DotNetDispatcher.Invoke(thisAssemblyName, "InvocableStaticWithParams", default, argsJson); DotNetDispatcher.Invoke(thisAssemblyName, "InvocableStaticWithParams", default, argsJson);
}); });
Assert.Equal("In call to 'InvocableStaticWithParams', expected 3 parameters but received 4.", ex.Message); Assert.Equal("The call to 'InvocableStaticWithParams' expects '3' parameters, but received '2'.", ex.Message);
} });
[Fact]
public Task CannotInvokeWithMoreParameters() => WithJSRuntime(jsRuntime =>
{
// Arrange
var objectRef = DotNetObjectRef.Create(new TestDTO { IntVal = 4 });
var argsJson = JsonSerializer.Serialize(new object[]
{
new TestDTO { StringVal = "Another string", IntVal = 456 },
new[] { 100, 200 },
objectRef,
7,
}, JsonSerializerOptionsProvider.Options);
// Act/Assert
var ex = Assert.Throws<JsonException>(() =>
{
DotNetDispatcher.Invoke(thisAssemblyName, "InvocableStaticWithParams", default, argsJson);
});
Assert.Equal("Unexpected JSON token Number. Ensure that the call to `InvocableStaticWithParams' is supplied with exactly '3' parameters.", ex.Message);
});
[Fact] [Fact]
public Task CanInvokeAsyncMethod() => WithJSRuntime(async jsRuntime => public Task CanInvokeAsyncMethod() => WithJSRuntime(async jsRuntime =>
@ -301,7 +392,7 @@ namespace Microsoft.JSInterop.Tests
// Assert: Correct completion information // Assert: Correct completion information
Assert.Equal(callId, jsRuntime.LastCompletionCallId); Assert.Equal(callId, jsRuntime.LastCompletionCallId);
Assert.True(jsRuntime.LastCompletionStatus); Assert.True(jsRuntime.LastCompletionStatus);
var result = Assert.IsType<object []>(jsRuntime.LastCompletionResult); var result = Assert.IsType<object[]>(jsRuntime.LastCompletionResult);
var resultDto1 = Assert.IsType<TestDTO>(result[0]); var resultDto1 = Assert.IsType<TestDTO>(result[0]);
Assert.Equal("STRING VIA JSON", resultDto1.StringVal); Assert.Equal("STRING VIA JSON", resultDto1.StringVal);
@ -390,6 +481,150 @@ namespace Microsoft.JSInterop.Tests
Assert.StartsWith("System.ArgumentException: There is no tracked object with id '1'. Perhaps the DotNetObjectRef instance was already disposed.", result.SourceException.ToString()); Assert.StartsWith("System.ArgumentException: There is no tracked object with id '1'. Perhaps the DotNetObjectRef instance was already disposed.", result.SourceException.ToString());
}); });
[Theory]
[InlineData("")]
[InlineData("<xml>")]
public void ParseArguments_ThrowsIfJsonIsInvalid(string arguments)
{
Assert.ThrowsAny<JsonException>(() => DotNetDispatcher.ParseArguments("SomeMethod", arguments, new[] { typeof(string) }));
}
[Theory]
[InlineData("{\"key\":\"value\"}")]
[InlineData("\"Test\"")]
public void ParseArguments_ThrowsIfTheArgsJsonIsNotArray(string arguments)
{
// Act & Assert
Assert.ThrowsAny<JsonException>(() => DotNetDispatcher.ParseArguments("SomeMethod", arguments, new[] { typeof(string) }));
}
[Theory]
[InlineData("[\"hello\"")]
[InlineData("[\"hello\",")]
public void ParseArguments_ThrowsIfTheArgsJsonIsInvalidArray(string arguments)
{
// Act & Assert
Assert.ThrowsAny<JsonException>(() => DotNetDispatcher.ParseArguments("SomeMethod", arguments, new[] { typeof(string) }));
}
[Fact]
public void ParseArguments_Works()
{
// Arrange
var arguments = "[\"Hello\", 2]";
// Act
var result = DotNetDispatcher.ParseArguments("SomeMethod", arguments, new[] { typeof(string), typeof(int), });
// Assert
Assert.Equal(new object[] { "Hello", 2 }, result);
}
[Fact]
public void ParseArguments_SingleArgument()
{
// Arrange
var arguments = "[{\"IntVal\": 7}]";
// Act
var result = DotNetDispatcher.ParseArguments("SomeMethod", arguments, new[] { typeof(TestDTO), });
// Assert
var value = Assert.IsType<TestDTO>(Assert.Single(result));
Assert.Equal(7, value.IntVal);
Assert.Null(value.StringVal);
}
[Fact]
public void ParseArguments_NullArgument()
{
// Arrange
var arguments = "[4, null]";
// Act
var result = DotNetDispatcher.ParseArguments("SomeMethod", arguments, new[] { typeof(int), typeof(TestDTO), });
// Assert
Assert.Collection(
result,
v => Assert.Equal(4, v),
v => Assert.Null(v));
}
[Fact]
public void ParseArguments_Throws_WithIncorrectDotNetObjectRefUsage()
{
// Arrange
var method = "SomeMethod";
var arguments = "[4, {\"__dotNetObject\": 7}]";
// Act
var ex = Assert.Throws<InvalidOperationException>(() => DotNetDispatcher.ParseArguments(method, arguments, new[] { typeof(int), typeof(TestDTO), }));
// Assert
Assert.Equal($"In call to '{method}', parameter of type '{nameof(TestDTO)}' at index 2 must be declared as type 'DotNetObjectRef<TestDTO>' to receive the incoming value.", ex.Message);
}
[Fact]
public void ParseEndInvokeArguments_ThrowsIfJsonIsEmptyString()
{
Assert.ThrowsAny<JsonException>(() => DotNetDispatcher.ParseEndInvokeArguments(new TestJSRuntime(), ""));
}
[Fact]
public void ParseEndInvokeArguments_ThrowsIfJsonIsNotArray()
{
Assert.ThrowsAny<JsonException>(() => DotNetDispatcher.ParseEndInvokeArguments(new TestJSRuntime(), "{\"key\": \"value\"}"));
}
[Fact]
public void ParseEndInvokeArguments_ThrowsIfJsonArrayIsInComplete()
{
Assert.ThrowsAny<JsonException>(() => DotNetDispatcher.ParseEndInvokeArguments(new TestJSRuntime(), "[7, false"));
}
[Fact]
public void ParseEndInvokeArguments_ThrowsIfJsonArrayHasMoreThan3Arguments()
{
Assert.ThrowsAny<JsonException>(() => DotNetDispatcher.ParseEndInvokeArguments(new TestJSRuntime(), "[7, false, \"Hello\", 5]"));
}
[Fact]
public void ParseEndInvokeArguments_Works()
{
var jsRuntime = new TestJSRuntime();
var task = jsRuntime.InvokeAsync<TestDTO>("somemethod");
DotNetDispatcher.ParseEndInvokeArguments(jsRuntime, $"[{jsRuntime.LastInvocationAsyncHandle}, true, {{\"intVal\": 7}}]");
Assert.True(task.IsCompleted && task.Status == TaskStatus.RanToCompletion);
Assert.Equal(7, task.Result.IntVal);
}
[Fact]
public void ParseEndInvokeArguments_WithArrayValue()
{
var jsRuntime = new TestJSRuntime();
var task = jsRuntime.InvokeAsync<int[]>("somemethod");
DotNetDispatcher.ParseEndInvokeArguments(jsRuntime, $"[{jsRuntime.LastInvocationAsyncHandle}, true, [1, 2, 3]]");
Assert.True(task.IsCompleted && task.Status == TaskStatus.RanToCompletion);
Assert.Equal(new[] { 1, 2, 3 }, task.Result);
}
[Fact]
public void ParseEndInvokeArguments_WithNullValue()
{
var jsRuntime = new TestJSRuntime();
var task = jsRuntime.InvokeAsync<TestDTO>("somemethod");
DotNetDispatcher.ParseEndInvokeArguments(jsRuntime, $"[{jsRuntime.LastInvocationAsyncHandle}, true, null]");
Assert.True(task.IsCompleted && task.Status == TaskStatus.RanToCompletion);
Assert.Null(task.Result);
}
Task WithJSRuntime(Action<TestJSRuntime> testCode) Task WithJSRuntime(Action<TestJSRuntime> testCode)
{ {
return WithJSRuntime(jsRuntime => return WithJSRuntime(jsRuntime =>

View File

@ -4,13 +4,13 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Runtime.ExceptionServices; using System.Text;
using System.Text.Json; using System.Text.Json;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Xunit; using Xunit;
namespace Microsoft.JSInterop.Tests namespace Microsoft.JSInterop
{ {
public class JSRuntimeBaseTest public class JSRuntimeBaseTest
{ {
@ -54,18 +54,19 @@ namespace Microsoft.JSInterop.Tests
} }
[Fact] [Fact]
public async Task InvokeAsync_CompletesSuccessfullyBeforeTimeout() public void InvokeAsync_CompletesSuccessfullyBeforeTimeout()
{ {
// Arrange // Arrange
var runtime = new TestJSRuntime(); var runtime = new TestJSRuntime();
runtime.DefaultTimeout = TimeSpan.FromSeconds(10); runtime.DefaultTimeout = TimeSpan.FromSeconds(10);
var reader = new Utf8JsonReader(Encoding.UTF8.GetBytes("null"));
// Act // Act
var task = runtime.InvokeAsync<object>("test identifier 1", "arg1", 123, true); var task = runtime.InvokeAsync<object>("test identifier 1", "arg1", 123, true);
runtime.EndInvokeJS(2, succeeded: true, null);
// Assert runtime.EndInvokeJS(2, succeeded: true, ref reader);
await task;
Assert.True(task.IsCompleted && task.Status == TaskStatus.RanToCompletion);
} }
[Fact] [Fact]
@ -113,18 +114,62 @@ namespace Microsoft.JSInterop.Tests
var task = runtime.InvokeAsync<string>("test identifier", Array.Empty<object>()); var task = runtime.InvokeAsync<string>("test identifier", Array.Empty<object>());
Assert.False(unrelatedTask.IsCompleted); Assert.False(unrelatedTask.IsCompleted);
Assert.False(task.IsCompleted); Assert.False(task.IsCompleted);
using var jsonDocument = JsonDocument.Parse("\"my result\""); var bytes = Encoding.UTF8.GetBytes("\"my result\"");
var reader = new Utf8JsonReader(bytes);
// Act/Assert: Task can be completed // Act/Assert: Task can be completed
runtime.OnEndInvoke( runtime.EndInvokeJS(
runtime.BeginInvokeCalls[1].AsyncHandle, runtime.BeginInvokeCalls[1].AsyncHandle,
/* succeeded: */ true, /* succeeded: */ true,
new JSAsyncCallResult(jsonDocument, jsonDocument.RootElement)); ref reader);
Assert.False(unrelatedTask.IsCompleted); Assert.False(unrelatedTask.IsCompleted);
Assert.True(task.IsCompleted); Assert.True(task.IsCompleted);
Assert.Equal("my result", task.Result); Assert.Equal("my result", task.Result);
} }
[Fact]
public void CanCompleteAsyncCallsWithComplexType()
{
// Arrange
var runtime = new TestJSRuntime();
var task = runtime.InvokeAsync<TestPoco>("test identifier", Array.Empty<object>());
var bytes = Encoding.UTF8.GetBytes("{\"id\":10, \"name\": \"Test\"}");
var reader = new Utf8JsonReader(bytes);
// Act/Assert: Task can be completed
runtime.EndInvokeJS(
runtime.BeginInvokeCalls[0].AsyncHandle,
/* succeeded: */ true,
ref reader);
Assert.True(task.IsCompleted);
var poco = task.Result;
Assert.Equal(10, poco.Id);
Assert.Equal("Test", poco.Name);
}
[Fact]
public void CanCompleteAsyncCallsWithComplexTypeUsingPropertyCasing()
{
// Arrange
var runtime = new TestJSRuntime();
var task = runtime.InvokeAsync<TestPoco>("test identifier", Array.Empty<object>());
var bytes = Encoding.UTF8.GetBytes("{\"Id\":10, \"Name\": \"Test\"}");
var reader = new Utf8JsonReader(bytes);
reader.Read();
// Act/Assert: Task can be completed
runtime.EndInvokeJS(
runtime.BeginInvokeCalls[0].AsyncHandle,
/* succeeded: */ true,
ref reader);
Assert.True(task.IsCompleted);
var poco = task.Result;
Assert.Equal(10, poco.Id);
Assert.Equal("Test", poco.Name);
}
[Fact] [Fact]
public void CanCompleteAsyncCallsAsFailure() public void CanCompleteAsyncCallsAsFailure()
{ {
@ -136,13 +181,15 @@ namespace Microsoft.JSInterop.Tests
var task = runtime.InvokeAsync<string>("test identifier", Array.Empty<object>()); var task = runtime.InvokeAsync<string>("test identifier", Array.Empty<object>());
Assert.False(unrelatedTask.IsCompleted); Assert.False(unrelatedTask.IsCompleted);
Assert.False(task.IsCompleted); Assert.False(task.IsCompleted);
using var jsonDocument = JsonDocument.Parse("\"This is a test exception\""); var bytes = Encoding.UTF8.GetBytes("\"This is a test exception\"");
var reader = new Utf8JsonReader(bytes);
reader.Read();
// Act/Assert: Task can be failed // Act/Assert: Task can be failed
runtime.OnEndInvoke( runtime.EndInvokeJS(
runtime.BeginInvokeCalls[1].AsyncHandle, runtime.BeginInvokeCalls[1].AsyncHandle,
/* succeeded: */ false, /* succeeded: */ false,
new JSAsyncCallResult(jsonDocument, jsonDocument.RootElement)); ref reader);
Assert.False(unrelatedTask.IsCompleted); Assert.False(unrelatedTask.IsCompleted);
Assert.True(task.IsCompleted); Assert.True(task.IsCompleted);
@ -152,7 +199,7 @@ namespace Microsoft.JSInterop.Tests
} }
[Fact] [Fact]
public async Task CanCompleteAsyncCallsWithErrorsDuringDeserialization() public Task CanCompleteAsyncCallsWithErrorsDuringDeserialization()
{ {
// Arrange // Arrange
var runtime = new TestJSRuntime(); var runtime = new TestJSRuntime();
@ -162,24 +209,27 @@ namespace Microsoft.JSInterop.Tests
var task = runtime.InvokeAsync<int>("test identifier", Array.Empty<object>()); var task = runtime.InvokeAsync<int>("test identifier", Array.Empty<object>());
Assert.False(unrelatedTask.IsCompleted); Assert.False(unrelatedTask.IsCompleted);
Assert.False(task.IsCompleted); Assert.False(task.IsCompleted);
using var jsonDocument = JsonDocument.Parse("\"Not a string\""); var bytes = Encoding.UTF8.GetBytes("Not a string");
var reader = new Utf8JsonReader(bytes);
// Act/Assert: Task can be failed // Act/Assert: Task can be failed
runtime.OnEndInvoke( runtime.EndInvokeJS(
runtime.BeginInvokeCalls[1].AsyncHandle, runtime.BeginInvokeCalls[1].AsyncHandle,
/* succeeded: */ true, /* succeeded: */ true,
new JSAsyncCallResult(jsonDocument, jsonDocument.RootElement)); ref reader);
Assert.False(unrelatedTask.IsCompleted); Assert.False(unrelatedTask.IsCompleted);
var jsException = await Assert.ThrowsAsync<JSException>(() => task); return AssertTask();
Assert.IsType<JsonException>(jsException.InnerException);
// Verify we've disposed the JsonDocument. async Task AssertTask()
Assert.Throws<ObjectDisposedException>(() => jsonDocument.RootElement.ValueKind); {
var jsException = await Assert.ThrowsAsync<JSException>(() => task);
Assert.IsAssignableFrom<JsonException>(jsException.InnerException);
}
} }
[Fact] [Fact]
public async Task CompletingSameAsyncCallMoreThanOnce_IgnoresSecondResultAsync() public Task CompletingSameAsyncCallMoreThanOnce_IgnoresSecondResultAsync()
{ {
// Arrange // Arrange
var runtime = new TestJSRuntime(); var runtime = new TestJSRuntime();
@ -187,11 +237,19 @@ namespace Microsoft.JSInterop.Tests
// Act/Assert // Act/Assert
var task = runtime.InvokeAsync<string>("test identifier", Array.Empty<object>()); var task = runtime.InvokeAsync<string>("test identifier", Array.Empty<object>());
var asyncHandle = runtime.BeginInvokeCalls[0].AsyncHandle; var asyncHandle = runtime.BeginInvokeCalls[0].AsyncHandle;
runtime.OnEndInvoke(asyncHandle, true, new JSAsyncCallResult(JsonDocument.Parse("{}"), JsonDocument.Parse("{\"Message\": \"Some data\"}").RootElement.GetProperty("Message"))); var firstReader = new Utf8JsonReader(Encoding.UTF8.GetBytes("\"Some data\""));
runtime.OnEndInvoke(asyncHandle, false, new JSAsyncCallResult(null, JsonDocument.Parse("{\"Message\": \"Exception\"}").RootElement.GetProperty("Message"))); var secondReader = new Utf8JsonReader(Encoding.UTF8.GetBytes("\"Exception\""));
var result = await task; runtime.EndInvokeJS(asyncHandle, true, ref firstReader);
Assert.Equal("Some data", result); runtime.EndInvokeJS(asyncHandle, false, ref secondReader);
return AssertTask();
async Task AssertTask()
{
var result = await task;
Assert.Equal("Some data", result);
}
} }
[Fact] [Fact]
@ -263,6 +321,13 @@ namespace Microsoft.JSInterop.Tests
public string Message { get; set; } public string Message { get; set; }
} }
private class TestPoco
{
public int Id { get; set; }
public string Name { get; set; }
}
class TestJSRuntime : JSRuntimeBase class TestJSRuntime : JSRuntimeBase
{ {
public List<BeginInvokeAsyncArgs> BeginInvokeCalls = new List<BeginInvokeAsyncArgs>(); public List<BeginInvokeAsyncArgs> BeginInvokeCalls = new List<BeginInvokeAsyncArgs>();
@ -316,9 +381,6 @@ namespace Microsoft.JSInterop.Tests
ArgsJson = argsJson, ArgsJson = argsJson,
}); });
} }
public void OnEndInvoke(long asyncHandle, bool succeeded, JSAsyncCallResult callResult)
=> EndInvokeJS(asyncHandle, succeeded, callResult);
} }
} }
} }

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework> <TargetFrameworks>netcoreapp3.0;net472</TargetFrameworks>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -7,6 +7,8 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<IsPackable>true</IsPackable> <IsPackable>true</IsPackable>
<IsShipping>true</IsShipping> <IsShipping>true</IsShipping>
<!-- This project is not included in the shared framework -->
<ExcludeFromSourceBuild>true</ExcludeFromSourceBuild>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -1,10 +1,14 @@
<!-- This file is automatically generated. --> <!-- This file is automatically generated. -->
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks> <TargetFrameworks>netstandard2.0;netcoreapp5.0</TargetFrameworks>
</PropertyGroup> </PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'"> <ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<Compile Include="Microsoft.Extensions.Localization.Abstractions.netstandard2.0.cs" /> <Compile Include="Microsoft.Extensions.Localization.Abstractions.netstandard2.0.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp5.0'">
<Compile Include="Microsoft.Extensions.Localization.Abstractions.netcoreapp5.0.cs" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -0,0 +1,49 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.Extensions.Localization
{
public partial interface IStringLocalizer
{
Microsoft.Extensions.Localization.LocalizedString this[string name] { get; }
Microsoft.Extensions.Localization.LocalizedString this[string name, params object[] arguments] { get; }
System.Collections.Generic.IEnumerable<Microsoft.Extensions.Localization.LocalizedString> GetAllStrings(bool includeParentCultures);
[System.ObsoleteAttribute("This method is obsolete. Use `CurrentCulture` and `CurrentUICulture` instead.")]
Microsoft.Extensions.Localization.IStringLocalizer WithCulture(System.Globalization.CultureInfo culture);
}
public partial interface IStringLocalizerFactory
{
Microsoft.Extensions.Localization.IStringLocalizer Create(string baseName, string location);
Microsoft.Extensions.Localization.IStringLocalizer Create(System.Type resourceSource);
}
public partial interface IStringLocalizer<out T> : Microsoft.Extensions.Localization.IStringLocalizer
{
}
public partial class LocalizedString
{
public LocalizedString(string name, string value) { }
public LocalizedString(string name, string value, bool resourceNotFound) { }
public LocalizedString(string name, string value, bool resourceNotFound, string searchedLocation) { }
public string Name { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public bool ResourceNotFound { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public string SearchedLocation { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public string Value { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public static implicit operator string (Microsoft.Extensions.Localization.LocalizedString localizedString) { throw null; }
public override string ToString() { throw null; }
}
public static partial class StringLocalizerExtensions
{
public static System.Collections.Generic.IEnumerable<Microsoft.Extensions.Localization.LocalizedString> GetAllStrings(this Microsoft.Extensions.Localization.IStringLocalizer stringLocalizer) { throw null; }
public static Microsoft.Extensions.Localization.LocalizedString GetString(this Microsoft.Extensions.Localization.IStringLocalizer stringLocalizer, string name) { throw null; }
public static Microsoft.Extensions.Localization.LocalizedString GetString(this Microsoft.Extensions.Localization.IStringLocalizer stringLocalizer, string name, params object[] arguments) { throw null; }
}
public partial class StringLocalizer<TResourceSource> : Microsoft.Extensions.Localization.IStringLocalizer, Microsoft.Extensions.Localization.IStringLocalizer<TResourceSource>
{
public StringLocalizer(Microsoft.Extensions.Localization.IStringLocalizerFactory factory) { }
public virtual Microsoft.Extensions.Localization.LocalizedString this[string name] { get { throw null; } }
public virtual Microsoft.Extensions.Localization.LocalizedString this[string name, params object[] arguments] { get { throw null; } }
public System.Collections.Generic.IEnumerable<Microsoft.Extensions.Localization.LocalizedString> GetAllStrings(bool includeParentCultures) { throw null; }
[System.ObsoleteAttribute("This method is obsolete. Use `CurrentCulture` and `CurrentUICulture` instead.")]
public virtual Microsoft.Extensions.Localization.IStringLocalizer WithCulture(System.Globalization.CultureInfo culture) { throw null; }
}
}

View File

@ -0,0 +1,49 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.Extensions.Localization
{
public partial interface IStringLocalizer
{
Microsoft.Extensions.Localization.LocalizedString this[string name] { get; }
Microsoft.Extensions.Localization.LocalizedString this[string name, params object[] arguments] { get; }
System.Collections.Generic.IEnumerable<Microsoft.Extensions.Localization.LocalizedString> GetAllStrings(bool includeParentCultures);
[System.ObsoleteAttribute("This method is obsolete. Use `CurrentCulture` and `CurrentUICulture` instead.")]
Microsoft.Extensions.Localization.IStringLocalizer WithCulture(System.Globalization.CultureInfo culture);
}
public partial interface IStringLocalizerFactory
{
Microsoft.Extensions.Localization.IStringLocalizer Create(string baseName, string location);
Microsoft.Extensions.Localization.IStringLocalizer Create(System.Type resourceSource);
}
public partial interface IStringLocalizer<out T> : Microsoft.Extensions.Localization.IStringLocalizer
{
}
public partial class LocalizedString
{
public LocalizedString(string name, string value) { }
public LocalizedString(string name, string value, bool resourceNotFound) { }
public LocalizedString(string name, string value, bool resourceNotFound, string searchedLocation) { }
public string Name { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public bool ResourceNotFound { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public string SearchedLocation { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public string Value { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public static implicit operator string (Microsoft.Extensions.Localization.LocalizedString localizedString) { throw null; }
public override string ToString() { throw null; }
}
public static partial class StringLocalizerExtensions
{
public static System.Collections.Generic.IEnumerable<Microsoft.Extensions.Localization.LocalizedString> GetAllStrings(this Microsoft.Extensions.Localization.IStringLocalizer stringLocalizer) { throw null; }
public static Microsoft.Extensions.Localization.LocalizedString GetString(this Microsoft.Extensions.Localization.IStringLocalizer stringLocalizer, string name) { throw null; }
public static Microsoft.Extensions.Localization.LocalizedString GetString(this Microsoft.Extensions.Localization.IStringLocalizer stringLocalizer, string name, params object[] arguments) { throw null; }
}
public partial class StringLocalizer<TResourceSource> : Microsoft.Extensions.Localization.IStringLocalizer, Microsoft.Extensions.Localization.IStringLocalizer<TResourceSource>
{
public StringLocalizer(Microsoft.Extensions.Localization.IStringLocalizerFactory factory) { }
public virtual Microsoft.Extensions.Localization.LocalizedString this[string name] { get { throw null; } }
public virtual Microsoft.Extensions.Localization.LocalizedString this[string name, params object[] arguments] { get { throw null; } }
public System.Collections.Generic.IEnumerable<Microsoft.Extensions.Localization.LocalizedString> GetAllStrings(bool includeParentCultures) { throw null; }
[System.ObsoleteAttribute("This method is obsolete. Use `CurrentCulture` and `CurrentUICulture` instead.")]
public virtual Microsoft.Extensions.Localization.IStringLocalizer WithCulture(System.Globalization.CultureInfo culture) { throw null; }
}
}

View File

@ -6,7 +6,8 @@
Commonly used types: Commonly used types:
Microsoft.Extensions.Localization.IStringLocalizer Microsoft.Extensions.Localization.IStringLocalizer
Microsoft.Extensions.Localization.IStringLocalizer&lt;T&gt;</Description> Microsoft.Extensions.Localization.IStringLocalizer&lt;T&gt;</Description>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFrameworks>netstandard2.0;netcoreapp5.0</TargetFrameworks>
<TargetFrameworks Condition="'$(DotNetBuildFromSource)' == 'true'">netcoreapp5.0</TargetFrameworks>
<NoWarn>$(NoWarn);CS1591</NoWarn> <NoWarn>$(NoWarn);CS1591</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>localization</PackageTags> <PackageTags>localization</PackageTags>

View File

@ -1,7 +1,7 @@
<!-- This file is automatically generated. --> <!-- This file is automatically generated. -->
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks> <TargetFrameworks>netstandard2.0;netcoreapp5.0</TargetFrameworks>
</PropertyGroup> </PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'"> <ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<Compile Include="Microsoft.Extensions.Localization.netstandard2.0.cs" /> <Compile Include="Microsoft.Extensions.Localization.netstandard2.0.cs" />
@ -10,4 +10,11 @@
<Reference Include="Microsoft.Extensions.Localization.Abstractions" /> <Reference Include="Microsoft.Extensions.Localization.Abstractions" />
<Reference Include="Microsoft.Extensions.Logging.Abstractions" /> <Reference Include="Microsoft.Extensions.Logging.Abstractions" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp5.0'">
<Compile Include="Microsoft.Extensions.Localization.netcoreapp5.0.cs" />
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
<Reference Include="Microsoft.Extensions.Options" />
<Reference Include="Microsoft.Extensions.Localization.Abstractions" />
<Reference Include="Microsoft.Extensions.Logging.Abstractions" />
</ItemGroup>
</Project> </Project>

View File

@ -0,0 +1,93 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.Extensions.DependencyInjection
{
public static partial class LocalizationServiceCollectionExtensions
{
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddLocalization(this Microsoft.Extensions.DependencyInjection.IServiceCollection services) { throw null; }
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddLocalization(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Action<Microsoft.Extensions.Localization.LocalizationOptions> setupAction) { throw null; }
}
}
namespace Microsoft.Extensions.Localization
{
public partial interface IResourceNamesCache
{
System.Collections.Generic.IList<string> GetOrAdd(string name, System.Func<string, System.Collections.Generic.IList<string>> valueFactory);
}
public partial class LocalizationOptions
{
public LocalizationOptions() { }
public string ResourcesPath { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
}
[System.AttributeUsageAttribute(System.AttributeTargets.Assembly, AllowMultiple=false, Inherited=false)]
public partial class ResourceLocationAttribute : System.Attribute
{
public ResourceLocationAttribute(string resourceLocation) { }
public string ResourceLocation { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
public partial class ResourceManagerStringLocalizer : Microsoft.Extensions.Localization.IStringLocalizer
{
public ResourceManagerStringLocalizer(System.Resources.ResourceManager resourceManager, Microsoft.Extensions.Localization.Internal.AssemblyWrapper resourceAssemblyWrapper, string baseName, Microsoft.Extensions.Localization.IResourceNamesCache resourceNamesCache, Microsoft.Extensions.Logging.ILogger logger) { }
public ResourceManagerStringLocalizer(System.Resources.ResourceManager resourceManager, Microsoft.Extensions.Localization.Internal.IResourceStringProvider resourceStringProvider, string baseName, Microsoft.Extensions.Localization.IResourceNamesCache resourceNamesCache, Microsoft.Extensions.Logging.ILogger logger) { }
public ResourceManagerStringLocalizer(System.Resources.ResourceManager resourceManager, System.Reflection.Assembly resourceAssembly, string baseName, Microsoft.Extensions.Localization.IResourceNamesCache resourceNamesCache, Microsoft.Extensions.Logging.ILogger logger) { }
public virtual Microsoft.Extensions.Localization.LocalizedString this[string name] { get { throw null; } }
public virtual Microsoft.Extensions.Localization.LocalizedString this[string name, params object[] arguments] { get { throw null; } }
public virtual System.Collections.Generic.IEnumerable<Microsoft.Extensions.Localization.LocalizedString> GetAllStrings(bool includeParentCultures) { throw null; }
protected System.Collections.Generic.IEnumerable<Microsoft.Extensions.Localization.LocalizedString> GetAllStrings(bool includeParentCultures, System.Globalization.CultureInfo culture) { throw null; }
protected string GetStringSafely(string name, System.Globalization.CultureInfo culture) { throw null; }
[System.ObsoleteAttribute("This method is obsolete. Use `CurrentCulture` and `CurrentUICulture` instead.")]
public Microsoft.Extensions.Localization.IStringLocalizer WithCulture(System.Globalization.CultureInfo culture) { throw null; }
}
public partial class ResourceManagerStringLocalizerFactory : Microsoft.Extensions.Localization.IStringLocalizerFactory
{
public ResourceManagerStringLocalizerFactory(Microsoft.Extensions.Options.IOptions<Microsoft.Extensions.Localization.LocalizationOptions> localizationOptions, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory) { }
public Microsoft.Extensions.Localization.IStringLocalizer Create(string baseName, string location) { throw null; }
public Microsoft.Extensions.Localization.IStringLocalizer Create(System.Type resourceSource) { throw null; }
protected virtual Microsoft.Extensions.Localization.ResourceManagerStringLocalizer CreateResourceManagerStringLocalizer(System.Reflection.Assembly assembly, string baseName) { throw null; }
protected virtual Microsoft.Extensions.Localization.ResourceLocationAttribute GetResourceLocationAttribute(System.Reflection.Assembly assembly) { throw null; }
protected virtual string GetResourcePrefix(System.Reflection.TypeInfo typeInfo) { throw null; }
protected virtual string GetResourcePrefix(System.Reflection.TypeInfo typeInfo, string baseNamespace, string resourcesRelativePath) { throw null; }
protected virtual string GetResourcePrefix(string baseResourceName, string baseNamespace) { throw null; }
protected virtual string GetResourcePrefix(string location, string baseName, string resourceLocation) { throw null; }
protected virtual Microsoft.Extensions.Localization.RootNamespaceAttribute GetRootNamespaceAttribute(System.Reflection.Assembly assembly) { throw null; }
}
[System.ObsoleteAttribute("This method is obsolete. Use `CurrentCulture` and `CurrentUICulture` instead.")]
public partial class ResourceManagerWithCultureStringLocalizer : Microsoft.Extensions.Localization.ResourceManagerStringLocalizer
{
public ResourceManagerWithCultureStringLocalizer(System.Resources.ResourceManager resourceManager, System.Reflection.Assembly resourceAssembly, string baseName, Microsoft.Extensions.Localization.IResourceNamesCache resourceNamesCache, System.Globalization.CultureInfo culture, Microsoft.Extensions.Logging.ILogger logger) : base (default(System.Resources.ResourceManager), default(System.Reflection.Assembly), default(string), default(Microsoft.Extensions.Localization.IResourceNamesCache), default(Microsoft.Extensions.Logging.ILogger)) { }
public override Microsoft.Extensions.Localization.LocalizedString this[string name] { get { throw null; } }
public override Microsoft.Extensions.Localization.LocalizedString this[string name, params object[] arguments] { get { throw null; } }
public override System.Collections.Generic.IEnumerable<Microsoft.Extensions.Localization.LocalizedString> GetAllStrings(bool includeParentCultures) { throw null; }
}
public partial class ResourceNamesCache : Microsoft.Extensions.Localization.IResourceNamesCache
{
public ResourceNamesCache() { }
public System.Collections.Generic.IList<string> GetOrAdd(string name, System.Func<string, System.Collections.Generic.IList<string>> valueFactory) { throw null; }
}
[System.AttributeUsageAttribute(System.AttributeTargets.Assembly, AllowMultiple=false, Inherited=false)]
public partial class RootNamespaceAttribute : System.Attribute
{
public RootNamespaceAttribute(string rootNamespace) { }
public string RootNamespace { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
}
namespace Microsoft.Extensions.Localization.Internal
{
public partial class AssemblyWrapper
{
public AssemblyWrapper(System.Reflection.Assembly assembly) { }
public System.Reflection.Assembly Assembly { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public virtual string FullName { get { throw null; } }
public virtual System.IO.Stream GetManifestResourceStream(string name) { throw null; }
}
public partial interface IResourceStringProvider
{
System.Collections.Generic.IList<string> GetAllResourceStrings(System.Globalization.CultureInfo culture, bool throwOnMissing);
}
public partial class ResourceManagerStringProvider : Microsoft.Extensions.Localization.Internal.IResourceStringProvider
{
public ResourceManagerStringProvider(Microsoft.Extensions.Localization.IResourceNamesCache resourceCache, System.Resources.ResourceManager resourceManager, System.Reflection.Assembly assembly, string baseName) { }
public System.Collections.Generic.IList<string> GetAllResourceStrings(System.Globalization.CultureInfo culture, bool throwOnMissing) { throw null; }
}
}

View File

@ -0,0 +1,93 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.Extensions.DependencyInjection
{
public static partial class LocalizationServiceCollectionExtensions
{
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddLocalization(this Microsoft.Extensions.DependencyInjection.IServiceCollection services) { throw null; }
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddLocalization(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Action<Microsoft.Extensions.Localization.LocalizationOptions> setupAction) { throw null; }
}
}
namespace Microsoft.Extensions.Localization
{
public partial interface IResourceNamesCache
{
System.Collections.Generic.IList<string> GetOrAdd(string name, System.Func<string, System.Collections.Generic.IList<string>> valueFactory);
}
public partial class LocalizationOptions
{
public LocalizationOptions() { }
public string ResourcesPath { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
}
[System.AttributeUsageAttribute(System.AttributeTargets.Assembly, AllowMultiple=false, Inherited=false)]
public partial class ResourceLocationAttribute : System.Attribute
{
public ResourceLocationAttribute(string resourceLocation) { }
public string ResourceLocation { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
public partial class ResourceManagerStringLocalizer : Microsoft.Extensions.Localization.IStringLocalizer
{
public ResourceManagerStringLocalizer(System.Resources.ResourceManager resourceManager, Microsoft.Extensions.Localization.Internal.AssemblyWrapper resourceAssemblyWrapper, string baseName, Microsoft.Extensions.Localization.IResourceNamesCache resourceNamesCache, Microsoft.Extensions.Logging.ILogger logger) { }
public ResourceManagerStringLocalizer(System.Resources.ResourceManager resourceManager, Microsoft.Extensions.Localization.Internal.IResourceStringProvider resourceStringProvider, string baseName, Microsoft.Extensions.Localization.IResourceNamesCache resourceNamesCache, Microsoft.Extensions.Logging.ILogger logger) { }
public ResourceManagerStringLocalizer(System.Resources.ResourceManager resourceManager, System.Reflection.Assembly resourceAssembly, string baseName, Microsoft.Extensions.Localization.IResourceNamesCache resourceNamesCache, Microsoft.Extensions.Logging.ILogger logger) { }
public virtual Microsoft.Extensions.Localization.LocalizedString this[string name] { get { throw null; } }
public virtual Microsoft.Extensions.Localization.LocalizedString this[string name, params object[] arguments] { get { throw null; } }
public virtual System.Collections.Generic.IEnumerable<Microsoft.Extensions.Localization.LocalizedString> GetAllStrings(bool includeParentCultures) { throw null; }
protected System.Collections.Generic.IEnumerable<Microsoft.Extensions.Localization.LocalizedString> GetAllStrings(bool includeParentCultures, System.Globalization.CultureInfo culture) { throw null; }
protected string GetStringSafely(string name, System.Globalization.CultureInfo culture) { throw null; }
[System.ObsoleteAttribute("This method is obsolete. Use `CurrentCulture` and `CurrentUICulture` instead.")]
public Microsoft.Extensions.Localization.IStringLocalizer WithCulture(System.Globalization.CultureInfo culture) { throw null; }
}
public partial class ResourceManagerStringLocalizerFactory : Microsoft.Extensions.Localization.IStringLocalizerFactory
{
public ResourceManagerStringLocalizerFactory(Microsoft.Extensions.Options.IOptions<Microsoft.Extensions.Localization.LocalizationOptions> localizationOptions, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory) { }
public Microsoft.Extensions.Localization.IStringLocalizer Create(string baseName, string location) { throw null; }
public Microsoft.Extensions.Localization.IStringLocalizer Create(System.Type resourceSource) { throw null; }
protected virtual Microsoft.Extensions.Localization.ResourceManagerStringLocalizer CreateResourceManagerStringLocalizer(System.Reflection.Assembly assembly, string baseName) { throw null; }
protected virtual Microsoft.Extensions.Localization.ResourceLocationAttribute GetResourceLocationAttribute(System.Reflection.Assembly assembly) { throw null; }
protected virtual string GetResourcePrefix(System.Reflection.TypeInfo typeInfo) { throw null; }
protected virtual string GetResourcePrefix(System.Reflection.TypeInfo typeInfo, string baseNamespace, string resourcesRelativePath) { throw null; }
protected virtual string GetResourcePrefix(string baseResourceName, string baseNamespace) { throw null; }
protected virtual string GetResourcePrefix(string location, string baseName, string resourceLocation) { throw null; }
protected virtual Microsoft.Extensions.Localization.RootNamespaceAttribute GetRootNamespaceAttribute(System.Reflection.Assembly assembly) { throw null; }
}
[System.ObsoleteAttribute("This method is obsolete. Use `CurrentCulture` and `CurrentUICulture` instead.")]
public partial class ResourceManagerWithCultureStringLocalizer : Microsoft.Extensions.Localization.ResourceManagerStringLocalizer
{
public ResourceManagerWithCultureStringLocalizer(System.Resources.ResourceManager resourceManager, System.Reflection.Assembly resourceAssembly, string baseName, Microsoft.Extensions.Localization.IResourceNamesCache resourceNamesCache, System.Globalization.CultureInfo culture, Microsoft.Extensions.Logging.ILogger logger) : base (default(System.Resources.ResourceManager), default(System.Reflection.Assembly), default(string), default(Microsoft.Extensions.Localization.IResourceNamesCache), default(Microsoft.Extensions.Logging.ILogger)) { }
public override Microsoft.Extensions.Localization.LocalizedString this[string name] { get { throw null; } }
public override Microsoft.Extensions.Localization.LocalizedString this[string name, params object[] arguments] { get { throw null; } }
public override System.Collections.Generic.IEnumerable<Microsoft.Extensions.Localization.LocalizedString> GetAllStrings(bool includeParentCultures) { throw null; }
}
public partial class ResourceNamesCache : Microsoft.Extensions.Localization.IResourceNamesCache
{
public ResourceNamesCache() { }
public System.Collections.Generic.IList<string> GetOrAdd(string name, System.Func<string, System.Collections.Generic.IList<string>> valueFactory) { throw null; }
}
[System.AttributeUsageAttribute(System.AttributeTargets.Assembly, AllowMultiple=false, Inherited=false)]
public partial class RootNamespaceAttribute : System.Attribute
{
public RootNamespaceAttribute(string rootNamespace) { }
public string RootNamespace { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
}
namespace Microsoft.Extensions.Localization.Internal
{
public partial class AssemblyWrapper
{
public AssemblyWrapper(System.Reflection.Assembly assembly) { }
public System.Reflection.Assembly Assembly { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public virtual string FullName { get { throw null; } }
public virtual System.IO.Stream GetManifestResourceStream(string name) { throw null; }
}
public partial interface IResourceStringProvider
{
System.Collections.Generic.IList<string> GetAllResourceStrings(System.Globalization.CultureInfo culture, bool throwOnMissing);
}
public partial class ResourceManagerStringProvider : Microsoft.Extensions.Localization.Internal.IResourceStringProvider
{
public ResourceManagerStringProvider(Microsoft.Extensions.Localization.IResourceNamesCache resourceCache, System.Resources.ResourceManager resourceManager, System.Reflection.Assembly assembly, string baseName) { }
public System.Collections.Generic.IList<string> GetAllResourceStrings(System.Globalization.CultureInfo culture, bool throwOnMissing) { throw null; }
}
}

View File

@ -3,7 +3,8 @@
<PropertyGroup> <PropertyGroup>
<Product>Microsoft .NET Extensions</Product> <Product>Microsoft .NET Extensions</Product>
<Description>Application localization services and default implementation based on ResourceManager to load localized assembly resources.</Description> <Description>Application localization services and default implementation based on ResourceManager to load localized assembly resources.</Description>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFrameworks>netstandard2.0;netcoreapp5.0</TargetFrameworks>
<TargetFrameworks Condition="'$(DotNetBuildFromSource)' == 'true'">netcoreapp5.0</TargetFrameworks>
<NoWarn>$(NoWarn);CS1591</NoWarn> <NoWarn>$(NoWarn);CS1591</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>localization</PackageTags> <PackageTags>localization</PackageTags>

View File

@ -1,7 +1,7 @@
<!-- This file is automatically generated. --> <!-- This file is automatically generated. -->
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks> <TargetFrameworks>netstandard2.0;netcoreapp5.0</TargetFrameworks>
</PropertyGroup> </PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'"> <ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<Compile Include="Microsoft.Extensions.WebEncoders.netstandard2.0.cs" /> <Compile Include="Microsoft.Extensions.WebEncoders.netstandard2.0.cs" />
@ -9,4 +9,9 @@
<Reference Include="Microsoft.Extensions.Options" /> <Reference Include="Microsoft.Extensions.Options" />
<Reference Include="System.Text.Encodings.Web" /> <Reference Include="System.Text.Encodings.Web" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp5.0'">
<Compile Include="Microsoft.Extensions.WebEncoders.netcoreapp5.0.cs" />
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
<Reference Include="Microsoft.Extensions.Options" />
</ItemGroup>
</Project> </Project>

View File

@ -0,0 +1,55 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.Extensions.DependencyInjection
{
public static partial class EncoderServiceCollectionExtensions
{
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddWebEncoders(this Microsoft.Extensions.DependencyInjection.IServiceCollection services) { throw null; }
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddWebEncoders(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Action<Microsoft.Extensions.WebEncoders.WebEncoderOptions> setupAction) { throw null; }
}
}
namespace Microsoft.Extensions.WebEncoders
{
public sealed partial class WebEncoderOptions
{
public WebEncoderOptions() { }
public System.Text.Encodings.Web.TextEncoderSettings TextEncoderSettings { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
}
}
namespace Microsoft.Extensions.WebEncoders.Testing
{
public sealed partial class HtmlTestEncoder : System.Text.Encodings.Web.HtmlEncoder
{
public HtmlTestEncoder() { }
public override int MaxOutputCharactersPerInputCharacter { get { throw null; } }
public override void Encode(System.IO.TextWriter output, char[] value, int startIndex, int characterCount) { }
public override void Encode(System.IO.TextWriter output, string value, int startIndex, int characterCount) { }
public override string Encode(string value) { throw null; }
public unsafe override int FindFirstCharacterToEncode(char* text, int textLength) { throw null; }
public unsafe override bool TryEncodeUnicodeScalar(int unicodeScalar, char* buffer, int bufferLength, out int numberOfCharactersWritten) { throw null; }
public override bool WillEncode(int unicodeScalar) { throw null; }
}
public partial class JavaScriptTestEncoder : System.Text.Encodings.Web.JavaScriptEncoder
{
public JavaScriptTestEncoder() { }
public override int MaxOutputCharactersPerInputCharacter { get { throw null; } }
public override void Encode(System.IO.TextWriter output, char[] value, int startIndex, int characterCount) { }
public override void Encode(System.IO.TextWriter output, string value, int startIndex, int characterCount) { }
public override string Encode(string value) { throw null; }
public unsafe override int FindFirstCharacterToEncode(char* text, int textLength) { throw null; }
public unsafe override bool TryEncodeUnicodeScalar(int unicodeScalar, char* buffer, int bufferLength, out int numberOfCharactersWritten) { throw null; }
public override bool WillEncode(int unicodeScalar) { throw null; }
}
public partial class UrlTestEncoder : System.Text.Encodings.Web.UrlEncoder
{
public UrlTestEncoder() { }
public override int MaxOutputCharactersPerInputCharacter { get { throw null; } }
public override void Encode(System.IO.TextWriter output, char[] value, int startIndex, int characterCount) { }
public override void Encode(System.IO.TextWriter output, string value, int startIndex, int characterCount) { }
public override string Encode(string value) { throw null; }
public unsafe override int FindFirstCharacterToEncode(char* text, int textLength) { throw null; }
public unsafe override bool TryEncodeUnicodeScalar(int unicodeScalar, char* buffer, int bufferLength, out int numberOfCharactersWritten) { throw null; }
public override bool WillEncode(int unicodeScalar) { throw null; }
}
}

View File

@ -0,0 +1,55 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.Extensions.DependencyInjection
{
public static partial class EncoderServiceCollectionExtensions
{
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddWebEncoders(this Microsoft.Extensions.DependencyInjection.IServiceCollection services) { throw null; }
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddWebEncoders(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Action<Microsoft.Extensions.WebEncoders.WebEncoderOptions> setupAction) { throw null; }
}
}
namespace Microsoft.Extensions.WebEncoders
{
public sealed partial class WebEncoderOptions
{
public WebEncoderOptions() { }
public System.Text.Encodings.Web.TextEncoderSettings TextEncoderSettings { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
}
}
namespace Microsoft.Extensions.WebEncoders.Testing
{
public sealed partial class HtmlTestEncoder : System.Text.Encodings.Web.HtmlEncoder
{
public HtmlTestEncoder() { }
public override int MaxOutputCharactersPerInputCharacter { get { throw null; } }
public override void Encode(System.IO.TextWriter output, char[] value, int startIndex, int characterCount) { }
public override void Encode(System.IO.TextWriter output, string value, int startIndex, int characterCount) { }
public override string Encode(string value) { throw null; }
public unsafe override int FindFirstCharacterToEncode(char* text, int textLength) { throw null; }
public unsafe override bool TryEncodeUnicodeScalar(int unicodeScalar, char* buffer, int bufferLength, out int numberOfCharactersWritten) { throw null; }
public override bool WillEncode(int unicodeScalar) { throw null; }
}
public partial class JavaScriptTestEncoder : System.Text.Encodings.Web.JavaScriptEncoder
{
public JavaScriptTestEncoder() { }
public override int MaxOutputCharactersPerInputCharacter { get { throw null; } }
public override void Encode(System.IO.TextWriter output, char[] value, int startIndex, int characterCount) { }
public override void Encode(System.IO.TextWriter output, string value, int startIndex, int characterCount) { }
public override string Encode(string value) { throw null; }
public unsafe override int FindFirstCharacterToEncode(char* text, int textLength) { throw null; }
public unsafe override bool TryEncodeUnicodeScalar(int unicodeScalar, char* buffer, int bufferLength, out int numberOfCharactersWritten) { throw null; }
public override bool WillEncode(int unicodeScalar) { throw null; }
}
public partial class UrlTestEncoder : System.Text.Encodings.Web.UrlEncoder
{
public UrlTestEncoder() { }
public override int MaxOutputCharactersPerInputCharacter { get { throw null; } }
public override void Encode(System.IO.TextWriter output, char[] value, int startIndex, int characterCount) { }
public override void Encode(System.IO.TextWriter output, string value, int startIndex, int characterCount) { }
public override string Encode(string value) { throw null; }
public unsafe override int FindFirstCharacterToEncode(char* text, int textLength) { throw null; }
public unsafe override bool TryEncodeUnicodeScalar(int unicodeScalar, char* buffer, int bufferLength, out int numberOfCharactersWritten) { throw null; }
public override bool WillEncode(int unicodeScalar) { throw null; }
}
}

View File

@ -2,7 +2,8 @@
<PropertyGroup> <PropertyGroup>
<Description>Contains registration and configuration APIs to add the core framework encoders to a dependency injection container.</Description> <Description>Contains registration and configuration APIs to add the core framework encoders to a dependency injection container.</Description>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFrameworks>netstandard2.0;netcoreapp5.0</TargetFrameworks>
<TargetFrameworks Condition="'$(DotNetBuildFromSource)' == 'true'">netcoreapp5.0</TargetFrameworks>
<NoWarn>$(NoWarn);CS1591</NoWarn> <NoWarn>$(NoWarn);CS1591</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>aspnetcore</PackageTags> <PackageTags>aspnetcore</PackageTags>
@ -13,6 +14,9 @@
<ItemGroup> <ItemGroup>
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions" /> <Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
<Reference Include="Microsoft.Extensions.Options" /> <Reference Include="Microsoft.Extensions.Options" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<Reference Include="System.Text.Encodings.Web" /> <Reference Include="System.Text.Encodings.Web" />
</ItemGroup> </ItemGroup>