@@ -674,16 +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
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
685- additionalFilePaths . AddRange ( assembly . compilerOptions . RoslynAdditionalFilePaths ) ;
686- analyzerConfigPath = assembly . compilerOptions . AnalyzerConfigPath ;
685+ // We have support in 2021.3, 2022.2 but without a backport in 2022.1
686+ #if UNITY_2021_3
687+ // Unfortunately those properties were introduced in a patch release of 2021.3, so not found in 2021.3.2f1 for example
688+ var scoType = compilerOptions . GetType ( ) ;
689+ var afpProperty = scoType . GetProperty ( "RoslynAdditionalFilePaths" ) ;
690+ var acpProperty = scoType . GetProperty ( "AnalyzerConfigPath" ) ;
691+ additionalFilePaths . AddRange ( afpProperty ? . GetValue ( compilerOptions ) as string [ ] ?? Array . Empty < string > ( ) ) ;
692+ analyzerConfigPath = acpProperty ? . GetValue ( compilerOptions ) as string ?? analyzerConfigPath ;
693+ #elif UNITY_2022_2_OR_NEWER
694+ additionalFilePaths . AddRange ( compilerOptions . RoslynAdditionalFilePaths ) ;
695+ analyzerConfigPath = compilerOptions . AnalyzerConfigPath ;
687696#endif
688697
689698 // Analyzers and additional files provided by csc.rsp
0 commit comments