Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit b67daee

Browse files
committed
Add support for 2018 4.6 profile
1 parent 47513a9 commit b67daee

File tree

12 files changed

+145
-63
lines changed

12 files changed

+145
-63
lines changed

GitHub.Unity.sln

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestWebServer", "src\tests\
3535
EndProject
3636
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnityTests", "src\UnityExtension\Assets\Editor\UnityTests\UnityTests.csproj", "{462CDBD4-0DDA-4854-1B13-CFDACBFB66F5}"
3737
EndProject
38+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExtensionLoader", "src\UnityExtension\Assets\Editor\GitHub.Unity\ExtensionLoader\ExtensionLoader.csproj", "{6B0EAB30-511A-44C1-87FE-D9AB7E34D115}"
39+
EndProject
3840
Global
3941
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4042
Debug|Any CPU = Debug|Any CPU
@@ -151,6 +153,14 @@ Global
151153
{462CDBD4-0DDA-4854-1B13-CFDACBFB66F5}.dev|Any CPU.Build.0 = Debug|Any CPU
152154
{462CDBD4-0DDA-4854-1B13-CFDACBFB66F5}.Release|Any CPU.ActiveCfg = Release|Any CPU
153155
{462CDBD4-0DDA-4854-1B13-CFDACBFB66F5}.Release|Any CPU.Build.0 = Release|Any CPU
156+
{6B0EAB30-511A-44C1-87FE-D9AB7E34D115}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
157+
{6B0EAB30-511A-44C1-87FE-D9AB7E34D115}.Debug|Any CPU.Build.0 = Debug|Any CPU
158+
{6B0EAB30-511A-44C1-87FE-D9AB7E34D115}.DebugNoUnity|Any CPU.ActiveCfg = Debug|Any CPU
159+
{6B0EAB30-511A-44C1-87FE-D9AB7E34D115}.DebugNoUnity|Any CPU.Build.0 = Debug|Any CPU
160+
{6B0EAB30-511A-44C1-87FE-D9AB7E34D115}.dev|Any CPU.ActiveCfg = dev|Any CPU
161+
{6B0EAB30-511A-44C1-87FE-D9AB7E34D115}.dev|Any CPU.Build.0 = dev|Any CPU
162+
{6B0EAB30-511A-44C1-87FE-D9AB7E34D115}.Release|Any CPU.ActiveCfg = Release|Any CPU
163+
{6B0EAB30-511A-44C1-87FE-D9AB7E34D115}.Release|Any CPU.Build.0 = Release|Any CPU
154164
EndGlobalSection
155165
GlobalSection(SolutionProperties) = preSolution
156166
HideSolutionNode = FALSE
@@ -166,4 +176,7 @@ Global
166176
{3DD3451C-30FA-4294-A3A9-1E080342F867} = {D17F1B4C-42DC-4E78-BCEF-9F239A084C4D}
167177
{462CDBD4-0DDA-4854-1B13-CFDACBFB66F5} = {D17F1B4C-42DC-4E78-BCEF-9F239A084C4D}
168178
EndGlobalSection
179+
GlobalSection(ExtensibilityGlobals) = postSolution
180+
SolutionGuid = {66BD4D50-3779-4912-9596-2C838BF24911}
181+
EndGlobalSection
169182
EndGlobal

common/packaging.targets

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
</PropertyGroup>
88

99
<!-- After the build is done, we copy all the artifacts into two locations:
10-
..\github-unity-test\GitHubExtensionProject - an empty unity project for testing
11-
unity\PackageProject - the project we use for packaging
10+
1) ..\github-unity-test\GitHubExtensionProject - an empty unity project for testing
11+
2) unity\PackageProject - the project we use for packaging
12+
and then we copy the meta files from the unity\PackageProject to github-unity-test
1213
-->
1314
<Target Name="AfterBuild">
1415

@@ -25,13 +26,13 @@
2526
Condition="!$([System.String]::Copy('%(Filename)').Contains('deleteme')) and !$([System.String]::Copy('%(Extension)').Contains('xml')) and !$([System.String]::Copy('%(Extension)').Contains('pdb')) and !$([System.String]::Copy('%(Extension)').Contains('dll.mdb'))" />
2627

2728
<CreateItem Include="$(PublishTo)\**\*.*">
28-
<Output TaskParameter="Include" ItemName="ToMoreCopy" />
29+
<Output TaskParameter="Include" ItemName="PackageFilesToCopy" />
2930
</CreateItem>
3031

31-
<!-- Copy all the DLLs to the ..\github-unity-test folder, creating an empty Unity project with the extension ready for testing -->
32+
<!-- Copy all the DLLs and meta files to the ..\github-unity-test folder, creating an empty Unity project with the extension ready for testing -->
3233
<Copy
33-
SourceFiles="@(ToMoreCopy)"
34-
DestinationFiles="@(ToMoreCopy->'$(ExternalPublishTo)\%(RecursiveDir)%(Filename)%(Extension)')"
34+
SourceFiles="@(PackageFilesToCopy)"
35+
DestinationFiles="@(PackageFilesToCopy->'$(ExternalPublishTo)\%(RecursiveDir)%(Filename)%(Extension)')"
3536
Retries="0"
3637
ContinueOnError="WarnAndContinue" />
3738

src/GitHub.Api/GitHub.Api.45.csproj

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
44
<PropertyGroup>
@@ -15,14 +15,14 @@
1515
<LangVersion>6</LangVersion>
1616
<NuGetPackageImportStamp>
1717
</NuGetPackageImportStamp>
18-
<OutputPath>..\UnityExtension\Assets\Editor\build</OutputPath>
18+
<OutputPath>..\UnityExtension\Assets\Editor\build\</OutputPath>
1919
</PropertyGroup>
2020
<Import Project="..\..\common\properties.props" />
2121
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2222
<DebugSymbols>true</DebugSymbols>
2323
<DebugType>full</DebugType>
2424
<Optimize>false</Optimize>
25-
<DefineConstants>DEBUG;TRACE;$(BuildDefs)</DefineConstants>
25+
<DefineConstants>DEBUG;TRACE;$(BuildDefs);NET_4_6</DefineConstants>
2626
<ErrorReport>prompt</ErrorReport>
2727
<WarningLevel>4</WarningLevel>
2828
<RunCodeAnalysis>false</RunCodeAnalysis>
@@ -32,7 +32,7 @@
3232
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
3333
<DebugType>pdbonly</DebugType>
3434
<Optimize>true</Optimize>
35-
<DefineConstants>TRACE;$(BuildDefs)</DefineConstants>
35+
<DefineConstants>TRACE;$(BuildDefs);NET_4_6</DefineConstants>
3636
<ErrorReport>prompt</ErrorReport>
3737
<WarningLevel>4</WarningLevel>
3838
<BuildConfid>Release</BuildConfid>
@@ -44,7 +44,7 @@
4444
<DebugSymbols>true</DebugSymbols>
4545
<DebugType>full</DebugType>
4646
<Optimize>false</Optimize>
47-
<DefineConstants>TRACE;DEBUG;DEVELOPER_BUILD;$(BuildDefs)</DefineConstants>
47+
<DefineConstants>TRACE;DEBUG;DEVELOPER_BUILD;$(BuildDefs);NET_4_6</DefineConstants>
4848
<ErrorReport>prompt</ErrorReport>
4949
<WarningLevel>4</WarningLevel>
5050
<RunCodeAnalysis>false</RunCodeAnalysis>
@@ -264,15 +264,10 @@
264264
<EmbeddedResource Include="PlatformResources\mac\git-lfs.json" />
265265
<EmbeddedResource Include="PlatformResources\windows\git-lfs.json" />
266266
<EmbeddedResource Include="PlatformResources\windows\git.json" />
267-
<None Include="PlatformResources\linux\git-lfs.zip" />
268-
<None Include="PlatformResources\mac\git-lfs.zip" />
269-
<None Include="PlatformResources\windows\git-lfs.zip" />
270-
<None Include="PlatformResources\windows\git.zip" />
271267
<EmbeddedResource Include="Resources\octorun.zip" />
272268
<EmbeddedResource Include="Resources\octorun.zip.md5" />
273269
</ItemGroup>
274270
<ItemGroup>
275-
<None Include="packages.config" />
276271
<EmbeddedResource Include="Localization.resx">
277272
<Generator>PublicResXFileCodeGenerator</Generator>
278273
<LastGenOutput>Localization.Designer.cs</LastGenOutput>
@@ -285,24 +280,5 @@
285280
<Target Name="BeforeBuild">
286281
</Target>
287282
-->
288-
<Target Name="AfterBuild">
289-
<Copy
290-
SourceFiles="PlatformResources\linux\git-lfs.zip;PlatformResources\linux\git-lfs.json"
291-
DestinationFolder="$(SolutionDir)\src\UnityExtension\Assets\Editor\GitHub.Unity\PlatformResources\linux"
292-
SkipUnchangedFiles="true"
293-
/>
294-
295-
<Copy
296-
SourceFiles="PlatformResources\mac\git-lfs.zip;PlatformResources\mac\git-lfs.json"
297-
DestinationFolder="$(SolutionDir)\src\UnityExtension\Assets\Editor\GitHub.Unity\PlatformResources\mac"
298-
SkipUnchangedFiles="true"
299-
/>
300-
301-
<Copy
302-
SourceFiles="PlatformResources\windows\git.zip;PlatformResources\windows\git.json;PlatformResources\windows\git-lfs.zip;PlatformResources\windows\git-lfs.json"
303-
DestinationFolder="$(SolutionDir)\src\UnityExtension\Assets\Editor\GitHub.Unity\PlatformResources\windows"
304-
SkipUnchangedFiles="true"
305-
/>
306-
</Target>
307283
<Import Project="..\..\common\build.targets" />
308284
</Project>

src/GitHub.Api/Helpers/TaskHelpers.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@ static class TaskHelpers
88
{
99
public static Task<T> GetCompletedTask<T>(T result)
1010
{
11+
#if NET_4_6
12+
return Task.FromResult(result);
13+
#else
1114
return TaskEx.FromResult(result);
15+
#endif
1216
}
1317

1418
public static Task<T> ToTask<T>(this Exception exception)
1519
{
16-
TaskCompletionSource<T> completionSource = new TaskCompletionSource<T>();
17-
completionSource.TrySetException(exception);
18-
return completionSource.Task;
20+
TaskCompletionSource<T> completionSource = new TaskCompletionSource<T>();
21+
completionSource.TrySetException(exception);
22+
return completionSource.Task;
1923
}
2024
}
2125

src/GitHub.Api/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Runtime.InteropServices;
44

55
[assembly: AssemblyTitle("GitHub.Api")]
6-
[assembly: AssemblyDescription("GitHub Api")]
6+
[assembly: AssemblyDescription("GitHub for Unity API")]
77
[assembly: Guid("4B424108-D0E8-4BF9-9B0C-4FB49E532AB9")]
88
[assembly: InternalsVisibleTo("GitHub.Unity")]
9+
[assembly: InternalsVisibleTo("GitHub.Unity.45")]

src/GitHub.Logging/Extensions/ExceptionExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace GitHub.Logging
55
{
6-
static class ExceptionExtensions
6+
public static class ExceptionExtensions
77
{
88
public static string GetExceptionMessage(this Exception ex)
99
{

src/UnityExtension/Assets/Editor/GitHub.Unity/ExtensionLoader

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "ExtensionLoader",
3+
"references": [],
4+
"includePlatforms": [
5+
"Editor"
6+
],
7+
"excludePlatforms": []
8+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
using UnityEditor;
2+
using UnityEngine;
3+
using System.IO;
4+
using System;
5+
6+
namespace GitHub.Unity
7+
{
8+
[InitializeOnLoad]
9+
public class ExtensionLoader : ScriptableSingleton<ExtensionLoader>
10+
{
11+
[SerializeField] private bool initialized = true;
12+
13+
public bool Initialized
14+
{
15+
get
16+
{
17+
return initialized;
18+
}
19+
set
20+
{
21+
initialized = value;
22+
Save(true);
23+
}
24+
}
25+
26+
private static bool inSourceMode = false;
27+
private const string sourceModePath = "Assets/Editor/build/";
28+
private const string realPath = "Assets/Plugins/GitHub/Editor/";
29+
30+
private static string[] assemblies20 = { "System.Threading.dll", "AsyncBridge.Net35.dll", "ReadOnlyCollectionsInterfaces.dll", "GitHub.Api.dll", "GitHub.Unity.dll" };
31+
private static string[] assemblies45 = { "GitHub.Api.45.dll", "GitHub.Unity.45.dll" };
32+
33+
static ExtensionLoader()
34+
{
35+
EditorApplication.update += Initialize;
36+
}
37+
38+
private static void Initialize()
39+
{
40+
EditorApplication.update -= Initialize;
41+
//if (!ExtensionLoader.instance.Initialized)
42+
{
43+
var scriptPath = Path.Combine(Application.dataPath, "Editor" + Path.DirectorySeparatorChar + "GitHub.Unity" + Path.DirectorySeparatorChar + "EntryPoint.cs");
44+
inSourceMode = File.Exists(scriptPath);
45+
ToggleAssemblies();
46+
//ExtensionLoader.instance.Initialized = true;
47+
}
48+
49+
}
50+
51+
private static void ToggleAssemblies()
52+
{
53+
var path = inSourceMode ? sourceModePath : realPath;
54+
#if NET_4_6
55+
ToggleAssemblies(path, assemblies20, false);
56+
ToggleAssemblies(path, assemblies45, true);
57+
#else
58+
ToggleAssemblies(path, assemblies45, false);
59+
ToggleAssemblies(path, assemblies20, true);
60+
#endif
61+
}
62+
63+
private static void ToggleAssemblies(string path, string[] assemblies, bool enable)
64+
{
65+
foreach (var file in assemblies)
66+
{
67+
var filepath = path + file;
68+
PluginImporter importer = AssetImporter.GetAtPath(filepath) as PluginImporter;
69+
if (importer == null)
70+
{
71+
Debug.LogFormat("GitHub for Unity: Could not find importer for {0}. Some functionality may fail.", filepath);
72+
continue;
73+
}
74+
if (importer.GetCompatibleWithEditor() != enable)
75+
{
76+
importer.SetCompatibleWithEditor(enable);
77+
importer.SaveAndReimport();
78+
}
79+
}
80+
}
81+
}
82+
}

src/UnityExtension/Assets/Editor/GitHub.Unity/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
using System.Runtime.CompilerServices;
33
using System.Runtime.InteropServices;
44

5-
[assembly: AssemblyTitle("GitHub.Api")]
6-
[assembly: AssemblyDescription("GitHub Api")]
5+
[assembly: AssemblyTitle("GitHub.Unity")]
6+
[assembly: AssemblyDescription("GitHub for Unity")]
77
[assembly: Guid("add7a18b-dd2a-4c22-a2c1-488964eff30a")]

0 commit comments

Comments
 (0)