You've already forked com.unity.ide.cursor
mirror of
https://github.com/boxqkrtm/com.unity.ide.cursor.git
synced 2026-05-14 22:30:10 +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;
|
||||
|
||||
@@ -104,10 +104,6 @@ namespace Microsoft.Unity.VisualStudio.Editor
|
||||
{
|
||||
SetupProjectSupportedExtensions();
|
||||
|
||||
// See https://devblogs.microsoft.com/setup/configure-visual-studio-across-your-organization-with-vsconfig/
|
||||
// We create a .vsconfig file to make sure our ManagedGame workload is installed
|
||||
CreateVsConfigIfNotFound();
|
||||
|
||||
// Don't sync if we haven't synced before
|
||||
if (HasSolutionBeenGenerated() && HasFilesBeenModified(affectedFiles, reimportedFiles))
|
||||
{
|
||||
@@ -161,6 +157,13 @@ namespace Microsoft.Unity.VisualStudio.Editor
|
||||
RefreshCurrentInstallation();
|
||||
|
||||
SetupProjectSupportedExtensions();
|
||||
|
||||
(m_AssemblyNameProvider as AssemblyNameProvider)?.ResetPackageInfoCache();
|
||||
|
||||
// See https://devblogs.microsoft.com/setup/configure-visual-studio-across-your-organization-with-vsconfig/
|
||||
// We create a .vsconfig file to make sure our ManagedGame workload is installed
|
||||
CreateVsConfigIfNotFound();
|
||||
|
||||
var externalCodeAlreadyGeneratedProjects = OnPreGeneratingCSProjectFiles();
|
||||
|
||||
if (!externalCodeAlreadyGeneratedProjects)
|
||||
@@ -322,7 +325,7 @@ namespace Microsoft.Unity.VisualStudio.Editor
|
||||
stringBuilders[assemblyName] = projectBuilder;
|
||||
}
|
||||
|
||||
projectBuilder.Append(" <None Include=\"").Append(EscapedRelativePathFor(asset)).Append("\" />").Append(k_WindowsNewline);
|
||||
projectBuilder.Append(" <None Include=\"").Append(EscapedRelativePathFor(asset)).Append("\" />").Append(k_WindowsNewline);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -367,6 +370,7 @@ namespace Microsoft.Unity.VisualStudio.Editor
|
||||
{
|
||||
return TypeCache
|
||||
.GetTypesDerivedFrom<AssetPostprocessor>()
|
||||
.Where(t => t.Assembly.GetName().Name != "SyntaxTree.VisualStudio.Unity.Bridge") // never call into the bridge if loaded with the package
|
||||
.Select(t => t.GetMethod(name, SR.BindingFlags.Public | SR.BindingFlags.NonPublic | SR.BindingFlags.Static))
|
||||
.Where(m => m != null);
|
||||
}
|
||||
@@ -466,12 +470,19 @@ namespace Microsoft.Unity.VisualStudio.Editor
|
||||
}
|
||||
projectBuilder.Append(@" </ItemGroup>").Append(k_WindowsNewline);
|
||||
|
||||
projectBuilder.Append(@" <ItemGroup>").Append(k_WindowsNewline);
|
||||
|
||||
// Append additional non-script files that should be included in project generation.
|
||||
if (allAssetsProjectParts.TryGetValue(assembly.name, out var additionalAssetsForProject))
|
||||
{
|
||||
projectBuilder.Append(@" <ItemGroup>").Append(k_WindowsNewline);
|
||||
|
||||
projectBuilder.Append(additionalAssetsForProject);
|
||||
|
||||
projectBuilder.Append(@" </ItemGroup>").Append(k_WindowsNewline);
|
||||
|
||||
}
|
||||
|
||||
projectBuilder.Append(@" <ItemGroup>").Append(k_WindowsNewline);
|
||||
|
||||
var responseRefs = responseFilesData.SelectMany(x => x.FullPathReferences.Select(r => r));
|
||||
var internalAssemblyReferences = assembly.assemblyReferences
|
||||
.Where(i => !i.sourceFiles.Any(ShouldFileBePartOfSolution)).Select(i => i.outputPath);
|
||||
|
||||
Reference in New Issue
Block a user