From 6c33d128c23a090f4a6cf46ce816b71b81b87506 Mon Sep 17 00:00:00 2001 From: Jonas Nyrup Date: Sun, 30 Oct 2022 22:22:01 +0100 Subject: [PATCH] Use PolySharp to generate polyfill attributes --- Build/Build.cs | 4 +- .../DoesNotReturnAttribute.cs | 17 ------- Src/FluentAssertions/FluentAssertions.csproj | 1 + Src/FluentAssertions/StringSyntaxAttribute.cs | 50 ------------------- 4 files changed, 2 insertions(+), 70 deletions(-) delete mode 100644 Src/FluentAssertions/DoesNotReturnAttribute.cs delete mode 100644 Src/FluentAssertions/StringSyntaxAttribute.cs diff --git a/Build/Build.cs b/Build/Build.cs index 12420110fd..7c2fb7b539 100644 --- a/Build/Build.cs +++ b/Build/Build.cs @@ -168,9 +168,7 @@ class Build : NukeBuild .SetTargetDirectory(TestResultsDirectory / "reports") .AddReports(TestResultsDirectory / "**/coverage.cobertura.xml") .AddReportTypes("HtmlInline_AzurePipelines_Dark", "lcov") - .SetClassFilters( - "-System.Diagnostics.CodeAnalysis.StringSyntaxAttribute", - "-System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute") + .AddFileFilters("-*.g.cs") .SetAssemblyFilters("+FluentAssertions")); string link = TestResultsDirectory / "reports" / "index.html"; diff --git a/Src/FluentAssertions/DoesNotReturnAttribute.cs b/Src/FluentAssertions/DoesNotReturnAttribute.cs deleted file mode 100644 index 9a5d558f29..0000000000 --- a/Src/FluentAssertions/DoesNotReturnAttribute.cs +++ /dev/null @@ -1,17 +0,0 @@ -// copied from https://source.dot.net/#System.Private.CoreLib/NullableAttributes.cs -#if !(NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_0_OR_GREATER) -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -namespace System.Diagnostics.CodeAnalysis; - -/// Applied to a method that will never return under any circumstance. -[AttributeUsage(AttributeTargets.Method, Inherited = false)] -#if SYSTEM_PRIVATE_CORELIB -public -#else -internal -#endif - sealed class DoesNotReturnAttribute : Attribute -{ -} -#endif diff --git a/Src/FluentAssertions/FluentAssertions.csproj b/Src/FluentAssertions/FluentAssertions.csproj index f1afb9908f..3d22813eb0 100644 --- a/Src/FluentAssertions/FluentAssertions.csproj +++ b/Src/FluentAssertions/FluentAssertions.csproj @@ -55,6 +55,7 @@ + diff --git a/Src/FluentAssertions/StringSyntaxAttribute.cs b/Src/FluentAssertions/StringSyntaxAttribute.cs deleted file mode 100644 index 8253978af5..0000000000 --- a/Src/FluentAssertions/StringSyntaxAttribute.cs +++ /dev/null @@ -1,50 +0,0 @@ -// copied from https://raw.githubusercontent.com/dotnet/runtime/main/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/StringSyntaxAttribute.cs -#if !NET7_0_OR_GREATER -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -#nullable enable - -namespace System.Diagnostics.CodeAnalysis; - -/// Specifies the syntax used in a string. -[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false, Inherited = false)] -#if SYSTEM_PRIVATE_CORELIB -public -#else -internal -#endif -sealed class StringSyntaxAttribute : Attribute -{ - /// Initializes the with the identifier of the syntax used. - /// The syntax identifier. - public StringSyntaxAttribute(string syntax) - { - Syntax = syntax; - Arguments = Array.Empty(); - } - - /// Initializes the with the identifier of the syntax used. - /// The syntax identifier. - /// Optional arguments associated with the specific syntax employed. - public StringSyntaxAttribute(string syntax, params object?[] arguments) - { - Syntax = syntax; - Arguments = arguments; - } - - /// Gets the identifier of the syntax used. - public string Syntax { get; } - - /// Optional arguments associated with the specific syntax employed. - public object?[] Arguments { get; } - - /// The syntax identifier for strings containing date and time format specifiers. - public const string DateTimeFormat = nameof(DateTimeFormat); - - /// The syntax identifier for strings containing JavaScript Object Notation (JSON). - public const string Json = nameof(Json); - - /// The syntax identifier for strings containing regular expressions. - public const string Regex = nameof(Regex); -} -#endif