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.18
## [2.0.18] - 2023-03-17 Integration: - Performance improvements with `EditorApplication.update` callbacks. Project generation: - Add extra compiler options for analyzers and source generators.
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -664,33 +664,50 @@ namespace Microsoft.Unity.VisualStudio.Editor
|
||||
}
|
||||
}
|
||||
|
||||
private string[] GetAnalyzers(Assembly assembly, ResponseFileData[] responseFilesData, out string rulesetPath)
|
||||
private void SetAnalyzerAndSourceGeneratorProperties(Assembly assembly, ResponseFileData[] responseFilesData, ProjectProperties properties)
|
||||
{
|
||||
rulesetPath = null;
|
||||
|
||||
if (m_CurrentInstallation == null || !m_CurrentInstallation.SupportsAnalyzers)
|
||||
return Array.Empty<string>();
|
||||
|
||||
return;
|
||||
|
||||
// Analyzers provided by VisualStudio
|
||||
List<string> analyzers = new List<string>(m_CurrentInstallation.GetAnalyzers());
|
||||
var analyzers = new List<string>(m_CurrentInstallation.GetAnalyzers());
|
||||
var additionalFilePaths = new List<string>();
|
||||
var rulesetPath = string.Empty;
|
||||
var analyzerConfigPath = string.Empty;
|
||||
|
||||
#if UNITY_2020_2_OR_NEWER
|
||||
// Analyzers + ruleset provided by Unity
|
||||
analyzers.AddRange(assembly.compilerOptions.RoslynAnalyzerDllPaths);
|
||||
|
||||
rulesetPath = assembly
|
||||
.compilerOptions
|
||||
.RoslynAnalyzerRulesetPath
|
||||
.MakeAbsolutePath()
|
||||
.NormalizePathSeparators();
|
||||
rulesetPath = assembly.compilerOptions.RoslynAnalyzerRulesetPath;
|
||||
#endif
|
||||
|
||||
// Analyzers provided by csc.rsp
|
||||
analyzers.AddRange(GetOtherArguments(responseFilesData, new HashSet<string>(new[] { "analyzer", "a" })));
|
||||
#if UNITY_2021_3_OR_NEWER && !UNITY_2022_1 // we have support in 2021.3, 2022.2 but without a backport in 2022.1
|
||||
additionalFilePaths.AddRange(assembly.compilerOptions.RoslynAdditionalFilePaths);
|
||||
analyzerConfigPath = assembly.compilerOptions.AnalyzerConfigPath;
|
||||
#endif
|
||||
|
||||
return analyzers
|
||||
// Analyzers and additional files provided by csc.rsp
|
||||
analyzers.AddRange(GetOtherArguments(responseFilesData, new HashSet<string>(new[] { "analyzer", "a" })));
|
||||
additionalFilePaths.AddRange(GetOtherArguments(responseFilesData, new HashSet<string>(new[] { "additionalfile" })));
|
||||
|
||||
properties.RulesetPath = ToNormalizedPath(rulesetPath);
|
||||
properties.Analyzers = ToNormalizedPaths(analyzers);
|
||||
properties.AnalyzerConfigPath = ToNormalizedPath(analyzerConfigPath);
|
||||
properties.AdditionalFilePaths = ToNormalizedPaths(additionalFilePaths);
|
||||
}
|
||||
|
||||
private string ToNormalizedPath(string path)
|
||||
{
|
||||
return path
|
||||
.MakeAbsolutePath()
|
||||
.NormalizePathSeparators();
|
||||
}
|
||||
|
||||
private string[] ToNormalizedPaths(IEnumerable<string> values)
|
||||
{
|
||||
return values
|
||||
.Where(a => !string.IsNullOrEmpty(a))
|
||||
.Select(a => a.MakeAbsolutePath().NormalizePathSeparators())
|
||||
.Select(a => ToNormalizedPath(a))
|
||||
.Distinct()
|
||||
.ToArray();
|
||||
}
|
||||
@@ -702,7 +719,6 @@ namespace Microsoft.Unity.VisualStudio.Editor
|
||||
)
|
||||
{
|
||||
var projectType = ProjectTypeOf(assembly.name);
|
||||
var analyzers = GetAnalyzers(assembly, responseFilesData, out var rulesetPath);
|
||||
|
||||
var projectProperties = new ProjectProperties
|
||||
{
|
||||
@@ -711,10 +727,7 @@ namespace Microsoft.Unity.VisualStudio.Editor
|
||||
AssemblyName = assembly.name,
|
||||
RootNamespace = GetRootNamespace(assembly),
|
||||
OutputPath = assembly.outputPath,
|
||||
// Analyzers
|
||||
RulesetPath = rulesetPath,
|
||||
// RSP alterable
|
||||
Analyzers = analyzers,
|
||||
Defines = assembly.defines.Concat(responseFilesData.SelectMany(x => x.Defines)).Distinct().ToArray(),
|
||||
Unsafe = assembly.compilerOptions.AllowUnsafeCode | responseFilesData.Any(x => x.Unsafe),
|
||||
// VSTU Flavoring
|
||||
@@ -724,6 +737,8 @@ namespace Microsoft.Unity.VisualStudio.Editor
|
||||
FlavoringPackageVersion = VisualStudioIntegration.PackageVersion(),
|
||||
};
|
||||
|
||||
SetAnalyzerAndSourceGeneratorProperties(assembly, responseFilesData, projectProperties);
|
||||
|
||||
GetProjectHeader(projectProperties, out headerBuilder);
|
||||
}
|
||||
|
||||
@@ -830,6 +845,23 @@ namespace Microsoft.Unity.VisualStudio.Editor
|
||||
}
|
||||
headerBuilder.Append(@" </ItemGroup>").Append(k_WindowsNewline);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(properties.AnalyzerConfigPath))
|
||||
{
|
||||
headerBuilder.Append(@" <ItemGroup>").Append(k_WindowsNewline);
|
||||
headerBuilder.Append(@" <EditorConfigFiles Include=""").Append(properties.AnalyzerConfigPath).Append(@""" />").Append(k_WindowsNewline);
|
||||
headerBuilder.Append(@" </ItemGroup>").Append(k_WindowsNewline);
|
||||
}
|
||||
|
||||
if (properties.AdditionalFilePaths.Any())
|
||||
{
|
||||
headerBuilder.Append(@" <ItemGroup>").Append(k_WindowsNewline);
|
||||
foreach (var additionalFile in properties.AdditionalFilePaths)
|
||||
{
|
||||
headerBuilder.Append(@" <AdditionalFiles Include=""").Append(additionalFile).Append(@""" />").Append(k_WindowsNewline);
|
||||
}
|
||||
headerBuilder.Append(@" </ItemGroup>").Append(k_WindowsNewline);
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetProjectFooter()
|
||||
|
||||
@@ -13,6 +13,9 @@ namespace Microsoft.Unity.VisualStudio.Editor
|
||||
// Analyzers
|
||||
public string[] Analyzers { get; set; } = Array.Empty<string>();
|
||||
public string RulesetPath { get; set; } = string.Empty;
|
||||
public string AnalyzerConfigPath { get; set; } = string.Empty;
|
||||
// Source generators
|
||||
public string[] AdditionalFilePaths { get; set; } = Array.Empty<string>();
|
||||
|
||||
// RSP alterable
|
||||
public string[] Defines { get; set; } = Array.Empty<string>();
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Microsoft.Unity.VisualStudio.Editor
|
||||
class Client
|
||||
{
|
||||
public IPEndPoint EndPoint { get; set; }
|
||||
public DateTime LastMessage { get; set; }
|
||||
public double LastMessage { get; set; }
|
||||
}
|
||||
|
||||
private static Messager _messager;
|
||||
@@ -141,7 +141,8 @@ namespace Microsoft.Unity.VisualStudio.Editor
|
||||
{
|
||||
foreach (var client in _clients.Values.ToArray())
|
||||
{
|
||||
if (DateTime.Now.Subtract(client.LastMessage) > TimeSpan.FromMilliseconds(4000))
|
||||
// EditorApplication.timeSinceStartup: The time since the editor was started, in seconds, not reset when starting play mode.
|
||||
if (EditorApplication.timeSinceStartup - client.LastMessage > 4)
|
||||
_clients.Remove(client.EndPoint);
|
||||
}
|
||||
}
|
||||
@@ -216,14 +217,14 @@ namespace Microsoft.Unity.VisualStudio.Editor
|
||||
client = new Client
|
||||
{
|
||||
EndPoint = endPoint,
|
||||
LastMessage = DateTime.Now
|
||||
LastMessage = EditorApplication.timeSinceStartup
|
||||
};
|
||||
|
||||
_clients.Add(endPoint, client);
|
||||
}
|
||||
else
|
||||
{
|
||||
client.LastMessage = DateTime.Now;
|
||||
client.LastMessage = EditorApplication.timeSinceStartup;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user