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.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;
@ -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.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.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 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 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
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
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
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.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.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;
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.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.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.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.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.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.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.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
#endif
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using System;
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 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;
#if UNITY_2018_3_OR_NEWER
using UnityEngine;
#endif
namespace Cysharp.Threading.Tasks.Internal
{
@ -31,6 +32,8 @@ namespace Cysharp.Threading.Tasks.Internal
return WellKnownNoReferenceContainsTypeInitialize(t.GetGenericArguments()[0]);
}
#if UNITY_2018_3_OR_NEWER
// or add other wellknown types(Vector, etc...) here
if (t == typeof(Vector2)) 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(Vector3Int)) return true;
#endif
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.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.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.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.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.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.Threading;
using UnityEngine.Events;
namespace Cysharp.Threading.Tasks
{
@ -117,11 +115,15 @@ namespace Cysharp.Threading.Tasks
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);
}
#endif
/// <summary>
/// helper of create add UniTaskVoid to delegate.
/// 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);
}
}
#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;
@ -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.Runtime.CompilerServices;
@ -11,6 +10,8 @@ namespace Cysharp.Threading.Tasks
{
public partial struct UniTask
{
#if UNITY_2018_3_OR_NEWER
/// <summary>
/// If running on mainthread, do nothing. Otherwise, same as UniTask.Yield(PlayerLoopTiming.Update).
/// </summary>
@ -19,6 +20,8 @@ namespace Cysharp.Threading.Tasks
return new SwitchToMainThreadAwaitable();
}
#endif
public static SwitchToThreadPoolAwaitable SwitchToThreadPool()
{
return new SwitchToThreadPoolAwaitable();
@ -36,6 +39,8 @@ namespace Cysharp.Threading.Tasks
}
}
#if UNITY_2018_3_OR_NEWER
public struct SwitchToMainThreadAwaitable
{
public Awaiter GetAwaiter() => new Awaiter();
@ -72,6 +77,8 @@ namespace Cysharp.Threading.Tasks
}
}
#endif
public struct SwitchToThreadPoolAwaitable
{
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.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.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.Collections.Generic;
@ -46,7 +45,6 @@ namespace Cysharp.Threading.Tasks
sealed class WhenAnyLRPromise<T> : IUniTaskSource<(bool, T)>
{
int completedCount;
int winArgumentIndex;
UniTaskCompletionSourceCore<(bool, T)> core;
public WhenAnyLRPromise(UniTask<T> leftTask, UniTask rightTask)
@ -184,7 +182,6 @@ namespace Cysharp.Threading.Tasks
sealed class WhenAnyPromise<T> : IUniTaskSource<(int, T)>
{
int completedCount;
int winArgumentIndex;
UniTaskCompletionSourceCore<(int, T)> core;
public WhenAnyPromise(UniTask<T>[] tasks, int tasksLength)
@ -276,7 +273,6 @@ namespace Cysharp.Threading.Tasks
sealed class WhenAnyPromise : IUniTaskSource<int>
{
int completedCount;
int winArgumentIndex;
UniTaskCompletionSourceCore<int> core;
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
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.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.Collections;
@ -190,6 +189,8 @@ namespace Cysharp.Threading.Tasks
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)
{
return new ToCoroutineEnumerator<T>(task, resultHandler, exceptionHandler);
@ -376,6 +377,8 @@ namespace Cysharp.Threading.Tasks
return (false, taskResult.Result);
}
#endif
public static void Forget(this UniTask task)
{
var awaiter = task.GetAwaiter();
@ -431,7 +434,9 @@ namespace Cysharp.Threading.Tasks
{
if (handleExceptionOnMainThread)
{
#if UNITY_2018_3_OR_NEWER
await UniTask.SwitchToMainThread();
#endif
}
exceptionHandler(ex);
}
@ -497,7 +502,9 @@ namespace Cysharp.Threading.Tasks
{
if (handleExceptionOnMainThread)
{
#if UNITY_2018_3_OR_NEWER
await UniTask.SwitchToMainThread();
#endif
}
exceptionHandler(ex);
}
@ -552,6 +559,8 @@ namespace Cysharp.Threading.Tasks
return await continuationFunction();
}
#if UNITY_2018_3_OR_NEWER
public static async UniTask ConfigureAwait(this Task task, PlayerLoopTiming timing)
{
await task.ConfigureAwait(false);
@ -578,6 +587,8 @@ namespace Cysharp.Threading.Tasks
return v;
}
#endif
public static async UniTask<T> Unwrap<T>(this UniTask<UniTask<T>> task)
{
return await await task;
@ -588,6 +599,8 @@ namespace Cysharp.Threading.Tasks
await await task;
}
#if UNITY_2018_3_OR_NEWER
class ToCoroutineEnumerator : IEnumerator
{
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.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.Threading;
@ -18,6 +17,8 @@ namespace Cysharp.Threading.Tasks
/// </summary>
public static bool PropagateOperationCanceledException = false;
#if UNITY_2018_3_OR_NEWER
/// <summary>
/// Write log type when catch unobserved exception and not registered UnobservedTaskException. Default is Error.
/// </summary>
@ -27,10 +28,16 @@ namespace Cysharp.Threading.Tasks
/// Dispatch exception event to Unity MainThread. Default is true.
/// </summary>
public static bool DispatchUnityMainThread = true;
// cache delegate.
static readonly SendOrPostCallback handleExceptionInvoke = InvokeUnobservedTaskException;
static void InvokeUnobservedTaskException(object state)
{
UnobservedTaskException((Exception)state);
}
#endif
internal static void PublishUnobservedTaskException(Exception ex)
{
if (ex != null)
@ -42,6 +49,7 @@ namespace Cysharp.Threading.Tasks
if (UnobservedTaskException != null)
{
#if UNITY_2018_3_OR_NEWER
if (!DispatchUnityMainThread || Thread.CurrentThread.ManagedThreadId == PlayerLoopHelper.MainThreadId)
{
// allows inlining call.
@ -52,9 +60,13 @@ namespace Cysharp.Threading.Tasks
// Post to MainThread.
PlayerLoopHelper.UnitySynchronizationContext.Post(handleExceptionInvoke, ex);
}
#else
UnobservedTaskException.Invoke(ex);
#endif
}
else
{
#if UNITY_2018_3_OR_NEWER
string msg = null;
if (UnobservedExceptionWriteLogType != UnityEngine.LogType.Exception)
{
@ -80,15 +92,12 @@ namespace Cysharp.Threading.Tasks
default:
break;
}
#else
Console.WriteLine(ex.ToString());
#endif
}
}
}
static void InvokeUnobservedTaskException(object state)
{
UnobservedTaskException((Exception)state);
}
}
}
#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
using System;
@ -30,7 +29,9 @@ namespace Cysharp.Threading.Tasks
[DebuggerHidden]
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.");
#endif
}
[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
using System;