diff --git a/Src/FluentAssertions/AssertionExtensions.cs b/Src/FluentAssertions/AssertionExtensions.cs index d2ed6822d9..d4f4274992 100644 --- a/Src/FluentAssertions/AssertionExtensions.cs +++ b/Src/FluentAssertions/AssertionExtensions.cs @@ -13,7 +13,6 @@ using FluentAssertions.Common; using FluentAssertions.Numeric; using FluentAssertions.Primitives; -using FluentAssertions.Reflection; using FluentAssertions.Specialized; using FluentAssertions.Streams; using FluentAssertions.Types; diff --git a/Src/FluentAssertions/FluentAssertions.csproj b/Src/FluentAssertions/FluentAssertions.csproj index c72f01136a..25c0f8ba2c 100644 --- a/Src/FluentAssertions/FluentAssertions.csproj +++ b/Src/FluentAssertions/FluentAssertions.csproj @@ -55,8 +55,6 @@ - - @@ -66,7 +64,6 @@ - diff --git a/Src/FluentAssertions/StringBuilderExtensions.cs b/Src/FluentAssertions/Polyfill/StringBuilderExtensions.cs similarity index 86% rename from Src/FluentAssertions/StringBuilderExtensions.cs rename to Src/FluentAssertions/Polyfill/StringBuilderExtensions.cs index 3c20ee549e..bfe221227c 100644 --- a/Src/FluentAssertions/StringBuilderExtensions.cs +++ b/Src/FluentAssertions/Polyfill/StringBuilderExtensions.cs @@ -1,5 +1,8 @@ -using System.Collections.Generic; +#if NET47 || NETSTANDARD2_0 || NETSTANDARD2_1 +using System.Collections.Generic; + +// ReSharper disable once CheckNamespace namespace System.Text; /// @@ -13,8 +16,8 @@ internal static class StringBuilderExtensions public static StringBuilder AppendLine(this StringBuilder stringBuilder, IFormatProvider _, string value) => stringBuilder.AppendLine(value); -#if NET47 || NETSTANDARD2_0 public static StringBuilder AppendJoin(this StringBuilder stringBuilder, string separator, IEnumerable values) => stringBuilder.Append(string.Join(separator, values)); -#endif } + +#endif diff --git a/Src/FluentAssertions/SystemExtensions.cs b/Src/FluentAssertions/Polyfill/SystemExtensions.cs similarity index 92% rename from Src/FluentAssertions/SystemExtensions.cs rename to Src/FluentAssertions/Polyfill/SystemExtensions.cs index 9594e97654..88a5af634d 100644 --- a/Src/FluentAssertions/SystemExtensions.cs +++ b/Src/FluentAssertions/Polyfill/SystemExtensions.cs @@ -1,4 +1,7 @@ -namespace System; +#if NET47 || NETSTANDARD2_0 + +// ReSharper disable once CheckNamespace +namespace System; internal static class SystemExtensions { @@ -21,3 +24,5 @@ public static bool Contains(this string str, char value, StringComparison compar public static bool StartsWith(this string str, char value) => str.Length != 0 && str[0] == value; } + +#endif diff --git a/Src/FluentAssertions/Specialized/AssemblyAssertions.cs b/Src/FluentAssertions/Types/AssemblyAssertions.cs similarity index 99% rename from Src/FluentAssertions/Specialized/AssemblyAssertions.cs rename to Src/FluentAssertions/Types/AssemblyAssertions.cs index 646ce0827b..fbe8a5a23f 100644 --- a/Src/FluentAssertions/Specialized/AssemblyAssertions.cs +++ b/Src/FluentAssertions/Types/AssemblyAssertions.cs @@ -6,7 +6,7 @@ using FluentAssertions.Execution; using FluentAssertions.Primitives; -namespace FluentAssertions.Reflection; +namespace FluentAssertions.Types; /// /// Contains a number of methods to assert that an is in the expected state. diff --git a/Src/FluentAssertions/Xml/XmlAssertionExtensions.cs b/Src/FluentAssertions/XmlAssertionExtensions.cs similarity index 100% rename from Src/FluentAssertions/Xml/XmlAssertionExtensions.cs rename to Src/FluentAssertions/XmlAssertionExtensions.cs diff --git a/Tests/Approval.Tests/ApprovedApi/FluentAssertions/net47.verified.txt b/Tests/Approval.Tests/ApprovedApi/FluentAssertions/net47.verified.txt index 71fa616938..2a748c2802 100644 --- a/Tests/Approval.Tests/ApprovedApi/FluentAssertions/net47.verified.txt +++ b/Tests/Approval.Tests/ApprovedApi/FluentAssertions/net47.verified.txt @@ -69,7 +69,7 @@ namespace FluentAssertions public static FluentAssertions.Streams.BufferedStreamAssertions Should(this System.IO.BufferedStream actualValue) { } public static FluentAssertions.Streams.StreamAssertions Should(this System.IO.Stream actualValue) { } public static FluentAssertions.Primitives.HttpResponseMessageAssertions Should(this System.Net.Http.HttpResponseMessage actualValue) { } - public static FluentAssertions.Reflection.AssemblyAssertions Should(this System.Reflection.Assembly assembly) { } + public static FluentAssertions.Types.AssemblyAssertions Should(this System.Reflection.Assembly assembly) { } public static FluentAssertions.Types.ConstructorInfoAssertions Should(this System.Reflection.ConstructorInfo constructorInfo) { } public static FluentAssertions.Types.MethodInfoAssertions Should(this System.Reflection.MethodInfo methodInfo) { } public static FluentAssertions.Types.PropertyInfoAssertions Should(this System.Reflection.PropertyInfo propertyInfo) { } @@ -2080,19 +2080,6 @@ namespace FluentAssertions.Primitives LessThan = 4, } } -namespace FluentAssertions.Reflection -{ - public class AssemblyAssertions : FluentAssertions.Primitives.ReferenceTypeAssertions - { - public AssemblyAssertions(System.Reflection.Assembly assembly) { } - protected override string Identifier { get; } - public FluentAssertions.AndConstraint BeSignedWithPublicKey(string publicKey, string because = "", params object[] becauseArgs) { } - public FluentAssertions.AndConstraint BeUnsigned(string because = "", params object[] becauseArgs) { } - public FluentAssertions.AndWhichConstraint DefineType(string @namespace, string name, string because = "", params object[] becauseArgs) { } - public FluentAssertions.AndConstraint NotReference(System.Reflection.Assembly assembly, string because = "", params object[] becauseArgs) { } - public FluentAssertions.AndConstraint Reference(System.Reflection.Assembly assembly, string because = "", params object[] becauseArgs) { } - } -} namespace FluentAssertions.Specialized { public class ActionAssertions : FluentAssertions.Specialized.DelegateAssertions @@ -2267,6 +2254,16 @@ namespace FluentAssertions.Types { public static FluentAssertions.Types.TypeSelector From(System.Reflection.Assembly assembly) { } } + public class AssemblyAssertions : FluentAssertions.Primitives.ReferenceTypeAssertions + { + public AssemblyAssertions(System.Reflection.Assembly assembly) { } + protected override string Identifier { get; } + public FluentAssertions.AndConstraint BeSignedWithPublicKey(string publicKey, string because = "", params object[] becauseArgs) { } + public FluentAssertions.AndConstraint BeUnsigned(string because = "", params object[] becauseArgs) { } + public FluentAssertions.AndWhichConstraint DefineType(string @namespace, string name, string because = "", params object[] becauseArgs) { } + public FluentAssertions.AndConstraint NotReference(System.Reflection.Assembly assembly, string because = "", params object[] becauseArgs) { } + public FluentAssertions.AndConstraint Reference(System.Reflection.Assembly assembly, string because = "", params object[] becauseArgs) { } + } public class ConstructorInfoAssertions : FluentAssertions.Types.MethodBaseAssertions { public ConstructorInfoAssertions(System.Reflection.ConstructorInfo constructorInfo) { } diff --git a/Tests/Approval.Tests/ApprovedApi/FluentAssertions/net6.0.verified.txt b/Tests/Approval.Tests/ApprovedApi/FluentAssertions/net6.0.verified.txt index 6d29bd1c3a..b02a826b01 100644 --- a/Tests/Approval.Tests/ApprovedApi/FluentAssertions/net6.0.verified.txt +++ b/Tests/Approval.Tests/ApprovedApi/FluentAssertions/net6.0.verified.txt @@ -71,7 +71,7 @@ namespace FluentAssertions public static FluentAssertions.Streams.BufferedStreamAssertions Should(this System.IO.BufferedStream actualValue) { } public static FluentAssertions.Streams.StreamAssertions Should(this System.IO.Stream actualValue) { } public static FluentAssertions.Primitives.HttpResponseMessageAssertions Should(this System.Net.Http.HttpResponseMessage actualValue) { } - public static FluentAssertions.Reflection.AssemblyAssertions Should(this System.Reflection.Assembly assembly) { } + public static FluentAssertions.Types.AssemblyAssertions Should(this System.Reflection.Assembly assembly) { } public static FluentAssertions.Types.ConstructorInfoAssertions Should(this System.Reflection.ConstructorInfo constructorInfo) { } public static FluentAssertions.Types.MethodInfoAssertions Should(this System.Reflection.MethodInfo methodInfo) { } public static FluentAssertions.Types.PropertyInfoAssertions Should(this System.Reflection.PropertyInfo propertyInfo) { } @@ -2201,19 +2201,6 @@ namespace FluentAssertions.Primitives LessThan = 4, } } -namespace FluentAssertions.Reflection -{ - public class AssemblyAssertions : FluentAssertions.Primitives.ReferenceTypeAssertions - { - public AssemblyAssertions(System.Reflection.Assembly assembly) { } - protected override string Identifier { get; } - public FluentAssertions.AndConstraint BeSignedWithPublicKey(string publicKey, string because = "", params object[] becauseArgs) { } - public FluentAssertions.AndConstraint BeUnsigned(string because = "", params object[] becauseArgs) { } - public FluentAssertions.AndWhichConstraint DefineType(string @namespace, string name, string because = "", params object[] becauseArgs) { } - public FluentAssertions.AndConstraint NotReference(System.Reflection.Assembly assembly, string because = "", params object[] becauseArgs) { } - public FluentAssertions.AndConstraint Reference(System.Reflection.Assembly assembly, string because = "", params object[] becauseArgs) { } - } -} namespace FluentAssertions.Specialized { public class ActionAssertions : FluentAssertions.Specialized.DelegateAssertions @@ -2397,6 +2384,16 @@ namespace FluentAssertions.Types { public static FluentAssertions.Types.TypeSelector From(System.Reflection.Assembly assembly) { } } + public class AssemblyAssertions : FluentAssertions.Primitives.ReferenceTypeAssertions + { + public AssemblyAssertions(System.Reflection.Assembly assembly) { } + protected override string Identifier { get; } + public FluentAssertions.AndConstraint BeSignedWithPublicKey(string publicKey, string because = "", params object[] becauseArgs) { } + public FluentAssertions.AndConstraint BeUnsigned(string because = "", params object[] becauseArgs) { } + public FluentAssertions.AndWhichConstraint DefineType(string @namespace, string name, string because = "", params object[] becauseArgs) { } + public FluentAssertions.AndConstraint NotReference(System.Reflection.Assembly assembly, string because = "", params object[] becauseArgs) { } + public FluentAssertions.AndConstraint Reference(System.Reflection.Assembly assembly, string because = "", params object[] becauseArgs) { } + } public class ConstructorInfoAssertions : FluentAssertions.Types.MethodBaseAssertions { public ConstructorInfoAssertions(System.Reflection.ConstructorInfo constructorInfo) { } diff --git a/Tests/Approval.Tests/ApprovedApi/FluentAssertions/netstandard2.0.verified.txt b/Tests/Approval.Tests/ApprovedApi/FluentAssertions/netstandard2.0.verified.txt index c39d7e7f89..95f6afb050 100644 --- a/Tests/Approval.Tests/ApprovedApi/FluentAssertions/netstandard2.0.verified.txt +++ b/Tests/Approval.Tests/ApprovedApi/FluentAssertions/netstandard2.0.verified.txt @@ -68,7 +68,7 @@ namespace FluentAssertions public static FluentAssertions.Streams.BufferedStreamAssertions Should(this System.IO.BufferedStream actualValue) { } public static FluentAssertions.Streams.StreamAssertions Should(this System.IO.Stream actualValue) { } public static FluentAssertions.Primitives.HttpResponseMessageAssertions Should(this System.Net.Http.HttpResponseMessage actualValue) { } - public static FluentAssertions.Reflection.AssemblyAssertions Should(this System.Reflection.Assembly assembly) { } + public static FluentAssertions.Types.AssemblyAssertions Should(this System.Reflection.Assembly assembly) { } public static FluentAssertions.Types.ConstructorInfoAssertions Should(this System.Reflection.ConstructorInfo constructorInfo) { } public static FluentAssertions.Types.MethodInfoAssertions Should(this System.Reflection.MethodInfo methodInfo) { } public static FluentAssertions.Types.PropertyInfoAssertions Should(this System.Reflection.PropertyInfo propertyInfo) { } @@ -2031,19 +2031,6 @@ namespace FluentAssertions.Primitives LessThan = 4, } } -namespace FluentAssertions.Reflection -{ - public class AssemblyAssertions : FluentAssertions.Primitives.ReferenceTypeAssertions - { - public AssemblyAssertions(System.Reflection.Assembly assembly) { } - protected override string Identifier { get; } - public FluentAssertions.AndConstraint BeSignedWithPublicKey(string publicKey, string because = "", params object[] becauseArgs) { } - public FluentAssertions.AndConstraint BeUnsigned(string because = "", params object[] becauseArgs) { } - public FluentAssertions.AndWhichConstraint DefineType(string @namespace, string name, string because = "", params object[] becauseArgs) { } - public FluentAssertions.AndConstraint NotReference(System.Reflection.Assembly assembly, string because = "", params object[] becauseArgs) { } - public FluentAssertions.AndConstraint Reference(System.Reflection.Assembly assembly, string because = "", params object[] becauseArgs) { } - } -} namespace FluentAssertions.Specialized { public class ActionAssertions : FluentAssertions.Specialized.DelegateAssertions @@ -2218,6 +2205,16 @@ namespace FluentAssertions.Types { public static FluentAssertions.Types.TypeSelector From(System.Reflection.Assembly assembly) { } } + public class AssemblyAssertions : FluentAssertions.Primitives.ReferenceTypeAssertions + { + public AssemblyAssertions(System.Reflection.Assembly assembly) { } + protected override string Identifier { get; } + public FluentAssertions.AndConstraint BeSignedWithPublicKey(string publicKey, string because = "", params object[] becauseArgs) { } + public FluentAssertions.AndConstraint BeUnsigned(string because = "", params object[] becauseArgs) { } + public FluentAssertions.AndWhichConstraint DefineType(string @namespace, string name, string because = "", params object[] becauseArgs) { } + public FluentAssertions.AndConstraint NotReference(System.Reflection.Assembly assembly, string because = "", params object[] becauseArgs) { } + public FluentAssertions.AndConstraint Reference(System.Reflection.Assembly assembly, string because = "", params object[] becauseArgs) { } + } public class ConstructorInfoAssertions : FluentAssertions.Types.MethodBaseAssertions { public ConstructorInfoAssertions(System.Reflection.ConstructorInfo constructorInfo) { } diff --git a/Tests/Approval.Tests/ApprovedApi/FluentAssertions/netstandard2.1.verified.txt b/Tests/Approval.Tests/ApprovedApi/FluentAssertions/netstandard2.1.verified.txt index 34e0f4b77d..9df7cf4d85 100644 --- a/Tests/Approval.Tests/ApprovedApi/FluentAssertions/netstandard2.1.verified.txt +++ b/Tests/Approval.Tests/ApprovedApi/FluentAssertions/netstandard2.1.verified.txt @@ -69,7 +69,7 @@ namespace FluentAssertions public static FluentAssertions.Streams.BufferedStreamAssertions Should(this System.IO.BufferedStream actualValue) { } public static FluentAssertions.Streams.StreamAssertions Should(this System.IO.Stream actualValue) { } public static FluentAssertions.Primitives.HttpResponseMessageAssertions Should(this System.Net.Http.HttpResponseMessage actualValue) { } - public static FluentAssertions.Reflection.AssemblyAssertions Should(this System.Reflection.Assembly assembly) { } + public static FluentAssertions.Types.AssemblyAssertions Should(this System.Reflection.Assembly assembly) { } public static FluentAssertions.Types.ConstructorInfoAssertions Should(this System.Reflection.ConstructorInfo constructorInfo) { } public static FluentAssertions.Types.MethodInfoAssertions Should(this System.Reflection.MethodInfo methodInfo) { } public static FluentAssertions.Types.PropertyInfoAssertions Should(this System.Reflection.PropertyInfo propertyInfo) { } @@ -2080,19 +2080,6 @@ namespace FluentAssertions.Primitives LessThan = 4, } } -namespace FluentAssertions.Reflection -{ - public class AssemblyAssertions : FluentAssertions.Primitives.ReferenceTypeAssertions - { - public AssemblyAssertions(System.Reflection.Assembly assembly) { } - protected override string Identifier { get; } - public FluentAssertions.AndConstraint BeSignedWithPublicKey(string publicKey, string because = "", params object[] becauseArgs) { } - public FluentAssertions.AndConstraint BeUnsigned(string because = "", params object[] becauseArgs) { } - public FluentAssertions.AndWhichConstraint DefineType(string @namespace, string name, string because = "", params object[] becauseArgs) { } - public FluentAssertions.AndConstraint NotReference(System.Reflection.Assembly assembly, string because = "", params object[] becauseArgs) { } - public FluentAssertions.AndConstraint Reference(System.Reflection.Assembly assembly, string because = "", params object[] becauseArgs) { } - } -} namespace FluentAssertions.Specialized { public class ActionAssertions : FluentAssertions.Specialized.DelegateAssertions @@ -2269,6 +2256,16 @@ namespace FluentAssertions.Types { public static FluentAssertions.Types.TypeSelector From(System.Reflection.Assembly assembly) { } } + public class AssemblyAssertions : FluentAssertions.Primitives.ReferenceTypeAssertions + { + public AssemblyAssertions(System.Reflection.Assembly assembly) { } + protected override string Identifier { get; } + public FluentAssertions.AndConstraint BeSignedWithPublicKey(string publicKey, string because = "", params object[] becauseArgs) { } + public FluentAssertions.AndConstraint BeUnsigned(string because = "", params object[] becauseArgs) { } + public FluentAssertions.AndWhichConstraint DefineType(string @namespace, string name, string because = "", params object[] becauseArgs) { } + public FluentAssertions.AndConstraint NotReference(System.Reflection.Assembly assembly, string because = "", params object[] becauseArgs) { } + public FluentAssertions.AndConstraint Reference(System.Reflection.Assembly assembly, string because = "", params object[] becauseArgs) { } + } public class ConstructorInfoAssertions : FluentAssertions.Types.MethodBaseAssertions { public ConstructorInfoAssertions(System.Reflection.ConstructorInfo constructorInfo) { } diff --git a/qodana.yaml b/qodana.yaml index caf1cfb08b..540010267c 100644 --- a/qodana.yaml +++ b/qodana.yaml @@ -26,3 +26,6 @@ exclude: - name: ConvertToLambdaExpression - name: SwitchExpressionHandlesSomeKnownEnumValuesWithExceptionInDefault - name: UnusedMemberInSuper.Global + - name: CheckNamespace + paths: + - Src\FluentAssertions\Polyfill