Skip to content

Commit

Permalink
0.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
frarees committed Jan 28, 2022
1 parent 24512cb commit 5636f70
Show file tree
Hide file tree
Showing 14 changed files with 194 additions and 134 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Changelog

## [0.8.0] - 2022-01-28

### Added
- Matching compiler version up to Unity 2022.1 (C# 9.0).

### Changed
- Updated Roslyn analyzers to [1.12.0](https://github.com/microsoft/Microsoft.Unity.Analyzers/releases/tag/1.12.0).

### Removed
- Postprocessor class (.csproj postprocessor).

### ProjectGenerator (matching [1.2.4](https://github.com/Unity-Technologies/com.unity.ide.vscode/tree/1.2.4/Packages/com.unity.ide.vscode/Editor/ProjectGeneration))
- Allow for per assembly roslyn analyzers
- Optimize package info look up performance. Reducing project generation time
- Use absolute path for Roslyn analyzers
- Always sync on asset updates

## [0.7.0] - 2021-04-01

### Added
Expand Down Expand Up @@ -119,6 +136,8 @@
- Support for MacVim on macOS.
- Support for Sublime Text 3 on macOS.

[0.8.0]: https://github.com/frarees/easyeditor/compare/v0.7.0...v0.8.0
[0.7.0]: https://github.com/frarees/easyeditor/compare/v0.6.1...v0.7.0
[0.6.1]: https://github.com/frarees/easyeditor/compare/v0.6.0...v0.6.1
[0.6.0]: https://github.com/frarees/easyeditor/compare/v0.5.1...v0.6.0
[0.5.1]: https://github.com/frarees/easyeditor/compare/v0.5.0...v0.5.1
Expand Down
Binary file modified Editor/Analyzers/Microsoft.Unity.Analyzers.dll
Binary file not shown.
2 changes: 0 additions & 2 deletions Editor/Discovery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,11 @@ public bool ExportFrameworkPathOverride
set => EditorPrefs.SetBool($"EasyEditor.{name}.ExportFrameworkPathOverride", value && !requiresNativeOpen && inheritsEnvironmentVariables);
}

#if !UNITY_2020_2_OR_NEWER
public bool MatchCompilerVersion
{
get => EditorPrefs.GetBool($"EasyEditor.{name}.MatchCompilerVersion", true);
set => EditorPrefs.SetBool($"EasyEditor.{name}.MatchCompilerVersion", value);
}
#endif

public string Arguments
{
Expand Down
10 changes: 4 additions & 6 deletions Editor/ExternalCodeEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ private class Properties
public static readonly GUIContent generate = EditorGUIUtility.TrTextContent("Generate");
public static readonly GUIContent clear = EditorGUIUtility.TrTextContent("Clear", "Remove all .sln and .csproj files");
public static readonly GUIContent autoGenerate = EditorGUIUtility.TrTextContent("Generate solution and project files", "Forces .sln and .csproj files to be generated and kept in sync.");
#if !UNITY_2020_2_OR_NEWER
public static readonly GUIContent matchCompilerVersion = EditorGUIUtility.TrTextContent("Match compiler version", "When Unity creates or updates .csproj files, it defines LangVersion as 'latest'. This can create inconsistencies with other .NET platforms (e.g. OmniSharp), which could resolve 'latest' as a different version. By matching compiler version, 'latest' will get resolved as " + Preferences.GetLangVersion() + ". ");
#endif
public static readonly GUIContent exportFrameworkPathOverride = EditorGUIUtility.TrTextContent("Export FrameworkPathOverride", FrameworkResolver.LastAvailableFrameworkPath != null ? "When invoking the text editor, sets the environment variable FrameworkPathOverride to " + FrameworkResolver.LastAvailableFrameworkPath : string.Empty);

public static readonly GUIContent monoInstallationFinderFail = EditorGUIUtility.TrTextContent("Couldn't reflect MonoInstallationFinder members successfully.");
Expand Down Expand Up @@ -122,7 +120,7 @@ public void OnGUI()
EditorGUILayout.HelpBox(discovery.notes, MessageType.Info);
}

EditorGUILayout.BeginHorizontal();
_ = EditorGUILayout.BeginHorizontal();
EditorGUI.BeginChangeCheck();
string arguments = EditorGUILayout.TextField(Properties.arguments, discovery.Arguments);
if (EditorGUI.EndChangeCheck())
Expand All @@ -137,7 +135,7 @@ public void OnGUI()
}
EditorGUILayout.EndHorizontal();

EditorGUILayout.BeginHorizontal();
_ = EditorGUILayout.BeginHorizontal();

EditorGUI.BeginChangeCheck();
bool autoGenerate = EditorGUILayout.Toggle(Properties.autoGenerate, discovery.AutoGenerate);
Expand Down Expand Up @@ -179,7 +177,6 @@ public void OnGUI()

EditorGUILayout.EndHorizontal();

#if !UNITY_2020_2_OR_NEWER
EditorGUI.BeginChangeCheck();
bool matchCompilerVersion = EditorGUILayout.Toggle(Properties.matchCompilerVersion, discovery.MatchCompilerVersion);
if (EditorGUI.EndChangeCheck())
Expand All @@ -190,7 +187,6 @@ public void OnGUI()
generator.Sync();
}
}
#endif

EditorGUI.BeginDisabledGroup(!MonoInstallationFinder.IsValid || !discovery.inheritsEnvironmentVariables);

Expand Down Expand Up @@ -289,6 +285,7 @@ public void SyncAll()
{
if (discovery.AutoGenerate)
{
(generator.AssemblyNameProvider as IPackageInfoCache)?.ResetPackageInfoCache();
AssetDatabase.Refresh();
generator.Sync();
}
Expand All @@ -301,6 +298,7 @@ public void SyncIfNeeded(string[] addedFiles, string[] deletedFiles, string[] mo
{
if (discovery.AutoGenerate)
{
(generator.AssemblyNameProvider as IPackageInfoCache)?.ResetPackageInfoCache();
_ = generator.SyncIfNeeded(addedFiles.Union(deletedFiles).Union(movedFiles).Union(movedFromFiles).ToList(), importedFiles);
}
}
Expand Down
47 changes: 0 additions & 47 deletions Editor/Postprocessor.cs

This file was deleted.

8 changes: 6 additions & 2 deletions Editor/Preferences.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@ static Preferences()

public static bool IsActive => CodeEditor.CurrentEditor is ExternalCodeEditor;

#if !UNITY_2020_2_OR_NEWER
public static string GetLangVersion()
{
#if UNITY_2021_2_OR_NEWER
return "9.0";
#elif UNITY_2020_2_OR_NEWER
return "8.0";
#else
return "7.3";
}
#endif
}
}
}

46 changes: 44 additions & 2 deletions Editor/ProjectGeneration/AssemblyNameProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,15 @@ public interface IAssemblyNameProvider
void ToggleProjectGeneration(ProjectGenerationFlag preference);
}

internal class AssemblyNameProvider : IAssemblyNameProvider
internal interface IPackageInfoCache
{
void ResetPackageInfoCache();
}

internal class AssemblyNameProvider : IAssemblyNameProvider, IPackageInfoCache
{
private readonly Dictionary<string, UnityEditor.PackageManager.PackageInfo> m_PackageInfoCache = new Dictionary<string, UnityEditor.PackageManager.PackageInfo>();

ProjectGenerationFlag m_ProjectGenerationFlag = (ProjectGenerationFlag)EditorPrefs.GetInt("unity_project_generation_flag", 0);

public string[] ProjectSupportedExtensions => EditorSettings.projectGenerationUserExtensions;
Expand Down Expand Up @@ -54,9 +61,44 @@ public IEnumerable<string> GetAllAssetPaths()
return AssetDatabase.GetAllAssetPaths();
}

private static string ResolvePotentialParentPackageAssetPath(string assetPath)
{
const string packagesPrefix = "packages/";
if (!assetPath.StartsWith(packagesPrefix, StringComparison.OrdinalIgnoreCase))
{
return null;
}

var followupSeparator = assetPath.IndexOf('/', packagesPrefix.Length);
if (followupSeparator == -1)
{
return assetPath.ToLowerInvariant();
}

return assetPath.Substring(0, followupSeparator).ToLowerInvariant();
}

public void ResetPackageInfoCache()
{
m_PackageInfoCache.Clear();
}

public UnityEditor.PackageManager.PackageInfo FindForAssetPath(string assetPath)
{
return UnityEditor.PackageManager.PackageInfo.FindForAssetPath(assetPath);
var parentPackageAssetPath = ResolvePotentialParentPackageAssetPath(assetPath);
if (parentPackageAssetPath == null)
{
return null;
}

if (m_PackageInfoCache.TryGetValue(parentPackageAssetPath, out var cachedPackageInfo))
{
return cachedPackageInfo;
}

var result = UnityEditor.PackageManager.PackageInfo.FindForAssetPath(parentPackageAssetPath);
m_PackageInfoCache[parentPackageAssetPath] = result;
return result;
}

public ResponseFileData ParseResponseFile(string responseFilePath, string projectDirectory, string[] systemReferenceDirectories)
Expand Down
Loading

0 comments on commit 5636f70

Please sign in to comment.