Skip to content

Commit 24512cb

Browse files
committed
0.7.0
1 parent 1dbedb6 commit 24512cb

24 files changed

+1297
-145
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog
22

3+
## [0.7.0] - 2021-04-01
4+
5+
### Added
6+
- Ability to specify which projects get generated.
7+
- Workaround for RoslynAnalysisRunner issues.
8+
9+
### Changed
10+
- Fix registering editor on initial startup.
11+
- Fix opening files custom extension (set in EditorSettings.projectGenerationUserExtensions).
12+
313
## [0.6.1] - 2020-10-26
414

515
### Changed

Editor/Analyzers.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
149 KB
Binary file not shown.

Editor/Analyzers/Microsoft.Unity.Analyzers.dll.meta

Lines changed: 81 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Editor/EasyEditor.asmdef

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "EasyEditor",
3+
"rootNamespace": "",
34
"references": [
45
"GUID:734e6689aeb5b4d668aa7c78bcc0910f"
56
],

Editor/ExternalCodeEditor.cs

Lines changed: 59 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,36 +17,46 @@ private class Properties
1717
public static readonly GUIContent arguments = EditorGUIUtility.TrTextContent("Arguments");
1818
public static readonly GUIContent reset = EditorGUIUtility.TrTextContent("Reset");
1919
public static readonly GUIContent generate = EditorGUIUtility.TrTextContent("Generate");
20+
public static readonly GUIContent clear = EditorGUIUtility.TrTextContent("Clear", "Remove all .sln and .csproj files");
2021
public static readonly GUIContent autoGenerate = EditorGUIUtility.TrTextContent("Generate solution and project files", "Forces .sln and .csproj files to be generated and kept in sync.");
2122
#if !UNITY_2020_2_OR_NEWER
2223
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() + ". ");
2324
#endif
2425
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);
2526

26-
public static readonly GUIContent syncVsFail = EditorGUIUtility.TrTextContent("Couldn't reflect SyncVS members successfully.");
2727
public static readonly GUIContent monoInstallationFinderFail = EditorGUIUtility.TrTextContent("Couldn't reflect MonoInstallationFinder members successfully.");
2828
public static readonly GUIContent discoveryFail = EditorGUIUtility.TrTextContent("Easy Editor couldn't load the discovery.");
2929
}
3030

31-
public static readonly ExternalCodeEditor instance;
32-
private static IEnumerable<string> DefaultExtensions { get; }
31+
public static ExternalCodeEditor Instance { get; private set; }
32+
33+
private static IEnumerable<string> DefaultExtensions => EditorSettings.projectGenerationBuiltinExtensions
34+
.Concat(EditorSettings.projectGenerationUserExtensions)
35+
.Concat(new[] { "json", "asmdef", "log" })
36+
.Distinct();
3337

3438
public CodeEditor.Installation[] Installations { get; }
3539

40+
private readonly IGenerator generator = new ProjectGeneration(Directory.GetParent(Application.dataPath).FullName);
41+
3642
static ExternalCodeEditor()
3743
{
38-
DefaultExtensions = EditorSettings.projectGenerationBuiltinExtensions
39-
.Concat(EditorSettings.projectGenerationUserExtensions)
40-
.Concat(new[] { "json", "asmdef", "log" })
41-
.Distinct();
42-
43-
instance = new ExternalCodeEditor();
44-
CodeEditor.Register(instance);
44+
EditorApplication.delayCall += RegisterInstance;
4545

4646
AssemblyReloadEvents.beforeAssemblyReload += OnBeforeAssemblyReload;
4747
AssemblyReloadEvents.afterAssemblyReload += OnAfterAssemblyReload;
4848
}
4949

50+
private static void RegisterInstance()
51+
{
52+
Instance = new ExternalCodeEditor();
53+
54+
if (Instance != null)
55+
{
56+
CodeEditor.Register(Instance);
57+
}
58+
}
59+
5060
private static bool SupportsExtension(string path)
5161
{
5262
string extension = Path.GetExtension(path);
@@ -64,14 +74,20 @@ private static void OnAfterAssemblyReload()
6474
{
6575
if (discovery.AutoGenerate)
6676
{
67-
SyncUtil.Sync();
77+
if (CodeEditor.CurrentEditor == Instance)
78+
{
79+
CodeEditor.CurrentEditor.SyncAll();
80+
}
6881
}
6982
}
7083
}
7184

7285
private static void OnBeforeAssemblyReload()
7386
{
74-
CodeEditor.Unregister(instance);
87+
if (Instance != null)
88+
{
89+
CodeEditor.Unregister(Instance);
90+
}
7591
}
7692

7793
private ExternalCodeEditor()
@@ -85,7 +101,7 @@ public void Initialize(string editorInstallationPath)
85101
{
86102
if (discovery.AutoGenerate)
87103
{
88-
SyncUtil.Sync();
104+
generator.Sync();
89105
}
90106
}
91107
}
@@ -99,7 +115,7 @@ public void OnGUI()
99115
return;
100116
}
101117

102-
EditorGUI.BeginDisabledGroup(!Preferences.IsActive || SyncUtil.IsReloading || EditorApplication.isCompiling || EditorApplication.isUpdating);
118+
EditorGUI.BeginDisabledGroup(!Preferences.IsActive || EditorApplication.isCompiling || EditorApplication.isUpdating);
103119

104120
if (!string.IsNullOrEmpty(discovery.notes))
105121
{
@@ -121,8 +137,6 @@ public void OnGUI()
121137
}
122138
EditorGUILayout.EndHorizontal();
123139

124-
EditorGUI.BeginDisabledGroup(!SyncVS.IsValid);
125-
126140
EditorGUILayout.BeginHorizontal();
127141

128142
EditorGUI.BeginChangeCheck();
@@ -132,13 +146,35 @@ public void OnGUI()
132146
discovery.AutoGenerate = autoGenerate;
133147
if (autoGenerate)
134148
{
135-
SyncUtil.Sync();
149+
generator.Sync();
136150
}
137151
}
138152

139-
if (GUILayout.Button(Properties.generate, EditorStyles.miniButton, GUILayout.Width(64f)))
153+
var flags = generator.AssemblyNameProvider.ProjectGenerationFlag;
154+
EditorGUI.BeginChangeCheck();
155+
var nflags = (ProjectGenerationFlag)EditorGUILayout.EnumFlagsField(flags);
156+
if (EditorGUI.EndChangeCheck())
140157
{
141-
SyncUtil.Sync();
158+
generator.AssemblyNameProvider.ToggleProjectGeneration(nflags ^ flags);
159+
}
160+
161+
if (GUILayout.Button(Properties.generate, EditorStyles.miniButtonLeft, GUILayout.Width(64f)))
162+
{
163+
generator.Sync();
164+
}
165+
166+
if (GUILayout.Button(Properties.clear, EditorStyles.miniButtonRight, GUILayout.Width(40f)))
167+
{
168+
var di = new DirectoryInfo(Preferences.projectPath);
169+
foreach (var fi in di.EnumerateFiles("*.csproj", SearchOption.TopDirectoryOnly))
170+
{
171+
fi.Delete();
172+
}
173+
174+
foreach (var fi in di.EnumerateFiles("*.sln", SearchOption.TopDirectoryOnly))
175+
{
176+
fi.Delete();
177+
}
142178
}
143179

144180
EditorGUILayout.EndHorizontal();
@@ -151,16 +187,10 @@ public void OnGUI()
151187
discovery.MatchCompilerVersion = matchCompilerVersion;
152188
if (matchCompilerVersion)
153189
{
154-
SyncUtil.Sync();
190+
generator.Sync();
155191
}
156192
}
157193
#endif
158-
EditorGUI.EndDisabledGroup();
159-
160-
if (!SyncVS.IsValid)
161-
{
162-
EditorGUILayout.HelpBox(Properties.syncVsFail.text, MessageType.Warning);
163-
}
164194

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

@@ -259,7 +289,8 @@ public void SyncAll()
259289
{
260290
if (discovery.AutoGenerate)
261291
{
262-
SyncUtil.Sync();
292+
AssetDatabase.Refresh();
293+
generator.Sync();
263294
}
264295
}
265296
}
@@ -270,7 +301,7 @@ public void SyncIfNeeded(string[] addedFiles, string[] deletedFiles, string[] mo
270301
{
271302
if (discovery.AutoGenerate)
272303
{
273-
SyncUtil.Sync();
304+
_ = generator.SyncIfNeeded(addedFiles.Union(deletedFiles).Union(movedFiles).Union(movedFromFiles).ToList(), importedFiles);
274305
}
275306
}
276307
}

Editor/ProjectGeneration.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)