Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [2.0.11] - 2021-07-01

Integration:

- Added support for Visual Studio and Visual Studio For Mac 2022.
- Fixed an issue when the package was enabled for background processes.

Project generation:

- Use absolute paths for Analyzers and rulesets.

## [2.0.10] - 2021-06-10

Project generation:

- Improved project generation performance when a file is moved, deleted or modified.

Integration:

- Improved Inner-loop performance by avoiding to call the package manager when looking up `vswhere` utility.
- Fixed a network issue preventing the communication between Visual Studio and Unity on Windows.
  • Loading branch information
Unity Technologies committed Jul 1, 2021
1 parent b0f2251 commit f6444c6
Show file tree
Hide file tree
Showing 22 changed files with 421 additions and 267 deletions.
32 changes: 27 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,39 @@
# Code Editor Package for Visual Studio

## [2.0.9] - 2021-05-04
## [2.0.11] - 2021-07-01

Integration:

- Added support for Visual Studio and Visual Studio For Mac 2022.
- Fixed an issue when the package was enabled for background processes.

Project generation:

- Use absolute paths for Analyzers and rulesets.


## [2.0.10] - 2021-06-10

Project generation:

Added support for CLI.
- Improved project generation performance when a file is moved, deleted or modified.

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.
- Improved Inner-loop performance by avoiding to call the package manager when looking up `vswhere` utility.
- Fixed a network issue preventing the communication between Visual Studio and Unity on Windows.

## [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.

## [2.0.8] - 2021-04-09

Expand Down
7 changes: 1 addition & 6 deletions Editor/AppleEventIntegration~/AppleEventIntegration/main.mm
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,7 @@ static BOOL ApplicationSupportsQueryOpenedSolution(NSString* appPath)
return NO;

NSString* version = (NSString*)versionValue;
NSArray* components = [version componentsSeparatedByString:@"."];
if (!components || components.count < 2)
return NO;

return [components[0] integerValue] >= 8
&& [components[1] integerValue] >= 6;
return [version compare:@"8.6" options:NSNumericSearch] != NSOrderedAscending;
}

static NSArray<NSRunningApplication*>* QueryRunningInstances(NSString *appPath)
Expand Down
11 changes: 7 additions & 4 deletions Editor/Discovery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ internal static class Discovery

public static void FindVSWhere()
{
_vsWherePath = FileUtility
.FindPackageAssetFullPath("VSWhere a:packages", "vswhere.exe")
.FirstOrDefault();
_vsWherePath = FileUtility.GetPackageAssetFullPath("Editor", "VSWhere", "vswhere.exe");
}

public static IEnumerable<IVisualStudioInstallation> GetVisualStudioInstallations()
Expand Down Expand Up @@ -71,7 +69,12 @@ public static bool TryDiscoverInstallation(string editorPath, out IVisualStudioI

// On Mac we use the .app folder, so we need to access to main assembly
if (VisualStudioEditor.IsOSX)
fvi = Path.Combine(editorPath, "Contents", "Resources", "lib", "monodevelop", "bin", "VisualStudio.exe");
{
fvi = Path.Combine(editorPath, "Contents/Resources/lib/monodevelop/bin/VisualStudio.exe");

if (!File.Exists(fvi))
fvi = Path.Combine(editorPath, "Contents/MonoBundle/VisualStudio.exe");
}

if (!File.Exists(fvi))
return false;
Expand Down
29 changes: 12 additions & 17 deletions Editor/FileUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
*--------------------------------------------------------------------------------------------*/
using System;
using System.IO;
using System.Linq;
using UnityEditor;
using UnityEngine;

namespace Microsoft.Unity.VisualStudio.Editor
Expand All @@ -16,27 +14,19 @@ internal static class FileUtility
public const char WinSeparator = '\\';
public const char UnixSeparator = '/';

// Safe for packages as we use packageInfo.resolvedPath, so this should work in library package cache as well
public static string[] FindPackageAssetFullPath(string assetfilter, string filefilter)
public static string GetPackageAssetFullPath(params string[] components)
{
return AssetDatabase.FindAssets(assetfilter)
.Select(AssetDatabase.GUIDToAssetPath)
.Where(assetPath => assetPath.Contains(filefilter))
.Select(asset =>
{
var packageInfo = UnityEditor.PackageManager.PackageInfo.FindForAssetPath(asset);
return Normalize(packageInfo.resolvedPath + asset.Substring(packageInfo.assetPath.Length));
})
.ToArray();
// Unity has special IO handling of Packages and will resolve those path to the right package location
return Path.GetFullPath(Path.Combine("Packages", "com.unity.ide.visualstudio", Path.Combine(components)));
}

public static string GetAssetFullPath(string asset)
{
var basePath = Path.GetFullPath(Path.Combine(Application.dataPath, ".."));
return Path.GetFullPath(Path.Combine(basePath, Normalize(asset)));
return Path.GetFullPath(Path.Combine(basePath, NormalizePathSeparators(asset)));
}

public static string Normalize(string path)
public static string NormalizePathSeparators(this string path)
{
if (string.IsNullOrEmpty(path))
return path;
Expand Down Expand Up @@ -65,12 +55,18 @@ internal static bool IsFileInProjectRootDirectory(string fileName)

return relative == Path.GetFileName(relative);
}

public static string MakeAbsolutePath(this string path, string projectDirectory)
{
if (string.IsNullOrEmpty(path)) { return string.Empty; }
return Path.IsPathRooted(path) ? path : Path.Combine(projectDirectory, path);
}

// returns null if outside of the project scope
internal static string MakeRelativeToProjectPath(string fileName)
{
var basePath = Path.GetFullPath(Path.Combine(Application.dataPath, ".."));
fileName = Normalize(fileName);
fileName = NormalizePathSeparators(fileName);

if (!Path.IsPathRooted(fileName))
fileName = Path.Combine(basePath, fileName);
Expand All @@ -82,6 +78,5 @@ internal static string MakeRelativeToProjectPath(string fileName)
.Substring(basePath.Length)
.Trim(Path.DirectorySeparatorChar);
}

}
}
24 changes: 21 additions & 3 deletions Editor/Messaging/Messenger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,31 @@ internal class Messager : IDisposable
private readonly object _disposeLock = new object();
private bool _disposed;

#if UNITY_EDITOR_WIN
[System.Runtime.InteropServices.DllImport("kernel32.dll", SetLastError = true)]
private static extern bool SetHandleInformation(IntPtr hObject, HandleFlags dwMask, HandleFlags dwFlags);

[Flags]
private enum HandleFlags: uint
{
None = 0,
Inherit = 1,
ProtectFromClose = 2
}
#endif

protected Messager(int port)
{
_socket = new UdpSocket();
_socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ExclusiveAddressUse, false);
_socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);

#if UNITY_EDITOR_WIN
// Explicitely disable inheritance for our UDP socket handle
// We found that Unity is creating a fork when importing new assets that can clone our socket
SetHandleInformation(_socket.Handle, HandleFlags.Inherit, HandleFlags.None);
#endif

_socket.Bind(IPAddress.Any, port);

BeginReceiveMessage();
Expand Down Expand Up @@ -72,9 +92,7 @@ private void ReceiveMessageCallback(IAsyncResult result)
{
message.Origin = (IPEndPoint)endPoint;

int port;
int bufferSize;
if (IsValidTcpMessage(message, out port, out bufferSize))
if (IsValidTcpMessage(message, out var port, out var bufferSize))
{
// switch to TCP mode to handle big messages
TcpClient.Queue(message.Origin.Address, port, bufferSize, buffer =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>19H1030</string>
<string>19H1217</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
Expand Down
Binary file not shown.
Loading

0 comments on commit f6444c6

Please sign in to comment.