com.unity.ide.visualstudio@2.0.8

## [2.0.8] - 2021-04-09

Project generation:

Improved generation performance (especially with DOTS enabled projects).
Improved stability.
Updated Analyzers lookup strategy.
Fixed .vsconfig file not generated when using "regenerate all".

Integration

Improved automation plugins.

Documentation

Open sourced automation plugins.
This commit is contained in:
Unity Technologies
2021-04-09 00:00:00 +00:00
parent 8cbbe811d0
commit 06b02acf9c
22 changed files with 9125 additions and 87 deletions

View File

@@ -4,7 +4,6 @@
*--------------------------------------------------------------------------------------------*/
using System;
using System.IO;
using System.Linq;
using Microsoft.Win32;
using Unity.CodeEditor;
using IOPath = System.IO.Path;
@@ -78,7 +77,7 @@ namespace Microsoft.Unity.VisualStudio.Editor
if (versions != null)
{
foreach(var entry in versions)
foreach (var entry in versions)
{
if (Version >= entry.IdeVersion)
return entry.LanguageVersion;
@@ -86,7 +85,7 @@ namespace Microsoft.Unity.VisualStudio.Editor
}
// default to 7.0 given we support at least VS 2017
return new Version(7,0);
return new Version(7, 0);
}
}
@@ -105,31 +104,37 @@ namespace Microsoft.Unity.VisualStudio.Editor
}
}
private string GetWindowsBridgeFromRegistry()
{
var keyName = $"Software\\Microsoft\\Microsoft Visual Studio {Version.Major}.0 Tools for Unity";
const string valueName = "UnityExtensionPath";
var bridge = ReadRegistry(Registry.CurrentUser, keyName, valueName);
if (string.IsNullOrEmpty(bridge))
bridge = ReadRegistry(Registry.LocalMachine, keyName, valueName);
return bridge;
}
// We only use this to find analyzers, we do not need to load this assembly anymore
private string GetBridgeLocation()
private string GetExtensionPath()
{
if (VisualStudioEditor.IsWindows)
{
// Registry, using legacy bridge location
var keyName = $"Software\\Microsoft\\Microsoft Visual Studio {Version.Major}.0 Tools for Unity";
const string valueName = "UnityExtensionPath";
const string extensionName = "Visual Studio Tools for Unity";
const string extensionAssembly = "SyntaxTree.VisualStudio.Unity.dll";
var bridge = ReadRegistry(Registry.CurrentUser, keyName, valueName);
if (string.IsNullOrEmpty(bridge))
bridge = ReadRegistry(Registry.LocalMachine, keyName, valueName);
var vsDirectory = IOPath.GetDirectoryName(Path);
var vstuDirectory = IOPath.Combine(vsDirectory, "Extensions", "Microsoft", extensionName);
return bridge;
if (File.Exists(IOPath.Combine(vstuDirectory, extensionAssembly)))
return vstuDirectory;
}
if (VisualStudioEditor.IsOSX)
{
// Environment, useful when developing UnityVS for Mac
var bridge = Environment.GetEnvironmentVariable("VSTUM_BRIDGE");
if (!string.IsNullOrEmpty(bridge) && File.Exists(bridge))
return bridge;
const string addinBridge = "Editor/SyntaxTree.VisualStudio.Unity.Bridge.dll";
const string addinName = "MonoDevelop.Unity";
const string addinAssembly = addinName + ".dll";
// user addins repository
var localAddins = IOPath.Combine(
@@ -138,38 +143,54 @@ namespace Microsoft.Unity.VisualStudio.Editor
// In the user addins repository, the addins are suffixed by their versions, like `MonoDevelop.Unity.1.0`
// When installing another local user addin, MD will remove files inside the folder
// So we browse all VSTUM addins, and return the one with a bridge, which is the one MD will load
// So we browse all VSTUM addins, and return the one with an addin assembly
if (Directory.Exists(localAddins))
{
foreach (var folder in Directory.GetDirectories(localAddins, addinName + "*", SearchOption.TopDirectoryOnly))
{
bridge = IOPath.Combine(folder, addinBridge);
if (File.Exists(bridge))
return bridge;
if (File.Exists(IOPath.Combine(folder, addinAssembly)))
return folder;
}
}
// Check in Visual Studio.app/
// In that case the name of the addin is used
bridge = IOPath.Combine(Path, $"Contents/Resources/lib/monodevelop/AddIns/{addinName}/{addinBridge}");
if (File.Exists(bridge))
return bridge;
var addinPath = IOPath.Combine(Path, $"Contents/Resources/lib/monodevelop/AddIns/{addinName}");
if (File.Exists(IOPath.Combine(addinPath, addinAssembly)))
return addinPath;
}
return null;
}
private static string[] GetAnalyzers(string path)
{
var analyzersDirectory = IOPath.GetFullPath(IOPath.Combine(path, "Analyzers"));
if (Directory.Exists(analyzersDirectory))
return Directory.GetFiles(analyzersDirectory, "*Analyzers.dll", SearchOption.AllDirectories);
return Array.Empty<string>();
}
public string[] GetAnalyzers()
{
var bridge = GetBridgeLocation();
var vstuPath = GetExtensionPath();
if (string.IsNullOrEmpty(vstuPath))
return Array.Empty<string>();
if (!string.IsNullOrEmpty(bridge))
if (VisualStudioEditor.IsOSX)
return GetAnalyzers(vstuPath);
if (VisualStudioEditor.IsWindows)
{
var baseLocation = IOPath.Combine(IOPath.GetDirectoryName(bridge), "..");
var analyzerLocation = IOPath.GetFullPath(IOPath.Combine(baseLocation, "Analyzers"));
var analyzers = GetAnalyzers(vstuPath);
if (analyzers?.Length > 0)
return analyzers;
if (Directory.Exists(analyzerLocation))
return Directory.GetFiles(analyzerLocation, "*Analyzers.dll", SearchOption.AllDirectories);
var bridge = GetWindowsBridgeFromRegistry();
if (File.Exists(bridge))
return GetAnalyzers(IOPath.Combine(IOPath.GetDirectoryName(bridge), ".."));
}
// Local assets