Skip to content

Commit 404c410

Browse files
committed
Extract variable
1 parent 47a4810 commit 404c410

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

Packages/com.unity.ide.visualstudio/Editor/ProjectGeneration/ProjectGeneration.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -674,24 +674,25 @@ private void SetAnalyzerAndSourceGeneratorProperties(Assembly assembly, Response
674674
var additionalFilePaths = new List<string>();
675675
var rulesetPath = string.Empty;
676676
var analyzerConfigPath = string.Empty;
677+
var compilerOptions = assembly.compilerOptions;
677678

678679
#if UNITY_2020_2_OR_NEWER
679680
// Analyzers + ruleset provided by Unity
680-
analyzers.AddRange(assembly.compilerOptions.RoslynAnalyzerDllPaths);
681-
rulesetPath = assembly.compilerOptions.RoslynAnalyzerRulesetPath;
681+
analyzers.AddRange(compilerOptions.RoslynAnalyzerDllPaths);
682+
rulesetPath = compilerOptions.RoslynAnalyzerRulesetPath;
682683
#endif
683684

684685
// We have support in 2021.3, 2022.2 but without a backport in 2022.1
685686
#if UNITY_2021_3
686687
// Unfortunately those properties were introduced in a patch release of 2021.3, so not found in 2021.3.2f1 for example
687-
var scoType = typeof(ScriptCompilerOptions);
688+
var scoType = compilerOptions.GetType();
688689
var afpProperty = scoType.GetProperty("RoslynAdditionalFilePaths");
689690
var acpProperty = scoType.GetProperty("AnalyzerConfigPath");
690-
additionalFilePaths.AddRange(afpProperty?.GetValue(assembly.compilerOptions) as string[] ?? Array.Empty<string>());
691-
analyzerConfigPath = acpProperty?.GetValue(assembly.compilerOptions) as string ?? analyzerConfigPath;
691+
additionalFilePaths.AddRange(afpProperty?.GetValue(compilerOptions) as string[] ?? Array.Empty<string>());
692+
analyzerConfigPath = acpProperty?.GetValue(compilerOptions) as string ?? analyzerConfigPath;
692693
#elif UNITY_2022_2_OR_NEWER
693-
additionalFilePaths.AddRange(assembly.compilerOptions.RoslynAdditionalFilePaths);
694-
analyzerConfigPath = assembly.compilerOptions.AnalyzerConfigPath;
694+
additionalFilePaths.AddRange(compilerOptions.RoslynAdditionalFilePaths);
695+
analyzerConfigPath = compilerOptions.AnalyzerConfigPath;
695696
#endif
696697

697698
// Analyzers and additional files provided by csc.rsp

0 commit comments

Comments
 (0)