From 261e7d311bd121776a459a3cc5758069c9bd21b1 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 22 Nov 2022 14:51:16 +0100 Subject: [PATCH 1/5] Move [SkipLocalsInit] to shared .targets file --- .../Properties/AssemblyInfo.cs | 8 ---- .../Properties/AssemblyInfo.cs | 8 ---- .../Properties/AssemblyInfo.cs | 8 +--- .../Attributes/SkipLocalsInitAttribute.cs | 27 ++++++++++++ ...ityToolkit.Mvvm.SourceGenerators.projitems | 1 + .../Properties/AssemblyInfo.cs | 3 -- src/Directory.Build.targets | 44 +++++++++++++++++++ 7 files changed, 73 insertions(+), 26 deletions(-) delete mode 100644 src/CommunityToolkit.Common/Properties/AssemblyInfo.cs delete mode 100644 src/CommunityToolkit.Diagnostics/Properties/AssemblyInfo.cs create mode 100644 src/CommunityToolkit.Mvvm.SourceGenerators/Attributes/SkipLocalsInitAttribute.cs create mode 100644 src/Directory.Build.targets diff --git a/src/CommunityToolkit.Common/Properties/AssemblyInfo.cs b/src/CommunityToolkit.Common/Properties/AssemblyInfo.cs deleted file mode 100644 index 160f1d9d..00000000 --- a/src/CommunityToolkit.Common/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,8 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Runtime.CompilerServices; - -// See notes in CommunityToolkit.HighPerformance for more info -[module: SkipLocalsInit] \ No newline at end of file diff --git a/src/CommunityToolkit.Diagnostics/Properties/AssemblyInfo.cs b/src/CommunityToolkit.Diagnostics/Properties/AssemblyInfo.cs deleted file mode 100644 index 160f1d9d..00000000 --- a/src/CommunityToolkit.Diagnostics/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,8 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Runtime.CompilerServices; - -// See notes in CommunityToolkit.HighPerformance for more info -[module: SkipLocalsInit] \ No newline at end of file diff --git a/src/CommunityToolkit.HighPerformance/Properties/AssemblyInfo.cs b/src/CommunityToolkit.HighPerformance/Properties/AssemblyInfo.cs index 333e5efc..25c38563 100644 --- a/src/CommunityToolkit.HighPerformance/Properties/AssemblyInfo.cs +++ b/src/CommunityToolkit.HighPerformance/Properties/AssemblyInfo.cs @@ -2,15 +2,9 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#if !NETSTANDARD2_1_OR_GREATER using System.Runtime.CompilerServices; -// We can suppress the .init flag for local variables for the entire module. -// This doesn't affect the correctness of methods in this assembly, as none of them -// are relying on the JIT ensuring that all local memory is zeroed out to work. Doing -// this can provide some minor performance benefits, depending on the workload. -[module: SkipLocalsInit] - // We need to test the RuntimeHelpers polyfills on applicable runtimes -#if !NETSTANDARD2_1_OR_GREATER [assembly: InternalsVisibleTo("CommunityToolkit.HighPerformance.UnitTests, publickey=002400000480000094000000060200000024000052534131000400000100010041753AF735AE6140C9508567666C51C6AB929806ADB0D210694B30AB142A060237BC741F9682E7D8D4310364B4BBA4EE89CC9D3D5CE7E5583587E8EA44DCA09977996582875E71FB54FA7B170798D853D5D8010B07219633BDB761D01AC924DA44576D6180CDCEAE537973982BB461C541541D58417A3794E34F45E6F2D129E2")] #endif \ No newline at end of file diff --git a/src/CommunityToolkit.Mvvm.SourceGenerators/Attributes/SkipLocalsInitAttribute.cs b/src/CommunityToolkit.Mvvm.SourceGenerators/Attributes/SkipLocalsInitAttribute.cs new file mode 100644 index 00000000..a05d197d --- /dev/null +++ b/src/CommunityToolkit.Mvvm.SourceGenerators/Attributes/SkipLocalsInitAttribute.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +#if !NET6_0_OR_GREATER + +namespace System.Runtime.CompilerServices; + +/// +/// Used to indicate to the compiler that the .locals init flag should not be set in method headers. +/// +/// Internal copy from the BCL attribute. +[AttributeUsage( + AttributeTargets.Module | + AttributeTargets.Class | + AttributeTargets.Struct | + AttributeTargets.Interface | + AttributeTargets.Constructor | + AttributeTargets.Method | + AttributeTargets.Property | + AttributeTargets.Event, + Inherited = false)] +internal sealed class SkipLocalsInitAttribute : Attribute +{ +} + +#endif \ No newline at end of file diff --git a/src/CommunityToolkit.Mvvm.SourceGenerators/CommunityToolkit.Mvvm.SourceGenerators.projitems b/src/CommunityToolkit.Mvvm.SourceGenerators/CommunityToolkit.Mvvm.SourceGenerators.projitems index 72e59be9..a3409ee1 100644 --- a/src/CommunityToolkit.Mvvm.SourceGenerators/CommunityToolkit.Mvvm.SourceGenerators.projitems +++ b/src/CommunityToolkit.Mvvm.SourceGenerators/CommunityToolkit.Mvvm.SourceGenerators.projitems @@ -33,6 +33,7 @@ + diff --git a/src/CommunityToolkit.Mvvm/Properties/AssemblyInfo.cs b/src/CommunityToolkit.Mvvm/Properties/AssemblyInfo.cs index 87398905..69e10663 100644 --- a/src/CommunityToolkit.Mvvm/Properties/AssemblyInfo.cs +++ b/src/CommunityToolkit.Mvvm/Properties/AssemblyInfo.cs @@ -4,7 +4,4 @@ using System.Runtime.CompilerServices; -// See notes in CommunityToolkit.HighPerformance for more info -[module: SkipLocalsInit] - [assembly: InternalsVisibleTo("CommunityToolkit.Mvvm.Internals.UnitTests, PublicKey=002400000480000094000000060200000024000052534131000400000100010041753AF735AE6140C9508567666C51C6AB929806ADB0D210694B30AB142A060237BC741F9682E7D8D4310364B4BBA4EE89CC9D3D5CE7E5583587E8EA44DCA09977996582875E71FB54FA7B170798D853D5D8010B07219633BDB761D01AC924DA44576D6180CDCEAE537973982BB461C541541D58417A3794E34F45E6F2D129E2")] \ No newline at end of file diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets new file mode 100644 index 00000000..8cdc6115 --- /dev/null +++ b/src/Directory.Build.targets @@ -0,0 +1,44 @@ + + + + + + + $(IntermediateOutputPath)$(MSBuildProjectName).SkipLocalsInit.g.cs + + +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +[module: global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]]]> + + + + + + + + + + + + + + \ No newline at end of file From 6c462db54ee6f7aaa3143f285133f27ece7ad6a3 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 22 Nov 2022 16:23:54 +0100 Subject: [PATCH 2/5] Use PolySharp to generate polyfills --- .../Attributes/NotNullIfNotNullAttribute.cs | 28 ------ .../Attributes/NotNullWhenAttribute.cs | 28 ------ .../Attributes/SkipLocalsInitAttribute.cs | 27 ------ .../CommunityToolkit.Common.csproj | 9 ++ .../CallerArgumentExpressionAttribute.cs | 31 ------- .../Attributes/DoesNotReturnAttribute.cs | 18 ---- .../Attributes/DoesNotReturnIfAttribute.cs | 35 -------- .../Attributes/NotNullAttribute.cs | 19 ---- .../Attributes/SkipLocalsInitAttribute.cs | 27 ------ .../Attributes/StackTraceHiddenAttribute.cs | 23 ----- .../CommunityToolkit.Diagnostics.csproj | 14 ++- .../Attributes/NotNullAttribute.cs | 19 ---- .../Attributes/NotNullWhenAttribute.cs | 35 -------- .../Attributes/SkipLocalsInitAttribute.cs | 27 ------ .../CommunityToolkit.HighPerformance.csproj | 9 ++ .../Attributes/NotNullWhenAttribute.cs | 24 ----- .../Attributes/SkipLocalsInitAttribute.cs | 27 ------ ...ityToolkit.Mvvm.SourceGenerators.projitems | 3 - .../IsExternalInit.cs | 16 ---- .../CommunityToolkit.Mvvm.csproj | 17 ++++ .../CallerArgumentExpressionAttribute.cs | 31 ------- .../Attributes/DoesNotReturnAttribute.cs | 18 ---- .../Attributes/MaybeNullWhenAttribute.cs | 31 ------- .../Attributes/MemberNotNullAttribute.cs | 40 --------- .../Polyfills/Attributes/NotNullAttribute.cs | 19 ---- .../Attributes/NotNullIfNotNullAttribute.cs | 26 ------ .../Attributes/NotNullWhenAttribute.cs | 28 ------ .../RequiresUnreferencedCodeAttribute.cs | 37 -------- .../Attributes/SkipLocalsInitAttribute.cs | 27 ------ .../UnconditionalSuppressMessageAttribute.cs | 90 ------------------- .../IsExternalInit.cs | 20 ----- src/Directory.Build.props | 11 +++ 32 files changed, 59 insertions(+), 755 deletions(-) delete mode 100644 src/CommunityToolkit.Common/Attributes/NotNullIfNotNullAttribute.cs delete mode 100644 src/CommunityToolkit.Common/Attributes/NotNullWhenAttribute.cs delete mode 100644 src/CommunityToolkit.Common/Attributes/SkipLocalsInitAttribute.cs delete mode 100644 src/CommunityToolkit.Diagnostics/Attributes/CallerArgumentExpressionAttribute.cs delete mode 100644 src/CommunityToolkit.Diagnostics/Attributes/DoesNotReturnAttribute.cs delete mode 100644 src/CommunityToolkit.Diagnostics/Attributes/DoesNotReturnIfAttribute.cs delete mode 100644 src/CommunityToolkit.Diagnostics/Attributes/NotNullAttribute.cs delete mode 100644 src/CommunityToolkit.Diagnostics/Attributes/SkipLocalsInitAttribute.cs delete mode 100644 src/CommunityToolkit.Diagnostics/Attributes/StackTraceHiddenAttribute.cs delete mode 100644 src/CommunityToolkit.HighPerformance/Attributes/NotNullAttribute.cs delete mode 100644 src/CommunityToolkit.HighPerformance/Attributes/NotNullWhenAttribute.cs delete mode 100644 src/CommunityToolkit.HighPerformance/Attributes/SkipLocalsInitAttribute.cs delete mode 100644 src/CommunityToolkit.Mvvm.SourceGenerators/Attributes/NotNullWhenAttribute.cs delete mode 100644 src/CommunityToolkit.Mvvm.SourceGenerators/Attributes/SkipLocalsInitAttribute.cs delete mode 100644 src/CommunityToolkit.Mvvm.SourceGenerators/System.Runtime.CompilerServices/IsExternalInit.cs delete mode 100644 src/CommunityToolkit.Mvvm/Properties/Polyfills/Attributes/CallerArgumentExpressionAttribute.cs delete mode 100644 src/CommunityToolkit.Mvvm/Properties/Polyfills/Attributes/DoesNotReturnAttribute.cs delete mode 100644 src/CommunityToolkit.Mvvm/Properties/Polyfills/Attributes/MaybeNullWhenAttribute.cs delete mode 100644 src/CommunityToolkit.Mvvm/Properties/Polyfills/Attributes/MemberNotNullAttribute.cs delete mode 100644 src/CommunityToolkit.Mvvm/Properties/Polyfills/Attributes/NotNullAttribute.cs delete mode 100644 src/CommunityToolkit.Mvvm/Properties/Polyfills/Attributes/NotNullIfNotNullAttribute.cs delete mode 100644 src/CommunityToolkit.Mvvm/Properties/Polyfills/Attributes/NotNullWhenAttribute.cs delete mode 100644 src/CommunityToolkit.Mvvm/Properties/Polyfills/Attributes/RequiresUnreferencedCodeAttribute.cs delete mode 100644 src/CommunityToolkit.Mvvm/Properties/Polyfills/Attributes/SkipLocalsInitAttribute.cs delete mode 100644 src/CommunityToolkit.Mvvm/Properties/Polyfills/Attributes/UnconditionalSuppressMessageAttribute.cs delete mode 100644 src/CommunityToolkit.Mvvm/Properties/Polyfills/System.Runtime.CompilerServices/IsExternalInit.cs create mode 100644 src/Directory.Build.props diff --git a/src/CommunityToolkit.Common/Attributes/NotNullIfNotNullAttribute.cs b/src/CommunityToolkit.Common/Attributes/NotNullIfNotNullAttribute.cs deleted file mode 100644 index a70d1ce2..00000000 --- a/src/CommunityToolkit.Common/Attributes/NotNullIfNotNullAttribute.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#if !NETSTANDARD2_1_OR_GREATER - -namespace System.Diagnostics.CodeAnalysis; - -/// -/// Specifies that the output will be non-null if the named parameter is non-null. -/// -/// Internal copy from the BCL attribute. -[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)] -internal sealed class NotNullIfNotNullAttribute : Attribute -{ - /// - /// Initializes a new instance of the class. - /// - /// The associated parameter name. The output will be non-null if the argument to the parameter specified is non-null. - public NotNullIfNotNullAttribute(string parameterName) => ParameterName = parameterName; - - /// - /// Gets the associated parameter name. - /// - public string ParameterName { get; } -} - -#endif \ No newline at end of file diff --git a/src/CommunityToolkit.Common/Attributes/NotNullWhenAttribute.cs b/src/CommunityToolkit.Common/Attributes/NotNullWhenAttribute.cs deleted file mode 100644 index 39a6b639..00000000 --- a/src/CommunityToolkit.Common/Attributes/NotNullWhenAttribute.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#if !NETSTANDARD2_1_OR_GREATER - -namespace System.Diagnostics.CodeAnalysis; - -/// -/// Specifies that when a method returns , the parameter will not be null even if the corresponding type allows it. -/// -/// Internal copy from the BCL attribute. -[AttributeUsage(AttributeTargets.Parameter, Inherited = false)] -internal sealed class NotNullWhenAttribute : Attribute -{ - /// - /// Initializes a new instance of the class. - /// - /// The return value condition. If the method returns this value, the associated parameter will not be null. - public NotNullWhenAttribute(bool returnValue) => ReturnValue = returnValue; - - /// - /// Gets a value indicating whether the annotated variable is not . - /// - public bool ReturnValue { get; } -} - -#endif \ No newline at end of file diff --git a/src/CommunityToolkit.Common/Attributes/SkipLocalsInitAttribute.cs b/src/CommunityToolkit.Common/Attributes/SkipLocalsInitAttribute.cs deleted file mode 100644 index fcad3701..00000000 --- a/src/CommunityToolkit.Common/Attributes/SkipLocalsInitAttribute.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#if !NET6_0_OR_GREATER - -namespace System.Runtime.CompilerServices; - -/// -/// Used to indicate to the compiler that the .locals init flag should not be set in method headers. -/// -/// Internal copy of the .NET 5 attribute. -[AttributeUsage( - AttributeTargets.Module | - AttributeTargets.Class | - AttributeTargets.Struct | - AttributeTargets.Interface | - AttributeTargets.Constructor | - AttributeTargets.Method | - AttributeTargets.Property | - AttributeTargets.Event, - Inherited = false)] -internal sealed class SkipLocalsInitAttribute : Attribute -{ -} - -#endif \ No newline at end of file diff --git a/src/CommunityToolkit.Common/CommunityToolkit.Common.csproj b/src/CommunityToolkit.Common/CommunityToolkit.Common.csproj index b9b9833c..43324e44 100644 --- a/src/CommunityToolkit.Common/CommunityToolkit.Common.csproj +++ b/src/CommunityToolkit.Common/CommunityToolkit.Common.csproj @@ -19,4 +19,13 @@ NETSTANDARD2_1_OR_GREATER + + + + System.Diagnostics.CodeAnalysis.NotNullIfNotNullAttribute; + System.Diagnostics.CodeAnalysis.NotNullWhenAttribute; + System.Runtime.CompilerServices.SkipLocalsInitAttribute; + + + \ No newline at end of file diff --git a/src/CommunityToolkit.Diagnostics/Attributes/CallerArgumentExpressionAttribute.cs b/src/CommunityToolkit.Diagnostics/Attributes/CallerArgumentExpressionAttribute.cs deleted file mode 100644 index ff9e5a4a..00000000 --- a/src/CommunityToolkit.Diagnostics/Attributes/CallerArgumentExpressionAttribute.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#if !NET5_0_OR_GREATER - -namespace System.Runtime.CompilerServices; - -/// -/// An attribute that allows parameters to receive the expression of other parameters. -/// -/// Internal copy from the BCL attribute. -[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] -internal sealed class CallerArgumentExpressionAttribute : Attribute -{ - /// - /// Initializes a new instance of the class. - /// - /// The condition parameter value. - public CallerArgumentExpressionAttribute(string parameterName) - { - ParameterName = parameterName; - } - - /// - /// Gets the parameter name the expression is retrieved from. - /// - public string ParameterName { get; } -} - -#endif \ No newline at end of file diff --git a/src/CommunityToolkit.Diagnostics/Attributes/DoesNotReturnAttribute.cs b/src/CommunityToolkit.Diagnostics/Attributes/DoesNotReturnAttribute.cs deleted file mode 100644 index 06ced088..00000000 --- a/src/CommunityToolkit.Diagnostics/Attributes/DoesNotReturnAttribute.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#if !NETSTANDARD2_1_OR_GREATER - -namespace System.Diagnostics.CodeAnalysis; - -/// -/// Applied to a method that will never return under any circumstance. -/// -/// Internal copy from the BCL attribute. -[AttributeUsage(AttributeTargets.Method, Inherited = false)] -internal sealed class DoesNotReturnAttribute : Attribute -{ -} - -#endif \ No newline at end of file diff --git a/src/CommunityToolkit.Diagnostics/Attributes/DoesNotReturnIfAttribute.cs b/src/CommunityToolkit.Diagnostics/Attributes/DoesNotReturnIfAttribute.cs deleted file mode 100644 index e0c1a411..00000000 --- a/src/CommunityToolkit.Diagnostics/Attributes/DoesNotReturnIfAttribute.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#if !NETSTANDARD2_1_OR_GREATER - -namespace System.Diagnostics.CodeAnalysis; - -/// -/// Specifies that a given also indicates -/// whether the method will not return (eg. throw an exception). -/// -/// Internal copy from the BCL attribute. -[AttributeUsage(AttributeTargets.Parameter)] -internal sealed class DoesNotReturnIfAttribute : Attribute -{ - /// - /// Initializes a new instance of the class. - /// - /// - /// The condition parameter value. Code after the method will be considered unreachable - /// by diagnostics if the argument to the associated parameter matches this value. - /// - public DoesNotReturnIfAttribute(bool parameterValue) - { - ParameterValue = parameterValue; - } - - /// - /// Gets a value indicating whether the parameter value should be . - /// - public bool ParameterValue { get; } -} - -#endif \ No newline at end of file diff --git a/src/CommunityToolkit.Diagnostics/Attributes/NotNullAttribute.cs b/src/CommunityToolkit.Diagnostics/Attributes/NotNullAttribute.cs deleted file mode 100644 index af849ab3..00000000 --- a/src/CommunityToolkit.Diagnostics/Attributes/NotNullAttribute.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#if !NETSTANDARD2_1_OR_GREATER - -namespace System.Diagnostics.CodeAnalysis; - -/// -/// Specifies that an output will not be even if the corresponding type allows it. -/// Specifies that an input argument was not when the call returns. -/// -/// Internal copy from the BCL attribute. -[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue)] -internal sealed class NotNullAttribute : Attribute -{ -} - -#endif \ No newline at end of file diff --git a/src/CommunityToolkit.Diagnostics/Attributes/SkipLocalsInitAttribute.cs b/src/CommunityToolkit.Diagnostics/Attributes/SkipLocalsInitAttribute.cs deleted file mode 100644 index a05d197d..00000000 --- a/src/CommunityToolkit.Diagnostics/Attributes/SkipLocalsInitAttribute.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#if !NET6_0_OR_GREATER - -namespace System.Runtime.CompilerServices; - -/// -/// Used to indicate to the compiler that the .locals init flag should not be set in method headers. -/// -/// Internal copy from the BCL attribute. -[AttributeUsage( - AttributeTargets.Module | - AttributeTargets.Class | - AttributeTargets.Struct | - AttributeTargets.Interface | - AttributeTargets.Constructor | - AttributeTargets.Method | - AttributeTargets.Property | - AttributeTargets.Event, - Inherited = false)] -internal sealed class SkipLocalsInitAttribute : Attribute -{ -} - -#endif \ No newline at end of file diff --git a/src/CommunityToolkit.Diagnostics/Attributes/StackTraceHiddenAttribute.cs b/src/CommunityToolkit.Diagnostics/Attributes/StackTraceHiddenAttribute.cs deleted file mode 100644 index 68ef293d..00000000 --- a/src/CommunityToolkit.Diagnostics/Attributes/StackTraceHiddenAttribute.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#if !NET6_0_OR_GREATER - -namespace System.Diagnostics; - -/// -/// Removes annotated methods from the stacktrace in case an exception occurrs while they're on the stack. -/// -/// -/// This is a port of the attribute from the BCL in .NET 6, and it's marked as conditional so that it will -/// be removed for package builds that are released on NuGet. This attribute is only used internally to -/// avoid having to clutter the codebase with many compiler directive switches to check for this API. -/// -[Conditional("DEBUG")] -[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Struct, Inherited = false)] -internal sealed class StackTraceHiddenAttribute : Attribute -{ -} - -#endif \ No newline at end of file diff --git a/src/CommunityToolkit.Diagnostics/CommunityToolkit.Diagnostics.csproj b/src/CommunityToolkit.Diagnostics/CommunityToolkit.Diagnostics.csproj index c49a6e53..68867263 100644 --- a/src/CommunityToolkit.Diagnostics/CommunityToolkit.Diagnostics.csproj +++ b/src/CommunityToolkit.Diagnostics/CommunityToolkit.Diagnostics.csproj @@ -34,7 +34,7 @@ - + NETSTANDARD2_1_OR_GREATER @@ -42,6 +42,18 @@ + + + + System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute; + System.Diagnostics.CodeAnalysis.DoesNotReturnIfAttribute; + System.Diagnostics.CodeAnalysis.NotNullAttribute; + System.Diagnostics.StackTraceHiddenAttribute; + System.Runtime.CompilerServices.CallerArgumentExpressionAttribute; + System.Runtime.CompilerServices.SkipLocalsInitAttribute; + + + TextTemplatingFileGenerator diff --git a/src/CommunityToolkit.HighPerformance/Attributes/NotNullAttribute.cs b/src/CommunityToolkit.HighPerformance/Attributes/NotNullAttribute.cs deleted file mode 100644 index af849ab3..00000000 --- a/src/CommunityToolkit.HighPerformance/Attributes/NotNullAttribute.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#if !NETSTANDARD2_1_OR_GREATER - -namespace System.Diagnostics.CodeAnalysis; - -/// -/// Specifies that an output will not be even if the corresponding type allows it. -/// Specifies that an input argument was not when the call returns. -/// -/// Internal copy from the BCL attribute. -[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue)] -internal sealed class NotNullAttribute : Attribute -{ -} - -#endif \ No newline at end of file diff --git a/src/CommunityToolkit.HighPerformance/Attributes/NotNullWhenAttribute.cs b/src/CommunityToolkit.HighPerformance/Attributes/NotNullWhenAttribute.cs deleted file mode 100644 index 4d427eb6..00000000 --- a/src/CommunityToolkit.HighPerformance/Attributes/NotNullWhenAttribute.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#if !NETSTANDARD2_1_OR_GREATER - -namespace System.Diagnostics.CodeAnalysis; - -/// -/// Specifies that when a method returns , the parameter -/// will not be null even if the corresponding type allows it. -/// -/// Internal copy of the .NET Standard 2.1 attribute. -[AttributeUsage(AttributeTargets.Parameter)] -internal sealed class NotNullWhenAttribute : Attribute -{ - /// - /// Initializes a new instance of the class. - /// - /// - /// The return value condition. If the method returns this value, - /// the associated parameter will not be . - /// - public NotNullWhenAttribute(bool returnValue) - { - ReturnValue = returnValue; - } - - /// - /// Gets a value indicating whether the return value should be . - /// - public bool ReturnValue { get; } -} - -#endif \ No newline at end of file diff --git a/src/CommunityToolkit.HighPerformance/Attributes/SkipLocalsInitAttribute.cs b/src/CommunityToolkit.HighPerformance/Attributes/SkipLocalsInitAttribute.cs deleted file mode 100644 index fcad3701..00000000 --- a/src/CommunityToolkit.HighPerformance/Attributes/SkipLocalsInitAttribute.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#if !NET6_0_OR_GREATER - -namespace System.Runtime.CompilerServices; - -/// -/// Used to indicate to the compiler that the .locals init flag should not be set in method headers. -/// -/// Internal copy of the .NET 5 attribute. -[AttributeUsage( - AttributeTargets.Module | - AttributeTargets.Class | - AttributeTargets.Struct | - AttributeTargets.Interface | - AttributeTargets.Constructor | - AttributeTargets.Method | - AttributeTargets.Property | - AttributeTargets.Event, - Inherited = false)] -internal sealed class SkipLocalsInitAttribute : Attribute -{ -} - -#endif \ No newline at end of file diff --git a/src/CommunityToolkit.HighPerformance/CommunityToolkit.HighPerformance.csproj b/src/CommunityToolkit.HighPerformance/CommunityToolkit.HighPerformance.csproj index 8ea177dd..782d99a5 100644 --- a/src/CommunityToolkit.HighPerformance/CommunityToolkit.HighPerformance.csproj +++ b/src/CommunityToolkit.HighPerformance/CommunityToolkit.HighPerformance.csproj @@ -54,4 +54,13 @@ + + + + System.Diagnostics.CodeAnalysis.NotNullAttribute; + System.Diagnostics.CodeAnalysis.NotNullWhenAttribute; + System.Runtime.CompilerServices.SkipLocalsInitAttribute; + + + \ No newline at end of file diff --git a/src/CommunityToolkit.Mvvm.SourceGenerators/Attributes/NotNullWhenAttribute.cs b/src/CommunityToolkit.Mvvm.SourceGenerators/Attributes/NotNullWhenAttribute.cs deleted file mode 100644 index acb9c585..00000000 --- a/src/CommunityToolkit.Mvvm.SourceGenerators/Attributes/NotNullWhenAttribute.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace System.Diagnostics.CodeAnalysis; - -/// Specifies that when a method returns , the parameter will not be null even if the corresponding type allows it. -[AttributeUsage(AttributeTargets.Parameter, Inherited = false)] -internal sealed class NotNullWhenAttribute : Attribute -{ - /// - /// Initializes a new instance of the class. - /// - /// The return value condition. If the method returns this value, the associated parameter will not be null. - public NotNullWhenAttribute(bool returnValue) - { - ReturnValue = returnValue; - } - - /// - /// Gets a value indicating whether the annotated parameter will be null depending on the return value. - /// - public bool ReturnValue { get; } -} diff --git a/src/CommunityToolkit.Mvvm.SourceGenerators/Attributes/SkipLocalsInitAttribute.cs b/src/CommunityToolkit.Mvvm.SourceGenerators/Attributes/SkipLocalsInitAttribute.cs deleted file mode 100644 index a05d197d..00000000 --- a/src/CommunityToolkit.Mvvm.SourceGenerators/Attributes/SkipLocalsInitAttribute.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#if !NET6_0_OR_GREATER - -namespace System.Runtime.CompilerServices; - -/// -/// Used to indicate to the compiler that the .locals init flag should not be set in method headers. -/// -/// Internal copy from the BCL attribute. -[AttributeUsage( - AttributeTargets.Module | - AttributeTargets.Class | - AttributeTargets.Struct | - AttributeTargets.Interface | - AttributeTargets.Constructor | - AttributeTargets.Method | - AttributeTargets.Property | - AttributeTargets.Event, - Inherited = false)] -internal sealed class SkipLocalsInitAttribute : Attribute -{ -} - -#endif \ No newline at end of file diff --git a/src/CommunityToolkit.Mvvm.SourceGenerators/CommunityToolkit.Mvvm.SourceGenerators.projitems b/src/CommunityToolkit.Mvvm.SourceGenerators/CommunityToolkit.Mvvm.SourceGenerators.projitems index a3409ee1..8b524d24 100644 --- a/src/CommunityToolkit.Mvvm.SourceGenerators/CommunityToolkit.Mvvm.SourceGenerators.projitems +++ b/src/CommunityToolkit.Mvvm.SourceGenerators/CommunityToolkit.Mvvm.SourceGenerators.projitems @@ -31,9 +31,7 @@ - - @@ -84,7 +82,6 @@ - diff --git a/src/CommunityToolkit.Mvvm.SourceGenerators/System.Runtime.CompilerServices/IsExternalInit.cs b/src/CommunityToolkit.Mvvm.SourceGenerators/System.Runtime.CompilerServices/IsExternalInit.cs deleted file mode 100644 index 0160c8ef..00000000 --- a/src/CommunityToolkit.Mvvm.SourceGenerators/System.Runtime.CompilerServices/IsExternalInit.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.ComponentModel; - -namespace System.Runtime.CompilerServices; - -/// -/// Reserved to be used by the compiler for tracking metadata. -/// This class should not be used by developers in source code. -/// -[EditorBrowsable(EditorBrowsableState.Never)] -internal static class IsExternalInit -{ -} diff --git a/src/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.csproj b/src/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.csproj index b488517d..db4bdfbd 100644 --- a/src/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.csproj +++ b/src/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.csproj @@ -40,6 +40,23 @@ + + + + System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute; + System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute; + System.Diagnostics.CodeAnalysis.MemberNotNullAttribute; + System.Diagnostics.CodeAnalysis.NotNullAttribute; + System.Diagnostics.CodeAnalysis.NotNullIfNotNullAttribute; + System.Diagnostics.CodeAnalysis.NotNullWhenAttribute; + System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute; + System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute; + System.Runtime.CompilerServices.CallerArgumentExpressionAttribute; + System.Runtime.CompilerServices.IsExternalInit; + System.Runtime.CompilerServices.SkipLocalsInitAttribute; + + + diff --git a/src/CommunityToolkit.Mvvm/Properties/Polyfills/Attributes/CallerArgumentExpressionAttribute.cs b/src/CommunityToolkit.Mvvm/Properties/Polyfills/Attributes/CallerArgumentExpressionAttribute.cs deleted file mode 100644 index 09d876cc..00000000 --- a/src/CommunityToolkit.Mvvm/Properties/Polyfills/Attributes/CallerArgumentExpressionAttribute.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#if !NET6_0_OR_GREATER - -namespace System.Runtime.CompilerServices; - -/// -/// An attribute that allows parameters to receive the expression of other parameters. -/// -/// Internal copy from the BCL attribute. -[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] -internal sealed class CallerArgumentExpressionAttribute : Attribute -{ - /// - /// Initializes a new instance of the class. - /// - /// The condition parameter value. - public CallerArgumentExpressionAttribute(string parameterName) - { - ParameterName = parameterName; - } - - /// - /// Gets the parameter name the expression is retrieved from. - /// - public string ParameterName { get; } -} - -#endif \ No newline at end of file diff --git a/src/CommunityToolkit.Mvvm/Properties/Polyfills/Attributes/DoesNotReturnAttribute.cs b/src/CommunityToolkit.Mvvm/Properties/Polyfills/Attributes/DoesNotReturnAttribute.cs deleted file mode 100644 index 9f6aadb5..00000000 --- a/src/CommunityToolkit.Mvvm/Properties/Polyfills/Attributes/DoesNotReturnAttribute.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#if NETSTANDARD2_0 - -namespace System.Diagnostics.CodeAnalysis; - -/// -/// Applied to a method that will never return under any circumstance. -/// -/// Internal copy from the BCL attribute. -[AttributeUsage(AttributeTargets.Method, Inherited = false)] -internal sealed class DoesNotReturnAttribute : Attribute -{ -} - -#endif \ No newline at end of file diff --git a/src/CommunityToolkit.Mvvm/Properties/Polyfills/Attributes/MaybeNullWhenAttribute.cs b/src/CommunityToolkit.Mvvm/Properties/Polyfills/Attributes/MaybeNullWhenAttribute.cs deleted file mode 100644 index f7ce3fb5..00000000 --- a/src/CommunityToolkit.Mvvm/Properties/Polyfills/Attributes/MaybeNullWhenAttribute.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#if NETSTANDARD2_0 - -namespace System.Diagnostics.CodeAnalysis; - -/// -/// Specifies that when a method returns , the parameter may be null even if the corresponding type disallows it. -/// -/// Internal copy from the BCL attribute. -[AttributeUsage(AttributeTargets.Parameter, Inherited = false)] -internal sealed class MaybeNullWhenAttribute : Attribute -{ - /// - /// Initializes the attribute with the specified return value condition. - /// - /// The return value condition. If the method returns this value, the associated parameter may be null. - public MaybeNullWhenAttribute(bool returnValue) - { - ReturnValue = returnValue; - } - - /// - /// Gets the return value condition. - /// - public bool ReturnValue { get; } -} - -#endif \ No newline at end of file diff --git a/src/CommunityToolkit.Mvvm/Properties/Polyfills/Attributes/MemberNotNullAttribute.cs b/src/CommunityToolkit.Mvvm/Properties/Polyfills/Attributes/MemberNotNullAttribute.cs deleted file mode 100644 index 457996db..00000000 --- a/src/CommunityToolkit.Mvvm/Properties/Polyfills/Attributes/MemberNotNullAttribute.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#if !NET6_0_OR_GREATER - -namespace System.Diagnostics.CodeAnalysis; - -/// -/// Specifies that the method or property will ensure that the listed field and property members have not-null values. -/// -/// Internal copy from the BCL attribute. -[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)] -internal sealed class MemberNotNullAttribute : Attribute -{ - /// - /// Initializes the attribute with a field or property member. - /// - /// The field or property member that is promised to be not-null. - public MemberNotNullAttribute(string member) - { - Members = new[] { member }; - } - - /// - /// Initializes the attribute with the list of field and property members. - /// - /// The list of field and property members that are promised to be not-null. - public MemberNotNullAttribute(params string[] members) - { - Members = members; - } - - /// - /// Gets field or property member names. - /// - public string[] Members { get; } -} - -#endif \ No newline at end of file diff --git a/src/CommunityToolkit.Mvvm/Properties/Polyfills/Attributes/NotNullAttribute.cs b/src/CommunityToolkit.Mvvm/Properties/Polyfills/Attributes/NotNullAttribute.cs deleted file mode 100644 index 87cec39b..00000000 --- a/src/CommunityToolkit.Mvvm/Properties/Polyfills/Attributes/NotNullAttribute.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#if NETSTANDARD2_0 - -namespace System.Diagnostics.CodeAnalysis; - -/// -/// Specifies that an output will not be null even if the corresponding type allows it. -/// Specifies that an input argument was not null when the call returns. -/// -/// Internal copy from the BCL attribute. -[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue, Inherited = false)] -internal sealed class NotNullAttribute : Attribute -{ -} - -#endif \ No newline at end of file diff --git a/src/CommunityToolkit.Mvvm/Properties/Polyfills/Attributes/NotNullIfNotNullAttribute.cs b/src/CommunityToolkit.Mvvm/Properties/Polyfills/Attributes/NotNullIfNotNullAttribute.cs deleted file mode 100644 index 09888a51..00000000 --- a/src/CommunityToolkit.Mvvm/Properties/Polyfills/Attributes/NotNullIfNotNullAttribute.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#if NETSTANDARD2_0 - -namespace System.Diagnostics.CodeAnalysis; - -/// -/// Specifies that the output will be non-null if the named parameter is non-null. -/// -/// Internal copy from the BCL attribute. -[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)] -internal sealed class NotNullIfNotNullAttribute : Attribute -{ - /// - /// Initializes a new instance of the class. - /// - /// The associated parameter name. The output will be non-null if the argument to the parameter specified is non-null. - public NotNullIfNotNullAttribute(string parameterName) => ParameterName = parameterName; - - /// Gets the associated parameter name. - public string ParameterName { get; } -} - -#endif \ No newline at end of file diff --git a/src/CommunityToolkit.Mvvm/Properties/Polyfills/Attributes/NotNullWhenAttribute.cs b/src/CommunityToolkit.Mvvm/Properties/Polyfills/Attributes/NotNullWhenAttribute.cs deleted file mode 100644 index a8b03f86..00000000 --- a/src/CommunityToolkit.Mvvm/Properties/Polyfills/Attributes/NotNullWhenAttribute.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#if NETSTANDARD2_0 - -namespace System.Diagnostics.CodeAnalysis; - -/// -/// Specifies that when a method returns , the parameter will not be null even if the corresponding type allows it. -/// -/// Internal copy from the BCL attribute. -[AttributeUsage(AttributeTargets.Parameter, Inherited = false)] -internal sealed class NotNullWhenAttribute : Attribute -{ - /// - /// Initializes a new instance of the class. - /// - /// The return value condition. If the method returns this value, the associated parameter will not be null. - public NotNullWhenAttribute(bool returnValue) => ReturnValue = returnValue; - - /// - /// Gets a value indicating whether the annotated variable is not . - /// - public bool ReturnValue { get; } -} - -#endif \ No newline at end of file diff --git a/src/CommunityToolkit.Mvvm/Properties/Polyfills/Attributes/RequiresUnreferencedCodeAttribute.cs b/src/CommunityToolkit.Mvvm/Properties/Polyfills/Attributes/RequiresUnreferencedCodeAttribute.cs deleted file mode 100644 index 3b097406..00000000 --- a/src/CommunityToolkit.Mvvm/Properties/Polyfills/Attributes/RequiresUnreferencedCodeAttribute.cs +++ /dev/null @@ -1,37 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#if !NET6_0_OR_GREATER - -namespace System.Diagnostics.CodeAnalysis; - -/// -/// Indicates that the specified method requires dynamic access to code that is not referenced statically. -/// -[AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Class, Inherited = false)] -[Conditional("DEBUG")] -internal sealed class RequiresUnreferencedCodeAttribute : Attribute -{ - /// - /// Initializes a new instance of the class. - /// - /// A message that contains information about the usage of unreferenced code. - public RequiresUnreferencedCodeAttribute(string message) - { - Message = message; - } - - /// - /// Gets a message that contains information about the usage of unreferenced code. - /// - public string Message { get; } - - /// - /// Gets or sets an optional URL that contains more information about the method, - /// why it requires unreferenced code, and what options a consumer has to deal with it. - /// - public string? Url { get; set; } -} - -#endif \ No newline at end of file diff --git a/src/CommunityToolkit.Mvvm/Properties/Polyfills/Attributes/SkipLocalsInitAttribute.cs b/src/CommunityToolkit.Mvvm/Properties/Polyfills/Attributes/SkipLocalsInitAttribute.cs deleted file mode 100644 index a05d197d..00000000 --- a/src/CommunityToolkit.Mvvm/Properties/Polyfills/Attributes/SkipLocalsInitAttribute.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#if !NET6_0_OR_GREATER - -namespace System.Runtime.CompilerServices; - -/// -/// Used to indicate to the compiler that the .locals init flag should not be set in method headers. -/// -/// Internal copy from the BCL attribute. -[AttributeUsage( - AttributeTargets.Module | - AttributeTargets.Class | - AttributeTargets.Struct | - AttributeTargets.Interface | - AttributeTargets.Constructor | - AttributeTargets.Method | - AttributeTargets.Property | - AttributeTargets.Event, - Inherited = false)] -internal sealed class SkipLocalsInitAttribute : Attribute -{ -} - -#endif \ No newline at end of file diff --git a/src/CommunityToolkit.Mvvm/Properties/Polyfills/Attributes/UnconditionalSuppressMessageAttribute.cs b/src/CommunityToolkit.Mvvm/Properties/Polyfills/Attributes/UnconditionalSuppressMessageAttribute.cs deleted file mode 100644 index 15ac1137..00000000 --- a/src/CommunityToolkit.Mvvm/Properties/Polyfills/Attributes/UnconditionalSuppressMessageAttribute.cs +++ /dev/null @@ -1,90 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#if !NET6_0_OR_GREATER - -namespace System.Diagnostics.CodeAnalysis; - -/// -/// Suppresses reporting of a specific rule violation, allowing multiple suppressions on a -/// single code artifact. -/// -/// -/// is different than -/// in that it doesn't have a -/// . So it is always preserved in the compiled assembly. -/// -[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)] -[Conditional("DEBUG")] -internal sealed class UnconditionalSuppressMessageAttribute : Attribute -{ - /// - /// Initializes a new instance of the - /// class, specifying the category of the tool and the identifier for an analysis rule. - /// - /// The category for the attribute. - /// The identifier of the analysis rule the attribute applies to. - public UnconditionalSuppressMessageAttribute(string category, string checkId) - { - Category = category; - CheckId = checkId; - } - - /// - /// Gets the category identifying the classification of the attribute. - /// - /// - /// The property describes the tool or tool analysis category - /// for which a message suppression attribute applies. - /// - public string Category { get; } - - /// - /// Gets the identifier of the analysis tool rule to be suppressed. - /// - /// - /// Concatenated together, the and - /// properties form a unique check identifier. - /// - public string CheckId { get; } - - /// - /// Gets or sets the scope of the code that is relevant for the attribute. - /// - /// - /// The Scope property is an optional argument that specifies the metadata scope for which - /// the attribute is relevant. - /// - public string? Scope { get; set; } - - /// - /// Gets or sets a fully qualified path that represents the target of the attribute. - /// - /// - /// The property is an optional argument identifying the analysis target - /// of the attribute. An example value is "System.IO.Stream.ctor():System.Void". - /// Because it is fully qualified, it can be long, particularly for targets such as parameters. - /// The analysis tool user interface should be capable of automatically formatting the parameter. - /// - public string? Target { get; set; } - - /// - /// Gets or sets an optional argument expanding on exclusion criteria. - /// - /// - /// The property is an optional argument that specifies additional - /// exclusion where the literal metadata target is not sufficiently precise. For example, - /// the cannot be applied within a method, - /// and it may be desirable to suppress a violation against a statement in the method that will - /// give a rule violation, but not against all statements in the method. - /// - public string? MessageId { get; set; } - - /// - /// Gets or sets the justification for suppressing the code analysis message. - /// - public string? Justification { get; set; } -} - -#endif \ No newline at end of file diff --git a/src/CommunityToolkit.Mvvm/Properties/Polyfills/System.Runtime.CompilerServices/IsExternalInit.cs b/src/CommunityToolkit.Mvvm/Properties/Polyfills/System.Runtime.CompilerServices/IsExternalInit.cs deleted file mode 100644 index 2b7b72e8..00000000 --- a/src/CommunityToolkit.Mvvm/Properties/Polyfills/System.Runtime.CompilerServices/IsExternalInit.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#if !NET6_0_OR_GREATER - -using System.ComponentModel; - -namespace System.Runtime.CompilerServices; - -/// -/// Reserved to be used by the compiler for tracking metadata. -/// This class should not be used by developers in source code. -/// -[EditorBrowsable(EditorBrowsableState.Never)] -internal static class IsExternalInit -{ -} - -#endif diff --git a/src/Directory.Build.props b/src/Directory.Build.props new file mode 100644 index 00000000..f3c2112a --- /dev/null +++ b/src/Directory.Build.props @@ -0,0 +1,11 @@ + + + + + + + all + build; analyzers + + + \ No newline at end of file From 17fc0daf2d6501b37b8177f6a68dd65f15b7fd7a Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 22 Nov 2022 16:33:47 +0100 Subject: [PATCH 3/5] Move [InternalsVisibleTo] to .csproj files --- build/Community.Toolkit.Common.props | 1 + .../CommunityToolkit.HighPerformance.csproj | 5 +++++ .../Properties/AssemblyInfo.cs | 10 ---------- src/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.csproj | 5 +++++ src/CommunityToolkit.Mvvm/Properties/AssemblyInfo.cs | 7 ------- 5 files changed, 11 insertions(+), 17 deletions(-) delete mode 100644 src/CommunityToolkit.HighPerformance/Properties/AssemblyInfo.cs delete mode 100644 src/CommunityToolkit.Mvvm/Properties/AssemblyInfo.cs diff --git a/build/Community.Toolkit.Common.props b/build/Community.Toolkit.Common.props index 1775ea7d..22411974 100644 --- a/build/Community.Toolkit.Common.props +++ b/build/Community.Toolkit.Common.props @@ -27,6 +27,7 @@ true $(RepositoryDirectory)toolkit.snk + 002400000480000094000000060200000024000052534131000400000100010041753AF735AE6140C9508567666C51C6AB929806ADB0D210694B30AB142A060237BC741F9682E7D8D4310364B4BBA4EE89CC9D3D5CE7E5583587E8EA44DCA09977996582875E71FB54FA7B170798D853D5D8010B07219633BDB761D01AC924DA44576D6180CDCEAE537973982BB461C541541D58417A3794E34F45E6F2D129E2 diff --git a/src/CommunityToolkit.HighPerformance/CommunityToolkit.HighPerformance.csproj b/src/CommunityToolkit.HighPerformance/CommunityToolkit.HighPerformance.csproj index 782d99a5..2f4b00bf 100644 --- a/src/CommunityToolkit.HighPerformance/CommunityToolkit.HighPerformance.csproj +++ b/src/CommunityToolkit.HighPerformance/CommunityToolkit.HighPerformance.csproj @@ -35,6 +35,11 @@ + + + + + diff --git a/src/CommunityToolkit.HighPerformance/Properties/AssemblyInfo.cs b/src/CommunityToolkit.HighPerformance/Properties/AssemblyInfo.cs deleted file mode 100644 index 25c38563..00000000 --- a/src/CommunityToolkit.HighPerformance/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,10 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#if !NETSTANDARD2_1_OR_GREATER -using System.Runtime.CompilerServices; - -// We need to test the RuntimeHelpers polyfills on applicable runtimes -[assembly: InternalsVisibleTo("CommunityToolkit.HighPerformance.UnitTests, publickey=002400000480000094000000060200000024000052534131000400000100010041753AF735AE6140C9508567666C51C6AB929806ADB0D210694B30AB142A060237BC741F9682E7D8D4310364B4BBA4EE89CC9D3D5CE7E5583587E8EA44DCA09977996582875E71FB54FA7B170798D853D5D8010B07219633BDB761D01AC924DA44576D6180CDCEAE537973982BB461C541541D58417A3794E34F45E6F2D129E2")] -#endif \ No newline at end of file diff --git a/src/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.csproj b/src/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.csproj index db4bdfbd..43adfb76 100644 --- a/src/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.csproj +++ b/src/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.csproj @@ -40,6 +40,11 @@ + + + + + diff --git a/src/CommunityToolkit.Mvvm/Properties/AssemblyInfo.cs b/src/CommunityToolkit.Mvvm/Properties/AssemblyInfo.cs deleted file mode 100644 index 69e10663..00000000 --- a/src/CommunityToolkit.Mvvm/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,7 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Runtime.CompilerServices; - -[assembly: InternalsVisibleTo("CommunityToolkit.Mvvm.Internals.UnitTests, PublicKey=002400000480000094000000060200000024000052534131000400000100010041753AF735AE6140C9508567666C51C6AB929806ADB0D210694B30AB142A060237BC741F9682E7D8D4310364B4BBA4EE89CC9D3D5CE7E5583587E8EA44DCA09977996582875E71FB54FA7B170798D853D5D8010B07219633BDB761D01AC924DA44576D6180CDCEAE537973982BB461C541541D58417A3794E34F45E6F2D129E2")] \ No newline at end of file From 9d9de23c44dcc4067145c7cfb98f428c5ae15564 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 22 Nov 2022 16:37:39 +0100 Subject: [PATCH 4/5] Move trimming properties to .targets file in src\ --- build/Community.Toolkit.Common.targets | 6 ------ src/Directory.Build.targets | 6 ++++++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build/Community.Toolkit.Common.targets b/build/Community.Toolkit.Common.targets index ffd77912..f34ab2ab 100644 --- a/build/Community.Toolkit.Common.targets +++ b/build/Community.Toolkit.Common.targets @@ -17,10 +17,4 @@ - - - true - true - - \ No newline at end of file diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets index 8cdc6115..94c099ce 100644 --- a/src/Directory.Build.targets +++ b/src/Directory.Build.targets @@ -2,6 +2,12 @@ + + + true + true + + - - NETSTANDARD2_1_OR_GREATER - - diff --git a/src/CommunityToolkit.Diagnostics/CommunityToolkit.Diagnostics.csproj b/src/CommunityToolkit.Diagnostics/CommunityToolkit.Diagnostics.csproj index 68867263..6cd510f1 100644 --- a/src/CommunityToolkit.Diagnostics/CommunityToolkit.Diagnostics.csproj +++ b/src/CommunityToolkit.Diagnostics/CommunityToolkit.Diagnostics.csproj @@ -15,31 +15,20 @@ - - + + + - - NETSTANDARD2_1_OR_GREATER - - - - - - - - NETSTANDARD2_1_OR_GREATER - - diff --git a/src/CommunityToolkit.HighPerformance/CommunityToolkit.HighPerformance.csproj b/src/CommunityToolkit.HighPerformance/CommunityToolkit.HighPerformance.csproj index 2f4b00bf..1639b330 100644 --- a/src/CommunityToolkit.HighPerformance/CommunityToolkit.HighPerformance.csproj +++ b/src/CommunityToolkit.HighPerformance/CommunityToolkit.HighPerformance.csproj @@ -42,21 +42,12 @@ + - - - - - - - - NETSTANDARD2_1_OR_GREATER - - diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets index 94c099ce..36dde4ce 100644 --- a/src/Directory.Build.targets +++ b/src/Directory.Build.targets @@ -2,6 +2,11 @@ + + + NETSTANDARD2_1_OR_GREATER + + true