Disabled [SkipLocalsInit] generation on unsupported targets

このコミットが含まれているのは:
Sergio Pedri committed 2021-11-16 17:34:01 +01:00
1 親 1e4b547c38
コミット e69a0b5835
1ファイル変更
+3 -2
+3 -2
ファイルの表示
@@ -89,8 +89,9 @@ public sealed partial class IShaderGenerator : ISourceGenerator
Literal("This method is not intended to be used directly by user code"))))))
};
// Add [SkipLocalsInit] if the target project allows it
if (context.Compilation.Options is CSharpCompilationOptions { AllowUnsafe: true })
// Add [SkipLocalsInit] if the target project allows it and can access it
if (context.Compilation.Options is CSharpCompilationOptions { AllowUnsafe: true } &&
context.Compilation.GetTypeByMetadataName("System.Runtime.CompilerServices.SkipLocalsInit") is not null)
{
attributes.Add(AttributeList(SingletonSeparatedList(Attribute(IdentifierName("global::System.Runtime.CompilerServices.SkipLocalsInit")))));
}