4 Commits

Author SHA1 Message Date
copilot-swe-agent[bot]
8e1da25983 Add clarifying comment for Unity 2019.4 C# 7.3 compatibility
Co-authored-by: OmarAlFarajat <OmarAlFarajat@users.noreply.github.com>

Co-authored-by: boxqkrtm <8157743+boxqkrtm@users.noreply.github.com>
2026-02-12 10:03:40 +00:00
copilot-swe-agent[bot]
412c992de2 Fix CS1525 compiler error for Unity 2019.4 by replacing ??= with version-compatible code
Co-authored-by: boxqkrtm <8157743+boxqkrtm@users.noreply.github.com>
2026-02-12 09:57:19 +00:00
copilot-swe-agent[bot]
d8164f72bb Initial plan 2026-02-12 09:55:31 +00:00
goethe
a97262d3f7 performance optimize for opening file (#36) 2026-02-12 18:34:39 +09:00
2 changed files with 25 additions and 4 deletions

View File

@@ -584,7 +584,12 @@ namespace Microsoft.Unity.VisualStudio.Editor
var application = Path; var application = Path;
var workspace = TryFindWorkspace(directory); var workspace = TryFindWorkspace(directory);
// Use version-compatible null-coalescing for Unity 2019.4 (C# 7.3) support
#if UNITY_2020_2_OR_NEWER
workspace ??= directory; workspace ??= directory;
#else
workspace = workspace ?? directory;
#endif
directory = workspace; directory = workspace;
if (EditorPrefs.GetBool(ReuseExistingWindowKey, false)) if (EditorPrefs.GetBool(ReuseExistingWindowKey, false))

View File

@@ -44,8 +44,11 @@ namespace Microsoft.Unity.VisualStudio.Editor
[InitializeOnLoadMethod] [InitializeOnLoadMethod]
static void LegacyVisualStudioCodePackageDisabler() static void LegacyVisualStudioCodePackageDisabler()
{ {
// disable legacy Visual Studio Code packages #if UNITY_2021_1_OR_NEWER
var editor = CodeEditor.Editor.GetCodeEditorForPath("code.cmd"); var editor = CodeEditor.Editor.GetCodeEditorForPath("code.cmd");
#else
var editor = CodeEditor.CurrentEditor;
#endif
if (editor == null) if (editor == null)
return; return;
@@ -226,7 +229,9 @@ namespace Microsoft.Unity.VisualStudio.Editor
{ {
var editorPath = CodeEditor.CurrentEditorInstallation; var editorPath = CodeEditor.CurrentEditorInstallation;
if (!Discovery.TryDiscoverInstallation(editorPath, out var installation)) { // Performance optimization: Use cached installation lookup instead of discovering every time
if (!TryGetVisualStudioInstallationForPath(editorPath, lookupDiscoveredInstallations: true, out var installation))
{
Debug.LogWarning($"Visual Studio executable {editorPath} is not found. Please change your settings in Edit > Preferences > External Tools."); Debug.LogWarning($"Visual Studio executable {editorPath} is not found. Please change your settings in Edit > Preferences > External Tools.");
return false; return false;
} }
@@ -238,7 +243,8 @@ namespace Microsoft.Unity.VisualStudio.Editor
if (!IsProjectGeneratedFor(path, generator, out var missingFlag)) if (!IsProjectGeneratedFor(path, generator, out var missingFlag))
Debug.LogWarning($"You are trying to open {path} outside a generated project. This might cause problems with IntelliSense and debugging. To avoid this, you can change your .csproj preferences in Edit > Preferences > External Tools and enable {GetProjectGenerationFlagDescription(missingFlag)} generation."); Debug.LogWarning($"You are trying to open {path} outside a generated project. This might cause problems with IntelliSense and debugging. To avoid this, you can change your .csproj preferences in Edit > Preferences > External Tools and enable {GetProjectGenerationFlagDescription(missingFlag)} generation.");
var solution = GetOrGenerateSolutionFile(generator); // Performance optimization: Only sync if solution doesn't exist
var solution = GetOrGenerateSolutionFileIfNeeded(generator);
return installation.Open(path, line, column, solution); return installation.Open(path, line, column, solution);
} }
@@ -307,5 +313,15 @@ namespace Microsoft.Unity.VisualStudio.Editor
generator.Sync(); generator.Sync();
return generator.SolutionFile(); return generator.SolutionFile();
} }
// Performance optimization: Only sync if solution file doesn't exist
private static string GetOrGenerateSolutionFileIfNeeded(IGenerator generator)
{
if (!generator.HasSolutionBeenGenerated())
{
generator.Sync();
}
return generator.SolutionFile();
}
} }
} }