You've already forked com.unity.ide.cursor
mirror of
https://github.com/boxqkrtm/com.unity.ide.cursor.git
synced 2026-05-15 14:50:08 +00:00
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:
@@ -30,6 +30,8 @@ namespace Microsoft.Unity.VisualStudio.Editor
|
||||
|
||||
public class AssemblyNameProvider : IAssemblyNameProvider
|
||||
{
|
||||
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",
|
||||
(int)(ProjectGenerationFlag.Local | ProjectGenerationFlag.Embedded));
|
||||
@@ -55,55 +57,35 @@ namespace Microsoft.Unity.VisualStudio.Editor
|
||||
|
||||
public IEnumerable<Assembly> GetAssemblies(Func<string, bool> shouldFileBePartOfSolution)
|
||||
{
|
||||
foreach (var assembly in CompilationPipeline.GetAssemblies())
|
||||
IEnumerable<Assembly> assemblies = GetAssembliesByType(AssembliesType.Editor, shouldFileBePartOfSolution, @"Temp\Bin\Debug\");
|
||||
|
||||
if (!ProjectGenerationFlag.HasFlag(ProjectGenerationFlag.PlayerAssemblies))
|
||||
{
|
||||
return assemblies;
|
||||
}
|
||||
var playerAssemblies = GetAssembliesByType(AssembliesType.Player, shouldFileBePartOfSolution, @"Temp\Bin\Debug\Player\");
|
||||
return assemblies.Concat(playerAssemblies);
|
||||
}
|
||||
|
||||
private static IEnumerable<Assembly> GetAssembliesByType(AssembliesType type, Func<string, bool> shouldFileBePartOfSolution, string outputPath)
|
||||
{
|
||||
foreach (var assembly in CompilationPipeline.GetAssemblies(type))
|
||||
{
|
||||
if (assembly.sourceFiles.Any(shouldFileBePartOfSolution))
|
||||
{
|
||||
var options = new ScriptCompilerOptions
|
||||
{
|
||||
ResponseFiles = assembly.compilerOptions.ResponseFiles,
|
||||
AllowUnsafeCode = assembly.compilerOptions.AllowUnsafeCode,
|
||||
ApiCompatibilityLevel = assembly.compilerOptions.ApiCompatibilityLevel
|
||||
};
|
||||
|
||||
yield return new Assembly(assembly.name, @"Temp\Bin\Debug\",
|
||||
assembly.sourceFiles, new[] { "DEBUG", "TRACE" }.Concat(assembly.defines).Concat(EditorUserBuildSettings.activeScriptCompilationDefines).ToArray(),
|
||||
yield return new Assembly(
|
||||
assembly.name,
|
||||
outputPath,
|
||||
assembly.sourceFiles,
|
||||
assembly.defines,
|
||||
assembly.assemblyReferences,
|
||||
assembly.compiledAssemblyReferences,
|
||||
assembly.flags,
|
||||
assembly.compilerOptions
|
||||
#if UNITY_2020_2_OR_NEWER
|
||||
options,
|
||||
assembly.rootNamespace);
|
||||
#else
|
||||
options);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (ProjectGenerationFlag.HasFlag(ProjectGenerationFlag.PlayerAssemblies))
|
||||
{
|
||||
foreach (var assembly in CompilationPipeline.GetAssemblies(AssembliesType.Player).Where(assembly => assembly.sourceFiles.Any(shouldFileBePartOfSolution)))
|
||||
{
|
||||
var options = new ScriptCompilerOptions
|
||||
{
|
||||
ResponseFiles = assembly.compilerOptions.ResponseFiles,
|
||||
AllowUnsafeCode = assembly.compilerOptions.AllowUnsafeCode,
|
||||
ApiCompatibilityLevel = assembly.compilerOptions.ApiCompatibilityLevel
|
||||
};
|
||||
|
||||
yield return
|
||||
new Assembly(assembly.name, @"Temp\Bin\Debug\Player\",
|
||||
assembly.sourceFiles,
|
||||
new[] { "DEBUG", "TRACE" }.Concat(assembly.defines).ToArray(),
|
||||
assembly.assemblyReferences,
|
||||
assembly.compiledAssemblyReferences,
|
||||
assembly.flags,
|
||||
#if UNITY_2020_2_OR_NEWER
|
||||
options,
|
||||
assembly.rootNamespace);
|
||||
#else
|
||||
options);
|
||||
, assembly.rootNamespace
|
||||
#endif
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -118,9 +100,39 @@ namespace Microsoft.Unity.VisualStudio.Editor
|
||||
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 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 bool IsInternalizedPackagePath(string path)
|
||||
@@ -177,6 +189,11 @@ namespace Microsoft.Unity.VisualStudio.Editor
|
||||
}
|
||||
}
|
||||
|
||||
internal void ResetPackageInfoCache()
|
||||
{
|
||||
m_PackageInfoCache.Clear();
|
||||
}
|
||||
|
||||
public void ResetProjectGenerationFlag()
|
||||
{
|
||||
ProjectGenerationFlag = ProjectGenerationFlag.None;
|
||||
|
||||
Reference in New Issue
Block a user