Add ValueTask support (#89)
* Add ValueTask support * remove netstandard2.1
This commit is contained in:
parent
c061f764bd
commit
eaf0393860
@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<Product>Ben Core</Product>
|
||||
@ -15,16 +15,18 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
|
||||
<!--<TargetFrameworks>netstandard2.0;netstandard2.1;net45</TargetFrameworks>-->
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Nerdbank.GitVersioning" Version="2.1.17" PrivateAssets="all" />
|
||||
<PackageReference Include="SourceLink.Create.CommandLine" Version="2.7.6" PrivateAssets="all" />
|
||||
<PackageReference Include="Nerdbank.GitVersioning" Version="3.0.25" PrivateAssets="all" />
|
||||
<PackageReference Include="SourceLink.Create.CommandLine" Version="2.8.3" PrivateAssets="all" />
|
||||
<PackageReference Include="System.Reflection.Metadata">
|
||||
<Version>1.5.0</Version>
|
||||
<Version>1.6.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.3" Condition="'$(TargetFramework)' != 'netstandard2.1'" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Label="TestInternalsVisibleTo">
|
||||
|
||||
@ -647,6 +647,10 @@ namespace System.Diagnostics
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (type == typeof(ValueTask<>) && method.Name == "get_Result")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (type == typeof(Task))
|
||||
{
|
||||
switch (method.Name)
|
||||
@ -687,6 +691,10 @@ namespace System.Diagnostics
|
||||
}
|
||||
else if (type == typeof(TaskAwaiter) ||
|
||||
type == typeof(TaskAwaiter<>) ||
|
||||
type == typeof(ValueTaskAwaiter) ||
|
||||
type == typeof(ValueTaskAwaiter<>) ||
|
||||
type == typeof(ConfiguredValueTaskAwaitable.ConfiguredValueTaskAwaiter) ||
|
||||
type == typeof(ConfiguredValueTaskAwaitable<>.ConfiguredValueTaskAwaiter) ||
|
||||
type == typeof(ConfiguredTaskAwaitable.ConfiguredTaskAwaiter) ||
|
||||
type == typeof(ConfiguredTaskAwaitable<>.ConfiguredTaskAwaiter))
|
||||
{
|
||||
|
||||
@ -39,13 +39,12 @@ namespace Ben.Demystifier.Test
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Exception GetMixedStackException()
|
||||
{
|
||||
Exception exception = null;
|
||||
try
|
||||
{
|
||||
Start((val:"", true));
|
||||
Start((val: "", true));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -61,7 +60,7 @@ namespace Ben.Demystifier.Test
|
||||
"string string.Join(string separator, IEnumerable<string> values)",
|
||||
"string Ben.Demystifier.Test.MixedStack+GenericClass<T>.GenericMethod<V>(ref V value)",
|
||||
"async Task<string> Ben.Demystifier.Test.MixedStack.MethodAsync(int value)",
|
||||
"async Task<string> Ben.Demystifier.Test.MixedStack.MethodAsync<TValue>(TValue value)",
|
||||
"async ValueTask<string> Ben.Demystifier.Test.MixedStack.MethodAsync<TValue>(TValue value)",
|
||||
"(string val, bool) Ben.Demystifier.Test.MixedStack.Method(string value)",
|
||||
"ref string Ben.Demystifier.Test.MixedStack.RefMethod(string value)",
|
||||
"(string val, bool) Ben.Demystifier.Test.MixedStack.s_func(string s, bool b)",
|
||||
@ -91,7 +90,7 @@ namespace Ben.Demystifier.Test
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)]
|
||||
static async Task<string> MethodAsync<TValue>(TValue value) => await MethodAsync(1);
|
||||
static async ValueTask<string> MethodAsync<TValue>(TValue value) => await MethodAsync(1);
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)]
|
||||
static (string val, bool) Method(string value) => (MethodAsync(value).GetAwaiter().GetResult(), true);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user