From a7928e6b61795afc674780bf6bab2be266f86292 Mon Sep 17 00:00:00 2001 From: Stewart Miles Date: Thu, 20 Jul 2017 09:04:23 -0700 Subject: [PATCH] Type forwarding DLL for the Parse Task implementation and Unity plugin build. This patch introduces: * Type forwarding DLL for Parse implementation of System.Threading.Tasks. * Project which builds a Unity plugin package that can be used to redistribute Parse's implementation of System.Threading.Tasks. Unity 2017 adds experimental support for .NET 4.5 (upgrading from a partially compatible version of .NET 3.5). With .NET 4.5, the Parse Task implementation is no longer required as System.Threading.Task is present in the .NET framework. For users distributing assemblies built against the Unity.Compat.dll and Unity.Tasks.dll components, this results in Unity failing to compile assemblies when .NET 4.5 is selected due to duplicate implementations of System.Threading.Tasks. So for the .NET 4.5 configuration in Unity, the Unity.Tasks.dll assembly (built by Unity.Tasks.TypeForwards) has been introduced which simply type forwards to the system implementation of System.Threading.Tasks. To standardize the location of Unity.Tasks.dll and Unity.Compat.dll for plugin developers reusing these components, a project has been introduced (Unity.Tasks.UnityPlugin) which builds a ParseTasks.unitypackage containing both the .NET 3.5 Parse implementation of System.Threading.Tasks and the .NET 4.5 type forwarding DLL. Finally, asset labels are used to mark .NET compatibilty of assemblies in the ParseTasks.unitypackage and asset metadata is used to disable the .NET 4.5 type forwarding DLL by default allowing successful compilation when .NET 3.5 is selected in Unity. The asset labels utilized to mark .NET compatibility of assemblies can be used by Unity editor plugins (e.g Google.VersionHandler.dll distributed as part of https://github.com/googlesamples/unity-jar-resolver) to enable / disable assemblies based upon the .NET framework version selected smoothing out the end user experience. --- .gitignore | 5 +- .../Properties/AssemblyInfo.cs | 19 +++ .../Public/TaskTypeForwards.cs | 14 +++ .../Unity.Tasks.TypeForwards.csproj | 59 +++++++++ .../Properties/AssemblyInfo.cs | 19 +++ .../Unity.Tasks.UnityPlugin.csproj | 115 ++++++++++++++++++ .../UnityProjectTemplate/Assets/Parse.meta | 9 ++ .../Assets/Parse/Plugins.meta | 9 ++ .../Parse/Plugins/Unity.Compat.dll.meta | 23 ++++ .../Assets/Parse/Plugins/Unity.Tasks.dll.meta | 22 ++++ .../Assets/Parse/Plugins/dotNet45.meta | 9 ++ .../Plugins/dotNet45/Unity.Tasks.dll.meta | 23 ++++ 12 files changed, 325 insertions(+), 1 deletion(-) create mode 100644 Unity.Tasks.TypeForwards/Properties/AssemblyInfo.cs create mode 100644 Unity.Tasks.TypeForwards/Public/TaskTypeForwards.cs create mode 100644 Unity.Tasks.TypeForwards/Unity.Tasks.TypeForwards.csproj create mode 100644 Unity.Tasks.UnityPlugin/Properties/AssemblyInfo.cs create mode 100644 Unity.Tasks.UnityPlugin/Unity.Tasks.UnityPlugin.csproj create mode 100644 Unity.Tasks.UnityPlugin/UnityProjectTemplate/Assets/Parse.meta create mode 100644 Unity.Tasks.UnityPlugin/UnityProjectTemplate/Assets/Parse/Plugins.meta create mode 100644 Unity.Tasks.UnityPlugin/UnityProjectTemplate/Assets/Parse/Plugins/Unity.Compat.dll.meta create mode 100644 Unity.Tasks.UnityPlugin/UnityProjectTemplate/Assets/Parse/Plugins/Unity.Tasks.dll.meta create mode 100644 Unity.Tasks.UnityPlugin/UnityProjectTemplate/Assets/Parse/Plugins/dotNet45.meta create mode 100644 Unity.Tasks.UnityPlugin/UnityProjectTemplate/Assets/Parse/Plugins/dotNet45/Unity.Tasks.dll.meta diff --git a/.gitignore b/.gitignore index b6177144..af0e05f0 100644 --- a/.gitignore +++ b/.gitignore @@ -108,4 +108,7 @@ Generated_Code #added for RIA/Silverlight projects # Visual Studio version. Backup files are not needed, because we have git ;-) _UpgradeReport_Files/ Backup*/ -UpgradeLog*.XML \ No newline at end of file +UpgradeLog*.XML + +# Include all files in Unity project templates. +!**/UnityProjectTemplate/** diff --git a/Unity.Tasks.TypeForwards/Properties/AssemblyInfo.cs b/Unity.Tasks.TypeForwards/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..1994cc02 --- /dev/null +++ b/Unity.Tasks.TypeForwards/Properties/AssemblyInfo.cs @@ -0,0 +1,19 @@ +// Copyright (c) 2015-present, Parse, LLC. All rights reserved. This source code is licensed under the BSD-style license found in the LICENSE file in the root directory of this source tree. An additional grant of patent rights can be found in the PATENTS file in the same directory. + +using System; +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Parse")] +[assembly: AssemblyDescription("Makes accessing services from Parse native and straightforward.")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Parse")] +[assembly: AssemblyCopyright("Copyright © Parse 2012")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: ComVisible(true)] \ No newline at end of file diff --git a/Unity.Tasks.TypeForwards/Public/TaskTypeForwards.cs b/Unity.Tasks.TypeForwards/Public/TaskTypeForwards.cs new file mode 100644 index 00000000..3a31fcff --- /dev/null +++ b/Unity.Tasks.TypeForwards/Public/TaskTypeForwards.cs @@ -0,0 +1,14 @@ +using System.Runtime.CompilerServices; + +[assembly: TypeForwardedToAttribute(typeof(System.AggregateException))] +[assembly: TypeForwardedToAttribute(typeof(System.Threading.CancellationToken))] +[assembly: TypeForwardedToAttribute(typeof(System.Threading.CancellationTokenRegistration))] +[assembly: TypeForwardedToAttribute(typeof(System.Threading.CancellationTokenSource))] +[assembly: TypeForwardedToAttribute(typeof(System.Threading.Tasks.Task))] +[assembly: TypeForwardedToAttribute(typeof(System.Threading.Tasks.Task<>))] +[assembly: TypeForwardedToAttribute(typeof(System.Threading.Tasks.TaskCompletionSource<>))] +[assembly: TypeForwardedToAttribute(typeof(System.Threading.Tasks.TaskContinuationOptions))] +[assembly: TypeForwardedToAttribute(typeof(System.Threading.Tasks.TaskCreationOptions))] +[assembly: TypeForwardedToAttribute(typeof(System.Threading.Tasks.TaskExtensions))] +[assembly: TypeForwardedToAttribute(typeof(System.Threading.Tasks.TaskFactory))] +[assembly: TypeForwardedToAttribute(typeof(System.Threading.Tasks.TaskScheduler))] diff --git a/Unity.Tasks.TypeForwards/Unity.Tasks.TypeForwards.csproj b/Unity.Tasks.TypeForwards/Unity.Tasks.TypeForwards.csproj new file mode 100644 index 00000000..e44de169 --- /dev/null +++ b/Unity.Tasks.TypeForwards/Unity.Tasks.TypeForwards.csproj @@ -0,0 +1,59 @@ + + + + + Debug + AnyCPU + {F4A424D3-1BBF-4F29-BE8E-D1336505987E} + Library + Properties + Unity.Tasks + Unity.Tasks + v4.5 + 512 + + + ..\ + true + 10.0.0 + 2.0 + + + true + full + false + bin\Debug\Unity\ + TRACE;DEBUG;UNITY + prompt + 4 + 5 + + + pdbonly + true + bin\Release\Unity\ + TRACE;UNITY + prompt + 4 + 5 + bin\Release\Unity\Unity.Tasks.xml + + + + + + + + + + + + + + diff --git a/Unity.Tasks.UnityPlugin/Properties/AssemblyInfo.cs b/Unity.Tasks.UnityPlugin/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..1994cc02 --- /dev/null +++ b/Unity.Tasks.UnityPlugin/Properties/AssemblyInfo.cs @@ -0,0 +1,19 @@ +// Copyright (c) 2015-present, Parse, LLC. All rights reserved. This source code is licensed under the BSD-style license found in the LICENSE file in the root directory of this source tree. An additional grant of patent rights can be found in the PATENTS file in the same directory. + +using System; +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Parse")] +[assembly: AssemblyDescription("Makes accessing services from Parse native and straightforward.")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Parse")] +[assembly: AssemblyCopyright("Copyright © Parse 2012")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: ComVisible(true)] \ No newline at end of file diff --git a/Unity.Tasks.UnityPlugin/Unity.Tasks.UnityPlugin.csproj b/Unity.Tasks.UnityPlugin/Unity.Tasks.UnityPlugin.csproj new file mode 100644 index 00000000..694d5cca --- /dev/null +++ b/Unity.Tasks.UnityPlugin/Unity.Tasks.UnityPlugin.csproj @@ -0,0 +1,115 @@ + + + + + Debug + AnyCPU + {2B36560F-64B5-4CEE-9F85-ED8A4FA64A1B} + Library + Properties + Unity.Tasks + Unity.Tasks.UnityPlugin + v3.5 + 512 + + + ..\ + true + 10.0.0 + 2.0 + + + true + full + false + bin\Debug\Unity\ + TRACE;DEBUG;UNITY + prompt + 4 + 5 + + + pdbonly + true + bin\Release\Unity\ + TRACE;UNITY + prompt + 4 + 5 + bin\Release\Unity\Unity.Tasks.xml + + + + + + False + ..\UnityEngine.dll + False + + + + + + + + + + + {CE75C800-A97F-4464-9A8B-3F65258456BF} + Unity.Tasks + + + + + {F4A424D3-1BBF-4F29-BE8E-D1336505987E} + Unity.Tasks.TypeForwards + + + + UnityProjectTemplate + $(IntermediateOutputPath)\UnityProject + $(ProgramFiles)\Unity\Editor\Unity.exe + /Applications/Unity/Unity.app/Contents/MacOS/Unity + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Unity.Tasks.UnityPlugin/UnityProjectTemplate/Assets/Parse.meta b/Unity.Tasks.UnityPlugin/UnityProjectTemplate/Assets/Parse.meta new file mode 100644 index 00000000..7148e219 --- /dev/null +++ b/Unity.Tasks.UnityPlugin/UnityProjectTemplate/Assets/Parse.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 1199e2794125469e8a23856b0799dd41 +folderAsset: yes +timeCreated: 1500423342 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity.Tasks.UnityPlugin/UnityProjectTemplate/Assets/Parse/Plugins.meta b/Unity.Tasks.UnityPlugin/UnityProjectTemplate/Assets/Parse/Plugins.meta new file mode 100644 index 00000000..9ff18d51 --- /dev/null +++ b/Unity.Tasks.UnityPlugin/UnityProjectTemplate/Assets/Parse/Plugins.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 29090946a760432f873fd7e78b773dd7 +folderAsset: yes +timeCreated: 1500423342 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity.Tasks.UnityPlugin/UnityProjectTemplate/Assets/Parse/Plugins/Unity.Compat.dll.meta b/Unity.Tasks.UnityPlugin/UnityProjectTemplate/Assets/Parse/Plugins/Unity.Compat.dll.meta new file mode 100644 index 00000000..2d4a678e --- /dev/null +++ b/Unity.Tasks.UnityPlugin/UnityProjectTemplate/Assets/Parse/Plugins/Unity.Compat.dll.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: 015ef18e20f24535830f59eda9e70830 +labels: +- gvh +- gvh_dotnet-3.5 +timeCreated: 1500423342 +licenseType: Pro +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Any: + enabled: 1 + settings: {} + Editor: + enabled: 1 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity.Tasks.UnityPlugin/UnityProjectTemplate/Assets/Parse/Plugins/Unity.Tasks.dll.meta b/Unity.Tasks.UnityPlugin/UnityProjectTemplate/Assets/Parse/Plugins/Unity.Tasks.dll.meta new file mode 100644 index 00000000..5e1e1090 --- /dev/null +++ b/Unity.Tasks.UnityPlugin/UnityProjectTemplate/Assets/Parse/Plugins/Unity.Tasks.dll.meta @@ -0,0 +1,22 @@ +fileFormatVersion: 2 +guid: 93324a471a6d44bb8297d17d8b191e52 +labels: +- gvh +timeCreated: 1500423342 +licenseType: Pro +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Any: + enabled: 1 + settings: {} + Editor: + enabled: 1 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity.Tasks.UnityPlugin/UnityProjectTemplate/Assets/Parse/Plugins/dotNet45.meta b/Unity.Tasks.UnityPlugin/UnityProjectTemplate/Assets/Parse/Plugins/dotNet45.meta new file mode 100644 index 00000000..70199db2 --- /dev/null +++ b/Unity.Tasks.UnityPlugin/UnityProjectTemplate/Assets/Parse/Plugins/dotNet45.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 9b73100528004036bb54eac84b0d0992 +folderAsset: yes +timeCreated: 1500423342 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity.Tasks.UnityPlugin/UnityProjectTemplate/Assets/Parse/Plugins/dotNet45/Unity.Tasks.dll.meta b/Unity.Tasks.UnityPlugin/UnityProjectTemplate/Assets/Parse/Plugins/dotNet45/Unity.Tasks.dll.meta new file mode 100644 index 00000000..b5a669cd --- /dev/null +++ b/Unity.Tasks.UnityPlugin/UnityProjectTemplate/Assets/Parse/Plugins/dotNet45/Unity.Tasks.dll.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: bd18eee30834e4f71bded96fd14033a9 +labels: +- gvh +- gvh_dotnet-4.5 +timeCreated: 1500423342 +licenseType: Pro +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: