Skip to content

Commit 47a4810

Browse files
committed
Fix access to missing properties, only introduced in a 2021.3 patch release
1 parent a369a75 commit 47a4810

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,15 @@ private void SetAnalyzerAndSourceGeneratorProperties(Assembly assembly, Response
681681
rulesetPath = assembly.compilerOptions.RoslynAnalyzerRulesetPath;
682682
#endif
683683

684-
#if UNITY_2021_3_OR_NEWER && !UNITY_2022_1 // we have support in 2021.3, 2022.2 but without a backport in 2022.1
684+
// We have support in 2021.3, 2022.2 but without a backport in 2022.1
685+
#if UNITY_2021_3
686+
// 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 afpProperty = scoType.GetProperty("RoslynAdditionalFilePaths");
689+
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;
692+
#elif UNITY_2022_2_OR_NEWER
685693
additionalFilePaths.AddRange(assembly.compilerOptions.RoslynAdditionalFilePaths);
686694
analyzerConfigPath = assembly.compilerOptions.AnalyzerConfigPath;
687695
#endif

0 commit comments

Comments
 (0)