From 0a73774fc6694061853e2c005b08481876f674ae Mon Sep 17 00:00:00 2001 From: sveinungf Date: Sat, 25 Nov 2023 10:48:53 +0100 Subject: [PATCH] Resolve trim warnings for the SourceGenerator project by not referencing the Polyfill package --- Directory.Build.props | 2 +- .../Helpers/Backporting/NotNullWhenAttribute.cs | 11 +++++++++++ .../SpreadCheetah.TrimCheck.Cmd.csproj | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 SpreadCheetah.SourceGenerator/Helpers/Backporting/NotNullWhenAttribute.cs diff --git a/Directory.Build.props b/Directory.Build.props index 4518c54a..88649f12 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -9,7 +9,7 @@ true - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/SpreadCheetah.SourceGenerator/Helpers/Backporting/NotNullWhenAttribute.cs b/SpreadCheetah.SourceGenerator/Helpers/Backporting/NotNullWhenAttribute.cs new file mode 100644 index 00000000..1e4f733e --- /dev/null +++ b/SpreadCheetah.SourceGenerator/Helpers/Backporting/NotNullWhenAttribute.cs @@ -0,0 +1,11 @@ +#if NETSTANDARD2_0 +namespace System.Diagnostics.CodeAnalysis; + +[AttributeUsage(AttributeTargets.Parameter, Inherited = false)] +internal sealed class NotNullWhenAttribute : Attribute +{ + public bool ReturnValue { get; } + + public NotNullWhenAttribute(bool returnValue) => ReturnValue = returnValue; +} +#endif \ No newline at end of file diff --git a/SpreadCheetah.TrimCheck.Cmd/SpreadCheetah.TrimCheck.Cmd.csproj b/SpreadCheetah.TrimCheck.Cmd/SpreadCheetah.TrimCheck.Cmd.csproj index 9aa72f57..f3b3d347 100644 --- a/SpreadCheetah.TrimCheck.Cmd/SpreadCheetah.TrimCheck.Cmd.csproj +++ b/SpreadCheetah.TrimCheck.Cmd/SpreadCheetah.TrimCheck.Cmd.csproj @@ -4,6 +4,7 @@ Exe net8.0 true + false