DotNetCore Version

pull/73/head
neuecc 2020-05-05 21:05:32 +09:00
parent 7cb0b17e6a
commit b9b2925e8d
46 changed files with 239 additions and 129 deletions

37
UniTask.NetCore.sln Normal file
View File

@ -0,0 +1,37 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29613.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniTask.NetCoreTests", "src\UniTask.NetCoreTests\UniTask.NetCoreTests.csproj", "{B3E311A4-70D8-4131-9965-C073A99D201A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniTask.NetCore", "src\UniTask.NetCore\UniTask.NetCore.csproj", "{16EE20D0-7FB1-483A-8467-A5EEDBF1F5BF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniTask.NetCoreSandbox", "src\UniTask.NetCoreSandbox\UniTask.NetCoreSandbox.csproj", "{3915E72E-33E0-4A14-A6D8-872702200E58}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B3E311A4-70D8-4131-9965-C073A99D201A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B3E311A4-70D8-4131-9965-C073A99D201A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B3E311A4-70D8-4131-9965-C073A99D201A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B3E311A4-70D8-4131-9965-C073A99D201A}.Release|Any CPU.Build.0 = Release|Any CPU
{16EE20D0-7FB1-483A-8467-A5EEDBF1F5BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{16EE20D0-7FB1-483A-8467-A5EEDBF1F5BF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{16EE20D0-7FB1-483A-8467-A5EEDBF1F5BF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{16EE20D0-7FB1-483A-8467-A5EEDBF1F5BF}.Release|Any CPU.Build.0 = Release|Any CPU
{3915E72E-33E0-4A14-A6D8-872702200E58}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3915E72E-33E0-4A14-A6D8-872702200E58}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3915E72E-33E0-4A14-A6D8-872702200E58}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3915E72E-33E0-4A14-A6D8-872702200E58}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {90F78FCC-7CD4-4E88-A3DB-873F481F8C8B}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>UniTask</AssemblyName>
<RootNamespace>Cysharp.Threading.Tasks</RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\UniTask\Assets\Plugins\UniTask\**\*.cs"
Exclude="..\UniTask\Assets\Plugins\UniTask\Triggers\*.cs;
..\UniTask\Assets\Plugins\UniTask\Editor\*.cs;
..\UniTask\Assets\Plugins\UniTask\Internal\UnityEqualityComparer.cs;
..\UniTask\Assets\Plugins\UniTask\Internal\DiagnosticsExtensions.cs;
..\UniTask\Assets\Plugins\UniTask\Internal\PlayerLoopRunner.cs;
..\UniTask\Assets\Plugins\UniTask\CancellationTokenSourceExtensions.cs;
..\UniTask\Assets\Plugins\UniTask\EnumeratorAsyncExtensions.cs;
..\UniTask\Assets\Plugins\UniTask\PlayerLoopHelper.cs;
..\UniTask\Assets\Plugins\UniTask\UniTask.Delay.cs;
..\UniTask\Assets\Plugins\UniTask\UniTask.Run.cs;
..\UniTask\Assets\Plugins\UniTask\UniTask.Bridge.cs;
..\UniTask\Assets\Plugins\UniTask\UniTask.WaitUntil.cs;
..\UniTask\Assets\Plugins\UniTask\UnityAsyncExtensions.cs;
..\UniTask\Assets\Plugins\UniTask\UnityAsyncExtensions.uGUI.cs;
..\UniTask\Assets\Plugins\UniTask\UnityAsyncExtensions.MonoBehaviour.cs;
"/>
</ItemGroup>
</Project>

View File

@ -0,0 +1,32 @@
using Cysharp.Threading.Tasks;
using System;
using System.Threading.Tasks;
namespace NetCoreSandbox
{
class Program
{
static async Task Main(string[] args)
{
Console.WriteLine("Foo");
var v = await DoAsync().AsTask();
Console.WriteLine("Bar:" + v);
}
static async UniTask<int> DoAsync()
{
var tcs = new UniTaskCompletionSource<int>();
tcs.TrySetResult(100);
var v = await tcs.Task;
return v;
}
}
}

View File

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>NetCoreSandbox</RootNamespace>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\UniTask.NetCore\UniTask.NetCore.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
<RootNamespace>NetCoreTests</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="coverlet.collector" Version="1.0.1" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,14 @@
using System;
using Xunit;
namespace UniTask.NetCoreTests
{
public class UnitTest1
{
[Fact]
public void Test1()
{
}
}
}

View File

@ -1,5 +1,4 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using System; using System;
using System.Threading; using System.Threading;
@ -118,4 +117,3 @@ namespace Cysharp.Threading.Tasks
} }
} }
} }
#endif

View File

@ -1,5 +1,4 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) #pragma warning disable CS1591 // Missing XML comment for publicly visible type or
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or
using System; using System;
@ -25,4 +24,3 @@ namespace Cysharp.Threading.Tasks
} }
} }
} }
#endif

View File

@ -1,5 +1,4 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading; using System.Threading;
@ -22,4 +21,3 @@ namespace Cysharp.Threading.Tasks
} }
} }
#endif

View File

@ -1,5 +1,4 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using System; using System;
using System.Threading; using System.Threading;
@ -73,4 +72,3 @@ namespace Cysharp.Threading.Tasks
} }
} }
#endif

View File

@ -1,5 +1,4 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using System.Threading; using System.Threading;
using UnityEngine; using UnityEngine;
@ -49,4 +48,3 @@ namespace Cysharp.Threading.Tasks
} }
} }
#endif

View File

@ -1,5 +1,4 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) 
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
#pragma warning disable CS0436 #pragma warning disable CS0436
@ -16,4 +15,3 @@ namespace System.Runtime.CompilerServices
} }
} }
#endif

View File

@ -1,5 +1,4 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) 
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using System; using System;
@ -270,4 +269,3 @@ namespace Cysharp.Threading.Tasks.CompilerServices
} }
} }
#endif

View File

@ -1,5 +1,4 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) 
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using System; using System;
@ -104,4 +103,3 @@ namespace Cysharp.Threading.Tasks.CompilerServices
} }
} }
#endif

View File

@ -1,5 +1,4 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) 
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using System; using System;
@ -56,4 +55,3 @@ namespace Cysharp.Threading.Tasks.CompilerServices
} }
} }
#endif

View File

@ -1,5 +1,4 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -33,4 +32,3 @@ namespace Cysharp.Threading.Tasks
} }
#endif

View File

@ -1,5 +1,4 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using System; using System;
using System.Collections; using System.Collections;
@ -227,4 +226,3 @@ namespace Cysharp.Threading.Tasks
} }
} }
#endif

View File

@ -1,5 +1,4 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) 
using System; using System;
namespace Cysharp.Threading.Tasks namespace Cysharp.Threading.Tasks
@ -13,4 +12,3 @@ namespace Cysharp.Threading.Tasks
} }
} }
#endif

View File

@ -1,5 +1,4 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) #pragma warning disable CS1591
#pragma warning disable CS1591
using System; using System;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
@ -65,4 +64,3 @@ namespace Cysharp.Threading.Tasks
} }
} }
#endif

View File

@ -1,5 +1,4 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using System; using System;
using System.Threading; using System.Threading;
@ -149,4 +148,3 @@ namespace Cysharp.Threading.Tasks.Internal
} }
} }
} }
#endif

View File

@ -1,5 +1,4 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -104,4 +103,3 @@ namespace Cysharp.Threading.Tasks.Internal
} }
} }
#endif

View File

@ -1,5 +1,4 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -72,4 +71,3 @@ namespace Cysharp.Threading.Tasks.Internal
} }
} }
#endif

View File

@ -1,5 +1,4 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using System; using System;
using System.Threading; using System.Threading;
@ -121,4 +120,3 @@ namespace Cysharp.Threading.Tasks.Internal
} }
} }
#endif

View File

@ -1,5 +1,4 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -248,4 +247,3 @@ namespace Cysharp.Threading.Tasks.Internal
} }
} }
#endif

View File

@ -1,5 +1,4 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using System; using System;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
@ -60,4 +59,3 @@ namespace Cysharp.Threading.Tasks.Internal
} }
} }
#endif

View File

@ -1,6 +1,4 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
#endif
using System; using System;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;

View File

@ -1,5 +1,4 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) 
using System; using System;
using UnityEngine; using UnityEngine;
@ -161,4 +160,3 @@ namespace Cysharp.Threading.Tasks.Internal
} }
} }
#endif

View File

@ -1,8 +1,9 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using System; using System;
#if UNITY_2018_3_OR_NEWER
using UnityEngine; using UnityEngine;
#endif
namespace Cysharp.Threading.Tasks.Internal namespace Cysharp.Threading.Tasks.Internal
{ {
@ -31,6 +32,8 @@ namespace Cysharp.Threading.Tasks.Internal
return WellKnownNoReferenceContainsTypeInitialize(t.GetGenericArguments()[0]); return WellKnownNoReferenceContainsTypeInitialize(t.GetGenericArguments()[0]);
} }
#if UNITY_2018_3_OR_NEWER
// or add other wellknown types(Vector, etc...) here // or add other wellknown types(Vector, etc...) here
if (t == typeof(Vector2)) return true; if (t == typeof(Vector2)) return true;
if (t == typeof(Vector3)) return true; if (t == typeof(Vector3)) return true;
@ -42,6 +45,8 @@ namespace Cysharp.Threading.Tasks.Internal
if (t == typeof(Vector2Int)) return true; if (t == typeof(Vector2Int)) return true;
if (t == typeof(Vector3Int)) return true; if (t == typeof(Vector3Int)) return true;
#endif
return false; return false;
} }
@ -57,4 +62,3 @@ namespace Cysharp.Threading.Tasks.Internal
} }
} }
#endif

View File

@ -1,5 +1,4 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -129,4 +128,3 @@ namespace Cysharp.Threading.Tasks
} }
} }
#endif

View File

@ -1,5 +1,4 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -333,4 +332,3 @@ namespace Cysharp.Threading.Tasks.Internal
} }
} }
#endif

View File

@ -1,5 +1,4 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using System; using System;
using System.Linq; using System.Linq;
@ -285,4 +284,3 @@ namespace Cysharp.Threading.Tasks
} }
} }
#endif

View File

@ -1,5 +1,4 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using System; using System;
using System.Collections; using System.Collections;
@ -17,4 +16,3 @@ namespace Cysharp.Threading.Tasks
} }
} }
#endif

View File

@ -1,5 +1,4 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using System; using System;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
@ -480,4 +479,3 @@ namespace Cysharp.Threading.Tasks
} }
} }
} }
#endif

View File

@ -1,9 +1,7 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using System; using System;
using System.Threading; using System.Threading;
using UnityEngine.Events;
namespace Cysharp.Threading.Tasks namespace Cysharp.Threading.Tasks
{ {
@ -117,11 +115,15 @@ namespace Cysharp.Threading.Tasks
return () => Void(asyncAction); return () => Void(asyncAction);
} }
public static UnityAction VoidUnityAction(Func<UniTask> asyncAction) #if UNITY_2018_3_OR_NEWER
public static UnityEngine.Events.UnityAction VoidUnityAction(Func<UniTask> asyncAction)
{ {
return () => Void(asyncAction); return () => Void(asyncAction);
} }
#endif
/// <summary> /// <summary>
/// helper of create add UniTaskVoid to delegate. /// helper of create add UniTaskVoid to delegate.
/// For example: FooEvent += (sender, e) => UniTask.Void(async arg => { /* */ }, (sender, e)) /// For example: FooEvent += (sender, e) => UniTask.Void(async arg => { /* */ }, (sender, e))
@ -142,4 +144,3 @@ namespace Cysharp.Threading.Tasks
public static readonly UniTask<int> One = UniTask.FromResult(1); public static readonly UniTask<int> One = UniTask.FromResult(1);
} }
} }
#endif

View File

@ -1,5 +1,4 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using System; using System;
@ -96,4 +95,3 @@ namespace Cysharp.Threading.Tasks
} }
} }
#endif

View File

@ -1,5 +1,4 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using System; using System;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
@ -11,6 +10,8 @@ namespace Cysharp.Threading.Tasks
{ {
public partial struct UniTask public partial struct UniTask
{ {
#if UNITY_2018_3_OR_NEWER
/// <summary> /// <summary>
/// If running on mainthread, do nothing. Otherwise, same as UniTask.Yield(PlayerLoopTiming.Update). /// If running on mainthread, do nothing. Otherwise, same as UniTask.Yield(PlayerLoopTiming.Update).
/// </summary> /// </summary>
@ -19,6 +20,8 @@ namespace Cysharp.Threading.Tasks
return new SwitchToMainThreadAwaitable(); return new SwitchToMainThreadAwaitable();
} }
#endif
public static SwitchToThreadPoolAwaitable SwitchToThreadPool() public static SwitchToThreadPoolAwaitable SwitchToThreadPool()
{ {
return new SwitchToThreadPoolAwaitable(); return new SwitchToThreadPoolAwaitable();
@ -36,6 +39,8 @@ namespace Cysharp.Threading.Tasks
} }
} }
#if UNITY_2018_3_OR_NEWER
public struct SwitchToMainThreadAwaitable public struct SwitchToMainThreadAwaitable
{ {
public Awaiter GetAwaiter() => new Awaiter(); public Awaiter GetAwaiter() => new Awaiter();
@ -72,6 +77,8 @@ namespace Cysharp.Threading.Tasks
} }
} }
#endif
public struct SwitchToThreadPoolAwaitable public struct SwitchToThreadPoolAwaitable
{ {
public Awaiter GetAwaiter() => new Awaiter(); public Awaiter GetAwaiter() => new Awaiter();
@ -173,4 +180,3 @@ namespace Cysharp.Threading.Tasks
} }
} }
#endif

View File

@ -1,5 +1,4 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -475,4 +474,3 @@ namespace Cysharp.Threading.Tasks
} }
} }
} }
#endif

View File

@ -1,5 +1,4 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -222,4 +221,3 @@ namespace Cysharp.Threading.Tasks
} }
} }
} }
#endif

View File

@ -1,5 +1,4 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -46,7 +45,6 @@ namespace Cysharp.Threading.Tasks
sealed class WhenAnyLRPromise<T> : IUniTaskSource<(bool, T)> sealed class WhenAnyLRPromise<T> : IUniTaskSource<(bool, T)>
{ {
int completedCount; int completedCount;
int winArgumentIndex;
UniTaskCompletionSourceCore<(bool, T)> core; UniTaskCompletionSourceCore<(bool, T)> core;
public WhenAnyLRPromise(UniTask<T> leftTask, UniTask rightTask) public WhenAnyLRPromise(UniTask<T> leftTask, UniTask rightTask)
@ -184,7 +182,6 @@ namespace Cysharp.Threading.Tasks
sealed class WhenAnyPromise<T> : IUniTaskSource<(int, T)> sealed class WhenAnyPromise<T> : IUniTaskSource<(int, T)>
{ {
int completedCount; int completedCount;
int winArgumentIndex;
UniTaskCompletionSourceCore<(int, T)> core; UniTaskCompletionSourceCore<(int, T)> core;
public WhenAnyPromise(UniTask<T>[] tasks, int tasksLength) public WhenAnyPromise(UniTask<T>[] tasks, int tasksLength)
@ -276,7 +273,6 @@ namespace Cysharp.Threading.Tasks
sealed class WhenAnyPromise : IUniTaskSource<int> sealed class WhenAnyPromise : IUniTaskSource<int>
{ {
int completedCount; int completedCount;
int winArgumentIndex;
UniTaskCompletionSourceCore<int> core; UniTaskCompletionSourceCore<int> core;
public WhenAnyPromise(UniTask[] tasks, int tasksLength) public WhenAnyPromise(UniTask[] tasks, int tasksLength)
@ -366,4 +362,3 @@ namespace Cysharp.Threading.Tasks
} }
} }
#endif

View File

@ -1,5 +1,4 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
#pragma warning disable CS0436 #pragma warning disable CS0436
using System; using System;
@ -652,4 +651,3 @@ namespace Cysharp.Threading.Tasks
} }
} }
#endif

View File

@ -1,5 +1,4 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using System; using System;
using System.Diagnostics; using System.Diagnostics;
@ -647,4 +646,3 @@ namespace Cysharp.Threading.Tasks
} }
} }
#endif

View File

@ -1,5 +1,4 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using System; using System;
using System.Collections; using System.Collections;
@ -190,6 +189,8 @@ namespace Cysharp.Threading.Tasks
return new AsyncLazy<T>(task.Preserve()); // require Preserve return new AsyncLazy<T>(task.Preserve()); // require Preserve
} }
#if UNITY_2018_3_OR_NEWER
public static IEnumerator ToCoroutine<T>(this UniTask<T> task, Action<T> resultHandler = null, Action<Exception> exceptionHandler = null) public static IEnumerator ToCoroutine<T>(this UniTask<T> task, Action<T> resultHandler = null, Action<Exception> exceptionHandler = null)
{ {
return new ToCoroutineEnumerator<T>(task, resultHandler, exceptionHandler); return new ToCoroutineEnumerator<T>(task, resultHandler, exceptionHandler);
@ -376,6 +377,8 @@ namespace Cysharp.Threading.Tasks
return (false, taskResult.Result); return (false, taskResult.Result);
} }
#endif
public static void Forget(this UniTask task) public static void Forget(this UniTask task)
{ {
var awaiter = task.GetAwaiter(); var awaiter = task.GetAwaiter();
@ -431,7 +434,9 @@ namespace Cysharp.Threading.Tasks
{ {
if (handleExceptionOnMainThread) if (handleExceptionOnMainThread)
{ {
#if UNITY_2018_3_OR_NEWER
await UniTask.SwitchToMainThread(); await UniTask.SwitchToMainThread();
#endif
} }
exceptionHandler(ex); exceptionHandler(ex);
} }
@ -497,7 +502,9 @@ namespace Cysharp.Threading.Tasks
{ {
if (handleExceptionOnMainThread) if (handleExceptionOnMainThread)
{ {
#if UNITY_2018_3_OR_NEWER
await UniTask.SwitchToMainThread(); await UniTask.SwitchToMainThread();
#endif
} }
exceptionHandler(ex); exceptionHandler(ex);
} }
@ -552,6 +559,8 @@ namespace Cysharp.Threading.Tasks
return await continuationFunction(); return await continuationFunction();
} }
#if UNITY_2018_3_OR_NEWER
public static async UniTask ConfigureAwait(this Task task, PlayerLoopTiming timing) public static async UniTask ConfigureAwait(this Task task, PlayerLoopTiming timing)
{ {
await task.ConfigureAwait(false); await task.ConfigureAwait(false);
@ -578,6 +587,8 @@ namespace Cysharp.Threading.Tasks
return v; return v;
} }
#endif
public static async UniTask<T> Unwrap<T>(this UniTask<UniTask<T>> task) public static async UniTask<T> Unwrap<T>(this UniTask<UniTask<T>> task)
{ {
return await await task; return await await task;
@ -588,6 +599,8 @@ namespace Cysharp.Threading.Tasks
await await task; await await task;
} }
#if UNITY_2018_3_OR_NEWER
class ToCoroutineEnumerator : IEnumerator class ToCoroutineEnumerator : IEnumerator
{ {
bool completed; bool completed;
@ -721,7 +734,8 @@ namespace Cysharp.Threading.Tasks
{ {
} }
} }
#endif
} }
} }
#endif

View File

@ -1,5 +1,4 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using System; using System;
using System.Runtime.ExceptionServices; using System.Runtime.ExceptionServices;
@ -743,4 +742,3 @@ namespace Cysharp.Threading.Tasks.Internal
} }
} }
#endif

View File

@ -1,5 +1,4 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using System; using System;
using System.Threading; using System.Threading;
@ -18,6 +17,8 @@ namespace Cysharp.Threading.Tasks
/// </summary> /// </summary>
public static bool PropagateOperationCanceledException = false; public static bool PropagateOperationCanceledException = false;
#if UNITY_2018_3_OR_NEWER
/// <summary> /// <summary>
/// Write log type when catch unobserved exception and not registered UnobservedTaskException. Default is Error. /// Write log type when catch unobserved exception and not registered UnobservedTaskException. Default is Error.
/// </summary> /// </summary>
@ -31,6 +32,12 @@ namespace Cysharp.Threading.Tasks
// cache delegate. // cache delegate.
static readonly SendOrPostCallback handleExceptionInvoke = InvokeUnobservedTaskException; static readonly SendOrPostCallback handleExceptionInvoke = InvokeUnobservedTaskException;
static void InvokeUnobservedTaskException(object state)
{
UnobservedTaskException((Exception)state);
}
#endif
internal static void PublishUnobservedTaskException(Exception ex) internal static void PublishUnobservedTaskException(Exception ex)
{ {
if (ex != null) if (ex != null)
@ -42,6 +49,7 @@ namespace Cysharp.Threading.Tasks
if (UnobservedTaskException != null) if (UnobservedTaskException != null)
{ {
#if UNITY_2018_3_OR_NEWER
if (!DispatchUnityMainThread || Thread.CurrentThread.ManagedThreadId == PlayerLoopHelper.MainThreadId) if (!DispatchUnityMainThread || Thread.CurrentThread.ManagedThreadId == PlayerLoopHelper.MainThreadId)
{ {
// allows inlining call. // allows inlining call.
@ -52,9 +60,13 @@ namespace Cysharp.Threading.Tasks
// Post to MainThread. // Post to MainThread.
PlayerLoopHelper.UnitySynchronizationContext.Post(handleExceptionInvoke, ex); PlayerLoopHelper.UnitySynchronizationContext.Post(handleExceptionInvoke, ex);
} }
#else
UnobservedTaskException.Invoke(ex);
#endif
} }
else else
{ {
#if UNITY_2018_3_OR_NEWER
string msg = null; string msg = null;
if (UnobservedExceptionWriteLogType != UnityEngine.LogType.Exception) if (UnobservedExceptionWriteLogType != UnityEngine.LogType.Exception)
{ {
@ -80,15 +92,12 @@ namespace Cysharp.Threading.Tasks
default: default:
break; break;
} }
} #else
} Console.WriteLine(ex.ToString());
}
static void InvokeUnobservedTaskException(object state)
{
UnobservedTaskException((Exception)state);
}
}
}
#endif #endif
}
}
}
}
}

View File

@ -1,5 +1,4 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) #pragma warning disable CS1591
#pragma warning disable CS1591
#pragma warning disable CS0436 #pragma warning disable CS0436
using System; using System;
@ -30,7 +29,9 @@ namespace Cysharp.Threading.Tasks
[DebuggerHidden] [DebuggerHidden]
public void GetResult() public void GetResult()
{ {
#if UNITY_2018_3_OR_NEWER
UnityEngine.Debug.LogWarning("UniTaskVoid can't await, always fire-and-forget. use Forget instead of await."); UnityEngine.Debug.LogWarning("UniTaskVoid can't await, always fire-and-forget. use Forget instead of await.");
#endif
} }
[DebuggerHidden] [DebuggerHidden]
@ -46,4 +47,3 @@ namespace Cysharp.Threading.Tasks
} }
} }
#endif

View File

@ -1,4 +1,4 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) && ENABLE_MANAGED_JOBS #if ENABLE_MANAGED_JOBS
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using System; using System;