-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## [2.0.9] - 2021-05-04 Project generation: Added support for CLI. Integration: Improved performance when discovering Visual Studio installations. Warn when legacy assemblies are present in the project. Warn when the package version is not up-to-date.
- Loading branch information
Unity Technologies
committed
May 4, 2021
1 parent
06b02ac
commit b0f2251
Showing
14 changed files
with
346 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Unity Technologies. | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
using System; | ||
using System.Threading; | ||
|
||
namespace Microsoft.Unity.VisualStudio.Editor | ||
{ | ||
internal class AsyncOperation<T> | ||
{ | ||
private readonly Func<T> _producer; | ||
private readonly ManualResetEventSlim _resetEvent; | ||
|
||
private T _result; | ||
private Exception _exception; | ||
|
||
private AsyncOperation(Func<T> producer) | ||
{ | ||
_producer = producer; | ||
_resetEvent = new ManualResetEventSlim(initialState: false); | ||
} | ||
|
||
public static AsyncOperation<T> Run(Func<T> producer) | ||
{ | ||
var task = new AsyncOperation<T>(producer); | ||
task.Run(); | ||
return task; | ||
} | ||
|
||
private void Run() | ||
{ | ||
ThreadPool.QueueUserWorkItem(_ => | ||
{ | ||
try | ||
{ | ||
_result = _producer(); | ||
} | ||
catch (Exception e) | ||
{ | ||
_exception = e; | ||
} | ||
finally | ||
{ | ||
_resetEvent.Set(); | ||
} | ||
}); | ||
} | ||
|
||
private void CheckCompletion() | ||
{ | ||
if (!_resetEvent.IsSet) | ||
_resetEvent.Wait(); | ||
} | ||
|
||
|
||
public T Result | ||
{ | ||
get | ||
{ | ||
CheckCompletion(); | ||
return _result; | ||
} | ||
} | ||
|
||
public Exception Exception | ||
{ | ||
get | ||
{ | ||
CheckCompletion(); | ||
return _exception; | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
using System; | ||
using System.Linq; | ||
using Unity.CodeEditor; | ||
|
||
namespace Microsoft.Unity.VisualStudio.Editor | ||
{ | ||
internal static class Cli | ||
{ | ||
internal static void Log(string message) | ||
{ | ||
// Use writeline here, instead of UnityEngine.Debug.Log to not include the stacktrace in the editor.log | ||
Console.WriteLine($"[VisualStudio.Editor.{nameof(Cli)}] {message}"); | ||
} | ||
|
||
internal static string GetInstallationDetails(IVisualStudioInstallation installation) | ||
{ | ||
return $"{installation.ToCodeEditorInstallation().Name} Path:{installation.Path}, LanguageVersionSupport:{installation.LatestLanguageVersionSupported} AnalyzersSupport:{installation.SupportsAnalyzers}"; | ||
} | ||
|
||
internal static void GenerateSolutionWith(VisualStudioEditor vse, string installationPath) | ||
{ | ||
if (vse != null && vse.TryGetVisualStudioInstallationForPath(installationPath, searchInstallations: true, out var vsi)) | ||
{ | ||
Log($"Using {GetInstallationDetails(vsi)}"); | ||
vse.SyncAll(); | ||
} | ||
else | ||
{ | ||
Log($"No Visual Studio installation found in ${installationPath}!"); | ||
} | ||
} | ||
|
||
internal static void GenerateSolution() | ||
{ | ||
if (CodeEditor.CurrentEditor is VisualStudioEditor vse) | ||
{ | ||
Log($"Using default editor settings for Visual Studio installation"); | ||
GenerateSolutionWith(vse, CodeEditor.CurrentEditorInstallation); | ||
} | ||
else | ||
{ | ||
Log($"Visual Studio is not set as your default editor, looking for installations"); | ||
try | ||
{ | ||
var installations = Discovery | ||
.GetVisualStudioInstallations() | ||
.Cast<VisualStudioInstallation>() | ||
.OrderByDescending(vsi => !vsi.IsPrerelease) | ||
.ThenBy(vsi => vsi.Version) | ||
.ToArray(); | ||
|
||
foreach(var vsi in installations) | ||
{ | ||
Log($"Detected {GetInstallationDetails(vsi)}"); | ||
} | ||
|
||
var installation = installations | ||
.FirstOrDefault(); | ||
|
||
if (installation != null) | ||
{ | ||
var current = CodeEditor.CurrentEditorInstallation; | ||
try | ||
{ | ||
CodeEditor.SetExternalScriptEditor(installation.Path); | ||
GenerateSolutionWith(CodeEditor.CurrentEditor as VisualStudioEditor, installation.Path); | ||
} | ||
finally | ||
{ | ||
CodeEditor.SetExternalScriptEditor(current); | ||
} | ||
} else | ||
{ | ||
Log($"No Visual Studio installation found!"); | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
Log($"Error detecting Visual Studio installations: {ex}"); | ||
} | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
namespace Microsoft.Unity.VisualStudio.Editor | ||
{ | ||
internal static class KnownAssemblies | ||
{ | ||
public const string Bridge = "SyntaxTree.VisualStudio.Unity.Bridge"; | ||
public const string Messaging = "SyntaxTree.VisualStudio.Unity.Messaging"; | ||
public const string UnityVS = "UnityVS.VersionSpecific"; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+96.1 KB
(280%)
Editor/Plugins/AppleEventIntegration.bundle/Contents/MacOS/AppleEventIntegration
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.