diff --git a/.editorconfig b/.editorconfig index 26015fa746..53a89eb647 100644 --- a/.editorconfig +++ b/.editorconfig @@ -17,12 +17,106 @@ indent_size = 2 # Xml config files [*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}] indent_style = space -tab_width = 2 +indent_size = 2 [*.{md,json}] indent_style = space -tab_width = 4 +indent_size = 4 [*.cs] indent_style = space -tab_width = 4 +indent_size = 4 + +# New line preferences +csharp_new_line_before_open_brace = all +csharp_new_line_before_else = true +csharp_new_line_before_catch = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_object_initializers = true +csharp_new_line_before_members_in_anonymous_types = true +csharp_new_line_between_query_expression_clauses = true + +# Indentation preferences +csharp_indent_block_contents = true +csharp_indent_braces = false +csharp_indent_case_contents = true +csharp_indent_switch_labels = true +csharp_indent_labels = one_less_than_current + +# avoid this. unless absolutely necessary +dotnet_style_qualification_for_field = false:suggestion +dotnet_style_qualification_for_property = false:suggestion +dotnet_style_qualification_for_method = false:suggestion +dotnet_style_qualification_for_event = false:suggestion + +# only use var when it's obvious what the variable type is +csharp_style_var_for_built_in_types = false:none +csharp_style_var_when_type_is_apparent = false:none +csharp_style_var_elsewhere = false:suggestion + +# use language keywords instead of BCL types +dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion +dotnet_style_predefined_type_for_member_access = true:suggestion + +# name all constant fields using PascalCase +dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields +dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style + +dotnet_naming_symbols.constant_fields.applicable_kinds = field +dotnet_naming_symbols.constant_fields.required_modifiers = const + +dotnet_naming_style.pascal_case_style.capitalization = pascal_case + +# Code style defaults +dotnet_sort_system_directives_first = true +csharp_preserve_single_line_blocks = true +csharp_preserve_single_line_statements = false + +# Expression-level preferences +dotnet_style_object_initializer = true:suggestion +dotnet_style_collection_initializer = true:suggestion +dotnet_style_explicit_tuple_names = true:suggestion +dotnet_style_coalesce_expression = true:suggestion +dotnet_style_null_propagation = true:suggestion + +# Expression-bodied members +csharp_style_expression_bodied_methods = true:none +csharp_style_expression_bodied_constructors = false:none +csharp_style_expression_bodied_operators = false:none +csharp_style_expression_bodied_properties = true:none +csharp_style_expression_bodied_indexers = true:none +csharp_style_expression_bodied_accessors = true:none + +# Pattern matching +csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion +csharp_style_inlined_variable_declaration = true:suggestion + +# Null checking preferences +csharp_style_throw_expression = true:suggestion +csharp_style_conditional_delegate_call = true:suggestion + +# Space preferences +csharp_space_after_cast = false +csharp_space_after_colon_in_inheritance_clause = true +csharp_space_after_comma = true +csharp_space_after_dot = false +csharp_space_after_keywords_in_control_flow_statements = true +csharp_space_after_semicolon_in_for_statement = true +csharp_space_around_binary_operators = before_and_after +csharp_space_around_declaration_statements = do_not_ignore +csharp_space_before_colon_in_inheritance_clause = true +csharp_space_before_comma = false +csharp_space_before_dot = false +csharp_space_before_open_square_brackets = false +csharp_space_before_semicolon_in_for_statement = false +csharp_space_between_empty_square_brackets = false +csharp_space_between_method_call_empty_parameter_list_parentheses = false +csharp_space_between_method_call_name_and_opening_parenthesis = false +csharp_space_between_method_call_parameter_list_parentheses = false +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false +csharp_space_between_method_declaration_name_and_open_parenthesis = false +csharp_space_between_method_declaration_parameter_list_parentheses = false +csharp_space_between_parentheses = false +csharp_space_between_square_brackets = false \ No newline at end of file diff --git a/FluentAssertions.sln.DotSettings b/FluentAssertions.sln.DotSettings index 8a620c6f2e..e0ba656db0 100644 --- a/FluentAssertions.sln.DotSettings +++ b/FluentAssertions.sln.DotSettings @@ -70,6 +70,7 @@ True True True + True True True True diff --git a/Src/FluentAssertions/AssertionExtensions.Actions.cs b/Src/FluentAssertions/AssertionExtensions.Actions.cs index 8b33fd771b..e8de6aa9e6 100644 --- a/Src/FluentAssertions/AssertionExtensions.Actions.cs +++ b/Src/FluentAssertions/AssertionExtensions.Actions.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Reflection; using System.Threading.Tasks; using FluentAssertions.Common; using FluentAssertions.Specialized; diff --git a/Src/FluentAssertions/AssertionOptions.cs b/Src/FluentAssertions/AssertionOptions.cs index 7cdb4af28d..611767f76f 100644 --- a/Src/FluentAssertions/AssertionOptions.cs +++ b/Src/FluentAssertions/AssertionOptions.cs @@ -1,7 +1,6 @@ #region using System; -using FluentAssertions.Common; using FluentAssertions.Equivalency; #endregion diff --git a/Src/FluentAssertions/CallerIdentifier.cs b/Src/FluentAssertions/CallerIdentifier.cs index af60d877fb..38d98db68e 100644 --- a/Src/FluentAssertions/CallerIdentifier.cs +++ b/Src/FluentAssertions/CallerIdentifier.cs @@ -1,10 +1,8 @@ using System; using System.Diagnostics; using System.IO; -using System.Linq; using System.Text.RegularExpressions; using FluentAssertions.Common; -using FluentAssertions.Execution; namespace FluentAssertions { @@ -66,7 +64,7 @@ private static string ExtractVariableNameFrom(StackFrame frame) if ((line != null) && (column != 0) && (line.Length > 0)) { - string statement = line.Substring(Math.Min(column - 1, line.Length -1)); + string statement = line.Substring(Math.Min(column - 1, line.Length - 1)); logger(statement); diff --git a/Src/FluentAssertions/Collections/GenericCollectionAssertions.cs b/Src/FluentAssertions/Collections/GenericCollectionAssertions.cs index 12e9a60e5c..0edd8ab971 100644 --- a/Src/FluentAssertions/Collections/GenericCollectionAssertions.cs +++ b/Src/FluentAssertions/Collections/GenericCollectionAssertions.cs @@ -254,7 +254,7 @@ public AndConstraint> OnlyHaveUniqueItems(E ? unordered.OrderBy(keySelector, comparer) : unordered.OrderByDescending(keySelector, comparer); - var orderString = propertyExpression.GetMemberPath(); + string orderString = propertyExpression.GetMemberPath().ToString(); orderString = orderString == "\"\"" ? string.Empty : " by " + orderString; Execute.Assertion diff --git a/Src/FluentAssertions/Collections/GenericDictionaryAssertions.cs b/Src/FluentAssertions/Collections/GenericDictionaryAssertions.cs index c78439c4cb..22ffaf846f 100644 --- a/Src/FluentAssertions/Collections/GenericDictionaryAssertions.cs +++ b/Src/FluentAssertions/Collections/GenericDictionaryAssertions.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; diff --git a/Src/FluentAssertions/Collections/NonGenericCollectionAssertions.cs b/Src/FluentAssertions/Collections/NonGenericCollectionAssertions.cs index 89cb6d125d..b5a24ce12b 100644 --- a/Src/FluentAssertions/Collections/NonGenericCollectionAssertions.cs +++ b/Src/FluentAssertions/Collections/NonGenericCollectionAssertions.cs @@ -1,6 +1,5 @@ using System; using System.Collections; -using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Linq.Expressions; diff --git a/Src/FluentAssertions/Collections/SelfReferencingCollectionAssertions.cs b/Src/FluentAssertions/Collections/SelfReferencingCollectionAssertions.cs index 6510b2930b..320f86750d 100644 --- a/Src/FluentAssertions/Collections/SelfReferencingCollectionAssertions.cs +++ b/Src/FluentAssertions/Collections/SelfReferencingCollectionAssertions.cs @@ -1,7 +1,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; using System.Linq.Expressions; using System.Reflection; diff --git a/Src/FluentAssertions/Common/CSharpAccessModifierExtensions.cs b/Src/FluentAssertions/Common/CSharpAccessModifierExtensions.cs index 1d0b817a0d..bd2a65567a 100644 --- a/Src/FluentAssertions/Common/CSharpAccessModifierExtensions.cs +++ b/Src/FluentAssertions/Common/CSharpAccessModifierExtensions.cs @@ -67,7 +67,7 @@ internal static CSharpAccessModifier GetCSharpAccessModifier(this FieldInfo fiel return CSharpAccessModifier.ProtectedInternal; } - if(fieldInfo.IsFamilyAndAssembly) + if (fieldInfo.IsFamilyAndAssembly) { return CSharpAccessModifier.PrivateProtected; } diff --git a/Src/FluentAssertions/Common/ExpressionExtensions.cs b/Src/FluentAssertions/Common/ExpressionExtensions.cs index eb2cd38cb2..b392ddc775 100644 --- a/Src/FluentAssertions/Common/ExpressionExtensions.cs +++ b/Src/FluentAssertions/Common/ExpressionExtensions.cs @@ -5,10 +5,11 @@ using System.Reflection; using FluentAssertions.Equivalency; +using FluentAssertions.Equivalency.Selection; namespace FluentAssertions.Common { - public static class ExpressionExtensions + internal static class ExpressionExtensions { public static SelectedMemberInfo GetSelectedMemberInfo(this Expression> expression) { @@ -79,9 +80,12 @@ public static class ExpressionExtensions } /// - /// Gets a dotted path of property names representing the property expression. E.g. Parent.Child.Sibling.Name. + /// Gets a dotted path of property names representing the property expression, including the declaring type. /// - public static string GetMemberPath( + /// + /// E.g. Parent.Child.Sibling.Name. + /// + public static MemberPath GetMemberPath( this Expression> expression) { if (expression == null) @@ -89,6 +93,8 @@ public static class ExpressionExtensions throw new ArgumentNullException(nameof(expression), "Expected an expression, but found ."); } + Type declaringType = typeof(TDeclaringType); + var segments = new List(); Expression node = expression; @@ -113,6 +119,7 @@ public static class ExpressionExtensions node = memberExpression.Expression; segments.Add(memberExpression.Member.Name); + declaringType = memberExpression.Member.DeclaringType; break; case ExpressionType.ArrayIndex: @@ -146,7 +153,7 @@ public static class ExpressionExtensions string[] reversedSegments = segments.AsEnumerable().Reverse().ToArray(); string segmentPath = string.Join(".", reversedSegments); - return segmentPath.Replace(".[", "["); + return new MemberPath(declaringType, segmentPath.Replace(".[", "[")); } internal static string GetMethodName(Expression action) diff --git a/Src/FluentAssertions/Common/FullFrameworkReflector.cs b/Src/FluentAssertions/Common/FullFrameworkReflector.cs index ede1c4356a..3b13fc4474 100644 --- a/Src/FluentAssertions/Common/FullFrameworkReflector.cs +++ b/Src/FluentAssertions/Common/FullFrameworkReflector.cs @@ -32,7 +32,7 @@ private bool IsRelevant(Assembly ass) private static bool IsDynamic(Assembly assembly) { - return (assembly.GetType().FullName == "System.Reflection.Emit.AssemblyBuilder") || + return (assembly.GetType().FullName == "System.Reflection.Emit.AssemblyBuilder") || (assembly.GetType().FullName == "System.Reflection.Emit.InternalAssemblyBuilder"); } diff --git a/Src/FluentAssertions/Equivalency/Selection/MemberPath.cs b/Src/FluentAssertions/Common/MemberPath.cs similarity index 55% rename from Src/FluentAssertions/Equivalency/Selection/MemberPath.cs rename to Src/FluentAssertions/Common/MemberPath.cs index 05975e8e46..143032bec4 100644 --- a/Src/FluentAssertions/Equivalency/Selection/MemberPath.cs +++ b/Src/FluentAssertions/Common/MemberPath.cs @@ -2,17 +2,22 @@ using System.Collections.Generic; using System.Linq; -namespace FluentAssertions.Equivalency.Selection +namespace FluentAssertions.Common { /// - /// Encapsulates a dotted candidate to a (nested) member of a type. + /// Encapsulates a dotted candidate to a (nested) member of a type as well as the + /// declaring type of the deepest member. /// internal class MemberPath { + private readonly Type declaringType; + private readonly string dottedPath; private readonly List segments = new List(); - public MemberPath(string dottedPath) + public MemberPath(Type declaringType, string dottedPath) { + this.declaringType = declaringType; + this.dottedPath = dottedPath; segments.AddRange(Segmentize(dottedPath)); } @@ -21,23 +26,37 @@ public bool IsParentOrChildOf(string candidate) return IsParent(candidate) || IsChild(candidate); } + public bool IsSameAs(string candidate, Type memberDeclaringType) + { + string[] candidateSegments = Segmentize(candidate); + + return candidateSegments.SequenceEqual(segments) && memberDeclaringType == declaringType; + } + private bool IsChild(string candidate) { string[] candidateSegments = Segmentize(candidate); - return candidateSegments.Take(segments.Count).SequenceEqual(segments); + return candidateSegments.Take(segments.Count).SequenceEqual(segments) && + candidateSegments.Length > segments.Count; } private bool IsParent(string candidate) { string[] candidateSegments = Segmentize(candidate); - return candidateSegments.SequenceEqual(segments.Take(candidateSegments.Length)); + return candidateSegments.SequenceEqual(segments.Take(candidateSegments.Length)) + && candidateSegments.Length < segments.Count; } private static string[] Segmentize(string dottedPath) { return dottedPath.Split(new[] { '.', '[', ']' }, StringSplitOptions.RemoveEmptyEntries); } + + public override string ToString() + { + return dottedPath; + } } } diff --git a/Src/FluentAssertions/Common/Services.cs b/Src/FluentAssertions/Common/Services.cs index 2a93bd9020..18b32e1324 100644 --- a/Src/FluentAssertions/Common/Services.cs +++ b/Src/FluentAssertions/Common/Services.cs @@ -1,6 +1,5 @@ using System; using FluentAssertions.Execution; -using FluentAssertions.Formatting; namespace FluentAssertions.Common { diff --git a/Src/FluentAssertions/Common/StringExtensions.cs b/Src/FluentAssertions/Common/StringExtensions.cs index dbbcd38c01..6f72357adc 100644 --- a/Src/FluentAssertions/Common/StringExtensions.cs +++ b/Src/FluentAssertions/Common/StringExtensions.cs @@ -1,20 +1,10 @@ using System; -using System.Linq; using FluentAssertions.Formatting; namespace FluentAssertions.Common { internal static class StringExtensions { - /// - /// Finds the first index at which the does not match the - /// string anymore, including the exact casing. - /// - public static int IndexOfFirstMismatch(this string value, string expected) - { - return IndexOfFirstMismatch(value, expected, StringComparison.CurrentCulture); - } - /// /// Finds the first index at which the does not match the /// string anymore, accounting for the specified . @@ -84,7 +74,7 @@ public static bool IsNullOrEmpty(this string value) /// public static string Combine(this string @this, string other, string separator = ".") { - if(@this.Length == 0) + if (@this.Length == 0) { return (other.Length != 0) ? other : string.Empty; } diff --git a/Src/FluentAssertions/Equivalency/AssertionContext.cs b/Src/FluentAssertions/Equivalency/AssertionContext.cs index a26e2f068f..65bcbe1bcc 100644 --- a/Src/FluentAssertions/Equivalency/AssertionContext.cs +++ b/Src/FluentAssertions/Equivalency/AssertionContext.cs @@ -1,5 +1,3 @@ -using System.Reflection; - namespace FluentAssertions.Equivalency { internal class AssertionContext : IAssertionContext diff --git a/Src/FluentAssertions/Equivalency/CollectionMemberMemberInfo.cs b/Src/FluentAssertions/Equivalency/CollectionMemberMemberInfo.cs index fa660220cb..71c4bb7669 100644 --- a/Src/FluentAssertions/Equivalency/CollectionMemberMemberInfo.cs +++ b/Src/FluentAssertions/Equivalency/CollectionMemberMemberInfo.cs @@ -1,5 +1,4 @@ using System; -using System.Reflection; namespace FluentAssertions.Equivalency { diff --git a/Src/FluentAssertions/Equivalency/ConversionSelector.cs b/Src/FluentAssertions/Equivalency/ConversionSelector.cs index 318915373c..ba3dd25d32 100644 --- a/Src/FluentAssertions/Equivalency/ConversionSelector.cs +++ b/Src/FluentAssertions/Equivalency/ConversionSelector.cs @@ -51,7 +51,7 @@ public bool RequiresConversion(IMemberInfo info) public override string ToString() { - if(inclusions.Count == 0 && exclusions.Count == 0) + if (inclusions.Count == 0 && exclusions.Count == 0) { return "Without automatic conversion."; } diff --git a/Src/FluentAssertions/Equivalency/CyclicReferenceDetector.cs b/Src/FluentAssertions/Equivalency/CyclicReferenceDetector.cs index 811bf84b92..560983edec 100644 --- a/Src/FluentAssertions/Equivalency/CyclicReferenceDetector.cs +++ b/Src/FluentAssertions/Equivalency/CyclicReferenceDetector.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using FluentAssertions.Execution; diff --git a/Src/FluentAssertions/Equivalency/DictionaryEquivalencyStep.cs b/Src/FluentAssertions/Equivalency/DictionaryEquivalencyStep.cs index 3c29f2379b..95339504e5 100644 --- a/Src/FluentAssertions/Equivalency/DictionaryEquivalencyStep.cs +++ b/Src/FluentAssertions/Equivalency/DictionaryEquivalencyStep.cs @@ -1,4 +1,3 @@ -using System; using System.Collections; using System.Diagnostics.CodeAnalysis; using System.Reflection; diff --git a/Src/FluentAssertions/Equivalency/EnumerableEquivalencyValidator.cs b/Src/FluentAssertions/Equivalency/EnumerableEquivalencyValidator.cs index f8d5b52ce8..20f081930a 100644 --- a/Src/FluentAssertions/Equivalency/EnumerableEquivalencyValidator.cs +++ b/Src/FluentAssertions/Equivalency/EnumerableEquivalencyValidator.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.Linq; diff --git a/Src/FluentAssertions/Equivalency/EquivalencyAssertionOptions.cs b/Src/FluentAssertions/Equivalency/EquivalencyAssertionOptions.cs index 98a3d62d80..ec3114a9c4 100644 --- a/Src/FluentAssertions/Equivalency/EquivalencyAssertionOptions.cs +++ b/Src/FluentAssertions/Equivalency/EquivalencyAssertionOptions.cs @@ -68,7 +68,7 @@ public EquivalencyAssertionOptions Including(Expression WithStrictOrderingFor( Expression> expression) { - string expressionMemberPath = expression.GetMemberPath(); + string expressionMemberPath = expression.GetMemberPath().ToString(); orderingRules.Add(new PathBasedOrderingRule(expressionMemberPath)); return this; } diff --git a/Src/FluentAssertions/Equivalency/IMemberInfo.cs b/Src/FluentAssertions/Equivalency/IMemberInfo.cs index 0b8fdf0fe6..75bf03c4d3 100644 --- a/Src/FluentAssertions/Equivalency/IMemberInfo.cs +++ b/Src/FluentAssertions/Equivalency/IMemberInfo.cs @@ -1,5 +1,4 @@ using System; -using System.Reflection; namespace FluentAssertions.Equivalency { diff --git a/Src/FluentAssertions/Equivalency/Selection/ExcludeMemberByPathSelectionRule.cs b/Src/FluentAssertions/Equivalency/Selection/ExcludeMemberByPathSelectionRule.cs index 634396e4fa..12d0645d6d 100644 --- a/Src/FluentAssertions/Equivalency/Selection/ExcludeMemberByPathSelectionRule.cs +++ b/Src/FluentAssertions/Equivalency/Selection/ExcludeMemberByPathSelectionRule.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using FluentAssertions.Common; @@ -9,23 +10,25 @@ namespace FluentAssertions.Equivalency.Selection /// internal class ExcludeMemberByPathSelectionRule : SelectMemberByPathSelectionRule { - private readonly string pathToExclude; + private readonly MemberPath memberToExclude; - public ExcludeMemberByPathSelectionRule(string pathToExclude) - : base(pathToExclude) + public ExcludeMemberByPathSelectionRule(MemberPath pathToExclude) + : base(pathToExclude.ToString()) { - this.pathToExclude = pathToExclude; + this.memberToExclude = pathToExclude; } protected override IEnumerable OnSelectMembers(IEnumerable selectedMembers, string currentPath, IMemberInfo context) { - return selectedMembers.Where(memberInfo => currentPath.Combine(memberInfo.Name) != pathToExclude).ToArray(); + return selectedMembers + .Where(memberInfo => !memberToExclude.IsSameAs(currentPath.Combine(memberInfo.Name), memberInfo.DeclaringType)) + .ToArray(); } public override string ToString() { - return "Exclude member root." + pathToExclude; + return "Exclude member root." + memberToExclude; } } } diff --git a/Src/FluentAssertions/Equivalency/Selection/IncludeMemberByPathSelectionRule.cs b/Src/FluentAssertions/Equivalency/Selection/IncludeMemberByPathSelectionRule.cs index 3dcc2e451d..f428475108 100644 --- a/Src/FluentAssertions/Equivalency/Selection/IncludeMemberByPathSelectionRule.cs +++ b/Src/FluentAssertions/Equivalency/Selection/IncludeMemberByPathSelectionRule.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using FluentAssertions.Common; @@ -9,12 +10,12 @@ namespace FluentAssertions.Equivalency.Selection /// internal class IncludeMemberByPathSelectionRule : SelectMemberByPathSelectionRule { - private readonly MemberPath pathToInclude; + private readonly MemberPath memberToInclude; - public IncludeMemberByPathSelectionRule(string pathToInclude) - : base(pathToInclude) + public IncludeMemberByPathSelectionRule(MemberPath pathToInclude) + : base(pathToInclude.ToString()) { - this.pathToInclude = new MemberPath(pathToInclude); + memberToInclude = pathToInclude; } public override bool IncludesMembers => true; @@ -24,7 +25,9 @@ public IncludeMemberByPathSelectionRule(string pathToInclude) { var matchingMembers = from member in context.RuntimeType.GetNonPrivateMembers() - where pathToInclude.IsParentOrChildOf(currentPath.Combine(member.Name)) + let memberPath = currentPath.Combine(member.Name) + where memberToInclude.IsSameAs(memberPath, member.DeclaringType) || + memberToInclude.IsParentOrChildOf(memberPath) select member; return selectedMembers.Concat(matchingMembers).ToArray(); @@ -32,7 +35,7 @@ where pathToInclude.IsParentOrChildOf(currentPath.Combine(member.Name)) public override string ToString() { - return "Include member root." + pathToInclude; + return "Include member root." + memberToInclude; } } } diff --git a/Src/FluentAssertions/Equivalency/Selection/NestedSelectionContext.cs b/Src/FluentAssertions/Equivalency/Selection/NestedSelectionContext.cs index a82f95a8c1..4bfdb4f4fc 100644 --- a/Src/FluentAssertions/Equivalency/Selection/NestedSelectionContext.cs +++ b/Src/FluentAssertions/Equivalency/Selection/NestedSelectionContext.cs @@ -1,5 +1,4 @@ using System; -using System.Reflection; using FluentAssertions.Common; namespace FluentAssertions.Equivalency.Selection diff --git a/Src/FluentAssertions/Equivalency/SelfReferenceEquivalencyAssertionOptions.cs b/Src/FluentAssertions/Equivalency/SelfReferenceEquivalencyAssertionOptions.cs index 80f0d67fe8..f124a4269b 100644 --- a/Src/FluentAssertions/Equivalency/SelfReferenceEquivalencyAssertionOptions.cs +++ b/Src/FluentAssertions/Equivalency/SelfReferenceEquivalencyAssertionOptions.cs @@ -127,7 +127,7 @@ IEnumerable IEquivalencyAssertionOptions.SelectionRules /// Gets an ordered collection of Equivalency steps how a subject is compared with the expectation. /// IEnumerable IEquivalencyAssertionOptions.GetUserEquivalencySteps(ConversionSelector convertionSelector) => - userEquivalencySteps.Concat(new[] {new TryConversionStep(convertionSelector) }); + userEquivalencySteps.Concat(new[] { new TryConversionStep(convertionSelector) }); public ConversionSelector ConversionSelector { get; } = new ConversionSelector(); diff --git a/Src/FluentAssertions/Equivalency/ValueTypeEquivalencyStep.cs b/Src/FluentAssertions/Equivalency/ValueTypeEquivalencyStep.cs index f8dd0c8ab3..ce7f2577e2 100644 --- a/Src/FluentAssertions/Equivalency/ValueTypeEquivalencyStep.cs +++ b/Src/FluentAssertions/Equivalency/ValueTypeEquivalencyStep.cs @@ -1,5 +1,4 @@ using System; -using FluentAssertions.Common; namespace FluentAssertions.Equivalency { diff --git a/Src/FluentAssertions/EventRaisingExtensions.cs b/Src/FluentAssertions/EventRaisingExtensions.cs index f46593f5f7..50bbc19bee 100644 --- a/Src/FluentAssertions/EventRaisingExtensions.cs +++ b/Src/FluentAssertions/EventRaisingExtensions.cs @@ -1,9 +1,6 @@ using System; -using System.ComponentModel; using System.Linq; using System.Linq.Expressions; - -using FluentAssertions.Common; using FluentAssertions.Events; using FluentAssertions.Execution; diff --git a/Src/FluentAssertions/Execution/AssertionScope.cs b/Src/FluentAssertions/Execution/AssertionScope.cs index bfea098062..d4e04c22d6 100644 --- a/Src/FluentAssertions/Execution/AssertionScope.cs +++ b/Src/FluentAssertions/Execution/AssertionScope.cs @@ -2,7 +2,6 @@ using System; using System.Linq; -using System.Threading; using FluentAssertions.Common; #endregion diff --git a/Src/FluentAssertions/Execution/Execute.cs b/Src/FluentAssertions/Execution/Execute.cs index 6a3d76e2e1..a18ed26e74 100644 --- a/Src/FluentAssertions/Execution/Execute.cs +++ b/Src/FluentAssertions/Execution/Execute.cs @@ -1,6 +1,4 @@ -using FluentAssertions.Common; - -namespace FluentAssertions.Execution +namespace FluentAssertions.Execution { /// /// Helper class for verifying a condition and/or throwing a test harness specific exception representing an assertion failure. diff --git a/Src/FluentAssertions/Execution/GivenSelectorExtensions.cs b/Src/FluentAssertions/Execution/GivenSelectorExtensions.cs index 6ed18de4a0..a41d3dd313 100644 --- a/Src/FluentAssertions/Execution/GivenSelectorExtensions.cs +++ b/Src/FluentAssertions/Execution/GivenSelectorExtensions.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using FluentAssertions.Common; namespace FluentAssertions.Execution diff --git a/Src/FluentAssertions/Formatting/AggregateExceptionValueFormatter.cs b/Src/FluentAssertions/Formatting/AggregateExceptionValueFormatter.cs index 74a62e5cd2..afab88d5df 100644 --- a/Src/FluentAssertions/Formatting/AggregateExceptionValueFormatter.cs +++ b/Src/FluentAssertions/Formatting/AggregateExceptionValueFormatter.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Text; namespace FluentAssertions.Formatting diff --git a/Src/FluentAssertions/Formatting/AttributeBasedFormatter.cs b/Src/FluentAssertions/Formatting/AttributeBasedFormatter.cs index cffbec480a..42b86a98f6 100644 --- a/Src/FluentAssertions/Formatting/AttributeBasedFormatter.cs +++ b/Src/FluentAssertions/Formatting/AttributeBasedFormatter.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.IO; using System.Linq; using System.Reflection; @@ -39,7 +37,7 @@ public string Format(object value, FormattingContext context, FormatChild format { MethodInfo method = GetFormatter(value); - object[] parameters = new[]{ value }; + object[] parameters = new[] { value }; return (string)method.Invoke(null, parameters); } diff --git a/Src/FluentAssertions/Formatting/ByteValueFormatter.cs b/Src/FluentAssertions/Formatting/ByteValueFormatter.cs index c720b8a761..53176f35e6 100644 --- a/Src/FluentAssertions/Formatting/ByteValueFormatter.cs +++ b/Src/FluentAssertions/Formatting/ByteValueFormatter.cs @@ -1,7 +1,4 @@ -using System.Collections.Generic; -using System.Globalization; - -namespace FluentAssertions.Formatting +namespace FluentAssertions.Formatting { public class ByteValueFormatter : IValueFormatter { diff --git a/Src/FluentAssertions/Formatting/DecimalValueFormatter.cs b/Src/FluentAssertions/Formatting/DecimalValueFormatter.cs index 11893e0661..34760ebb6d 100644 --- a/Src/FluentAssertions/Formatting/DecimalValueFormatter.cs +++ b/Src/FluentAssertions/Formatting/DecimalValueFormatter.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using System.Globalization; +using System.Globalization; namespace FluentAssertions.Formatting { diff --git a/Src/FluentAssertions/Formatting/DefaultValueFormatter.cs b/Src/FluentAssertions/Formatting/DefaultValueFormatter.cs index 3480c2ccfc..246d9d1cba 100644 --- a/Src/FluentAssertions/Formatting/DefaultValueFormatter.cs +++ b/Src/FluentAssertions/Formatting/DefaultValueFormatter.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Reflection; using System.Text; using FluentAssertions.Common; using FluentAssertions.Equivalency; diff --git a/Src/FluentAssertions/Formatting/DoubleValueFormatter.cs b/Src/FluentAssertions/Formatting/DoubleValueFormatter.cs index cb93e33e6a..44600a4287 100644 --- a/Src/FluentAssertions/Formatting/DoubleValueFormatter.cs +++ b/Src/FluentAssertions/Formatting/DoubleValueFormatter.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; -using System.Globalization; -using System.Text.RegularExpressions; +using System.Globalization; namespace FluentAssertions.Formatting { diff --git a/Src/FluentAssertions/Formatting/ExceptionValueFormatter.cs b/Src/FluentAssertions/Formatting/ExceptionValueFormatter.cs index 03b75e8455..e8ebdc4f2b 100644 --- a/Src/FluentAssertions/Formatting/ExceptionValueFormatter.cs +++ b/Src/FluentAssertions/Formatting/ExceptionValueFormatter.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Text; namespace FluentAssertions.Formatting diff --git a/Src/FluentAssertions/Formatting/ExpressionValueFormatter.cs b/Src/FluentAssertions/Formatting/ExpressionValueFormatter.cs index c71ef23213..8c3b2bba24 100644 --- a/Src/FluentAssertions/Formatting/ExpressionValueFormatter.cs +++ b/Src/FluentAssertions/Formatting/ExpressionValueFormatter.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using System.Linq.Expressions; +using System.Linq.Expressions; namespace FluentAssertions.Formatting { diff --git a/Src/FluentAssertions/Formatting/GuidValueFormatter.cs b/Src/FluentAssertions/Formatting/GuidValueFormatter.cs index f2a8be72f3..aec193a0d8 100644 --- a/Src/FluentAssertions/Formatting/GuidValueFormatter.cs +++ b/Src/FluentAssertions/Formatting/GuidValueFormatter.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; namespace FluentAssertions.Formatting { diff --git a/Src/FluentAssertions/Formatting/Int16ValueFormatter.cs b/Src/FluentAssertions/Formatting/Int16ValueFormatter.cs index 9f11c919d8..93381c437d 100644 --- a/Src/FluentAssertions/Formatting/Int16ValueFormatter.cs +++ b/Src/FluentAssertions/Formatting/Int16ValueFormatter.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using System.Globalization; +using System.Globalization; namespace FluentAssertions.Formatting { diff --git a/Src/FluentAssertions/Formatting/Int32ValueFormatter.cs b/Src/FluentAssertions/Formatting/Int32ValueFormatter.cs index fe43754c72..85c2113c71 100644 --- a/Src/FluentAssertions/Formatting/Int32ValueFormatter.cs +++ b/Src/FluentAssertions/Formatting/Int32ValueFormatter.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using System.Globalization; +using System.Globalization; namespace FluentAssertions.Formatting { diff --git a/Src/FluentAssertions/Formatting/Int64ValueFormatter.cs b/Src/FluentAssertions/Formatting/Int64ValueFormatter.cs index 335b42fa27..b09c13a905 100644 --- a/Src/FluentAssertions/Formatting/Int64ValueFormatter.cs +++ b/Src/FluentAssertions/Formatting/Int64ValueFormatter.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using System.Globalization; +using System.Globalization; namespace FluentAssertions.Formatting { diff --git a/Src/FluentAssertions/Formatting/NullValueFormatter.cs b/Src/FluentAssertions/Formatting/NullValueFormatter.cs index 8cfcb52a4b..6c435674cb 100644 --- a/Src/FluentAssertions/Formatting/NullValueFormatter.cs +++ b/Src/FluentAssertions/Formatting/NullValueFormatter.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; - -namespace FluentAssertions.Formatting +namespace FluentAssertions.Formatting { public class NullValueFormatter : IValueFormatter { diff --git a/Src/FluentAssertions/Formatting/PropertyInfoFormatter.cs b/Src/FluentAssertions/Formatting/PropertyInfoFormatter.cs index 24ae040058..45209ed887 100644 --- a/Src/FluentAssertions/Formatting/PropertyInfoFormatter.cs +++ b/Src/FluentAssertions/Formatting/PropertyInfoFormatter.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using System.Reflection; +using System.Reflection; namespace FluentAssertions.Formatting { diff --git a/Src/FluentAssertions/Formatting/SByteValueFormatter.cs b/Src/FluentAssertions/Formatting/SByteValueFormatter.cs index 680280766e..57694361b9 100644 --- a/Src/FluentAssertions/Formatting/SByteValueFormatter.cs +++ b/Src/FluentAssertions/Formatting/SByteValueFormatter.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using System.Globalization; +using System.Globalization; namespace FluentAssertions.Formatting { diff --git a/Src/FluentAssertions/Formatting/SingleValueFormatter.cs b/Src/FluentAssertions/Formatting/SingleValueFormatter.cs index d4328c8154..c40ab6d0f2 100644 --- a/Src/FluentAssertions/Formatting/SingleValueFormatter.cs +++ b/Src/FluentAssertions/Formatting/SingleValueFormatter.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using System.Globalization; +using System.Globalization; namespace FluentAssertions.Formatting { diff --git a/Src/FluentAssertions/Formatting/StringValueFormatter.cs b/Src/FluentAssertions/Formatting/StringValueFormatter.cs index 282ab89906..1c5ae04197 100644 --- a/Src/FluentAssertions/Formatting/StringValueFormatter.cs +++ b/Src/FluentAssertions/Formatting/StringValueFormatter.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using FluentAssertions.Common; namespace FluentAssertions.Formatting diff --git a/Src/FluentAssertions/Formatting/UInt16ValueFormatter.cs b/Src/FluentAssertions/Formatting/UInt16ValueFormatter.cs index 2de8e4ca7b..dcffb6c1eb 100644 --- a/Src/FluentAssertions/Formatting/UInt16ValueFormatter.cs +++ b/Src/FluentAssertions/Formatting/UInt16ValueFormatter.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using System.Globalization; +using System.Globalization; namespace FluentAssertions.Formatting { diff --git a/Src/FluentAssertions/Formatting/UInt32ValueFormatter.cs b/Src/FluentAssertions/Formatting/UInt32ValueFormatter.cs index 323df81925..e2b328c61e 100644 --- a/Src/FluentAssertions/Formatting/UInt32ValueFormatter.cs +++ b/Src/FluentAssertions/Formatting/UInt32ValueFormatter.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using System.Globalization; +using System.Globalization; namespace FluentAssertions.Formatting { diff --git a/Src/FluentAssertions/Formatting/UInt64ValueFormatter.cs b/Src/FluentAssertions/Formatting/UInt64ValueFormatter.cs index 81bcd03a93..03df4f922a 100644 --- a/Src/FluentAssertions/Formatting/UInt64ValueFormatter.cs +++ b/Src/FluentAssertions/Formatting/UInt64ValueFormatter.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using System.Globalization; +using System.Globalization; namespace FluentAssertions.Formatting { diff --git a/Src/FluentAssertions/Formatting/XAttributeValueFormatter.cs b/Src/FluentAssertions/Formatting/XAttributeValueFormatter.cs index 4b455b19b0..f03aca2ee4 100644 --- a/Src/FluentAssertions/Formatting/XAttributeValueFormatter.cs +++ b/Src/FluentAssertions/Formatting/XAttributeValueFormatter.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using System.Xml.Linq; namespace FluentAssertions.Formatting diff --git a/Src/FluentAssertions/Formatting/XDocumentValueFormatter.cs b/Src/FluentAssertions/Formatting/XDocumentValueFormatter.cs index 80103a80e4..2763382716 100644 --- a/Src/FluentAssertions/Formatting/XDocumentValueFormatter.cs +++ b/Src/FluentAssertions/Formatting/XDocumentValueFormatter.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using System.Xml.Linq; +using System.Xml.Linq; namespace FluentAssertions.Formatting { diff --git a/Src/FluentAssertions/Formatting/XElementValueFormatter.cs b/Src/FluentAssertions/Formatting/XElementValueFormatter.cs index ee27776ad0..f8a4c06d10 100644 --- a/Src/FluentAssertions/Formatting/XElementValueFormatter.cs +++ b/Src/FluentAssertions/Formatting/XElementValueFormatter.cs @@ -1,11 +1,8 @@ using System; -using System.Collections.Generic; +using System.Linq; using System.Xml.Linq; - using FluentAssertions.Common; -using System.Linq; - namespace FluentAssertions.Formatting { public class XElementValueFormatter : IValueFormatter diff --git a/Src/FluentAssertions/NumericAssertionsExtensions.cs b/Src/FluentAssertions/NumericAssertionsExtensions.cs index d09f379204..c4c9205fa0 100644 --- a/Src/FluentAssertions/NumericAssertionsExtensions.cs +++ b/Src/FluentAssertions/NumericAssertionsExtensions.cs @@ -803,7 +803,7 @@ public static class NumericAssertionsExtensions double? expectedValue, double precision, string because = "", params object[] becauseArgs) { - if(parent.Subject == null && expectedValue == null) + if (parent.Subject == null && expectedValue == null) { return new AndConstraint>(parent); } @@ -954,7 +954,7 @@ public static class NumericAssertionsExtensions private static void FailIfDifferenceOutsidePrecision( bool differenceWithinPrecision, NumericAssertions parent, T expectedValue, T precision, T actualDifference, - string because, object[] becauseArgs) where T:struct + string because, object[] becauseArgs) where T : struct { Execute.Assertion .ForCondition(differenceWithinPrecision) @@ -988,7 +988,7 @@ public static class NumericAssertionsExtensions float unexpectedValue, float precision, string because = "", params object[] becauseArgs) { - if(parent.Subject != null) + if (parent.Subject != null) { var nonNullableAssertions = new NumericAssertions((float)parent.Subject); nonNullableAssertions.NotBeApproximately(unexpectedValue, precision, because, becauseArgs); diff --git a/Src/FluentAssertions/Primitives/BooleanAssertions.cs b/Src/FluentAssertions/Primitives/BooleanAssertions.cs index 2c1100931b..f6fc7a4ea6 100644 --- a/Src/FluentAssertions/Primitives/BooleanAssertions.cs +++ b/Src/FluentAssertions/Primitives/BooleanAssertions.cs @@ -1,5 +1,4 @@ -using System; -using System.Diagnostics; +using System.Diagnostics; using FluentAssertions.Execution; namespace FluentAssertions.Primitives diff --git a/Src/FluentAssertions/Primitives/DateTimeAssertions.cs b/Src/FluentAssertions/Primitives/DateTimeAssertions.cs index a00bbdfebe..a472e38352 100644 --- a/Src/FluentAssertions/Primitives/DateTimeAssertions.cs +++ b/Src/FluentAssertions/Primitives/DateTimeAssertions.cs @@ -1,8 +1,8 @@ using System; using System.Collections.Generic; using System.Diagnostics; -using FluentAssertions.Execution; using System.Linq; +using FluentAssertions.Execution; namespace FluentAssertions.Primitives { diff --git a/Src/FluentAssertions/Primitives/DateTimeOffsetRangeAssertions.cs b/Src/FluentAssertions/Primitives/DateTimeOffsetRangeAssertions.cs index bf0bdbd423..bf80374f4d 100644 --- a/Src/FluentAssertions/Primitives/DateTimeOffsetRangeAssertions.cs +++ b/Src/FluentAssertions/Primitives/DateTimeOffsetRangeAssertions.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Diagnostics; -using FluentAssertions.Common; using FluentAssertions.Execution; namespace FluentAssertions.Primitives diff --git a/Src/FluentAssertions/Primitives/NullableBooleanAssertions.cs b/Src/FluentAssertions/Primitives/NullableBooleanAssertions.cs index ba2794b0c0..6e3270be2a 100644 --- a/Src/FluentAssertions/Primitives/NullableBooleanAssertions.cs +++ b/Src/FluentAssertions/Primitives/NullableBooleanAssertions.cs @@ -1,5 +1,4 @@ -using System; -using System.Diagnostics; +using System.Diagnostics; using FluentAssertions.Execution; namespace FluentAssertions.Primitives diff --git a/Src/FluentAssertions/Primitives/NullableSimpleTimeSpanAssertions.cs b/Src/FluentAssertions/Primitives/NullableSimpleTimeSpanAssertions.cs index 8fe5828287..44e4a8b265 100644 --- a/Src/FluentAssertions/Primitives/NullableSimpleTimeSpanAssertions.cs +++ b/Src/FluentAssertions/Primitives/NullableSimpleTimeSpanAssertions.cs @@ -1,6 +1,5 @@ using System; using System.Diagnostics; -using FluentAssertions.Common; using FluentAssertions.Execution; namespace FluentAssertions.Primitives diff --git a/Src/FluentAssertions/Primitives/ObjectAssertions.cs b/Src/FluentAssertions/Primitives/ObjectAssertions.cs index 1a666ee1ad..ce7b70e926 100644 --- a/Src/FluentAssertions/Primitives/ObjectAssertions.cs +++ b/Src/FluentAssertions/Primitives/ObjectAssertions.cs @@ -1,8 +1,5 @@ using System; using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Xml.Serialization; using FluentAssertions.Common; using FluentAssertions.Equivalency; using FluentAssertions.Execution; diff --git a/Src/FluentAssertions/Specialized/ExecutionTimeAssertions.cs b/Src/FluentAssertions/Specialized/ExecutionTimeAssertions.cs index 3e53221592..aa6daddd0d 100644 --- a/Src/FluentAssertions/Specialized/ExecutionTimeAssertions.cs +++ b/Src/FluentAssertions/Specialized/ExecutionTimeAssertions.cs @@ -1,9 +1,8 @@ using System; using System.Diagnostics; using System.Linq.Expressions; -using FluentAssertions.Execution; using System.Threading.Tasks; -using System.Threading; +using FluentAssertions.Execution; namespace FluentAssertions.Specialized { diff --git a/Src/FluentAssertions/TypeExtensions.cs b/Src/FluentAssertions/TypeExtensions.cs index d62565d235..abc7f9934c 100644 --- a/Src/FluentAssertions/TypeExtensions.cs +++ b/Src/FluentAssertions/TypeExtensions.cs @@ -1,10 +1,9 @@ using System; +using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; - using FluentAssertions.Types; -using System.Collections.Generic; namespace FluentAssertions { diff --git a/Src/FluentAssertions/Types/ConstructorInfoAssertions.cs b/Src/FluentAssertions/Types/ConstructorInfoAssertions.cs index 6672d9f2e4..3d94cd101e 100644 --- a/Src/FluentAssertions/Types/ConstructorInfoAssertions.cs +++ b/Src/FluentAssertions/Types/ConstructorInfoAssertions.cs @@ -1,4 +1,3 @@ -using System; using System.Diagnostics; using System.Reflection; diff --git a/Src/FluentAssertions/Types/MethodBaseAssertions.cs b/Src/FluentAssertions/Types/MethodBaseAssertions.cs index f8791974d7..3855849dab 100644 --- a/Src/FluentAssertions/Types/MethodBaseAssertions.cs +++ b/Src/FluentAssertions/Types/MethodBaseAssertions.cs @@ -1,4 +1,3 @@ -using System; using System.Diagnostics; using System.Linq; using System.Reflection; diff --git a/Src/FluentAssertions/Types/TypeAssertions.cs b/Src/FluentAssertions/Types/TypeAssertions.cs index 880f2d444e..b70c5428c6 100644 --- a/Src/FluentAssertions/Types/TypeAssertions.cs +++ b/Src/FluentAssertions/Types/TypeAssertions.cs @@ -1224,7 +1224,7 @@ private void AssertThatSubjectIsClass() var typeInfo = Subject.GetTypeInfo(); if (typeInfo.IsInterface || typeInfo.IsValueType || typeof(Delegate).IsAssignableFrom(typeInfo.BaseType)) { - throw new InvalidOperationException($"{Subject} must be a class."); + throw new InvalidOperationException($"{Subject} must be a class."); } } } diff --git a/Src/FluentAssertions/Types/TypeSelectorAssertions.cs b/Src/FluentAssertions/Types/TypeSelectorAssertions.cs index dd95694ff9..c6781c0b79 100644 --- a/Src/FluentAssertions/Types/TypeSelectorAssertions.cs +++ b/Src/FluentAssertions/Types/TypeSelectorAssertions.cs @@ -3,9 +3,8 @@ using System.Diagnostics; using System.Linq; using System.Linq.Expressions; - -using FluentAssertions.Execution; using FluentAssertions.Common; +using FluentAssertions.Execution; namespace FluentAssertions.Types { diff --git a/Tests/Benchmarks/HasValueSemanticsBenchmarks.cs b/Tests/Benchmarks/HasValueSemanticsBenchmarks.cs index 5df7dfeb96..4bd039cf9f 100644 --- a/Tests/Benchmarks/HasValueSemanticsBenchmarks.cs +++ b/Tests/Benchmarks/HasValueSemanticsBenchmarks.cs @@ -20,7 +20,7 @@ public class HasValueSemanticsBenchmarks public bool HasValueSemantics_AnonymousType() => new { }.GetType().HasValueSemantics(); [Benchmark] - public bool HasValueSemantics_KeyValuePair() => typeof(KeyValuePair).HasValueSemantics(); + public bool HasValueSemantics_KeyValuePair() => typeof(KeyValuePair).HasValueSemantics(); [Benchmark] public bool HasValueSemantics_ValueTuple() => typeof((int, int)).HasValueSemantics(); diff --git a/Tests/Net45.Specs/Chill/AutofacChillContainer.cs b/Tests/Net45.Specs/Chill/AutofacChillContainer.cs index 8a1bedec7c..f8923a0dcf 100644 --- a/Tests/Net45.Specs/Chill/AutofacChillContainer.cs +++ b/Tests/Net45.Specs/Chill/AutofacChillContainer.cs @@ -1,8 +1,6 @@ using Autofac; using Autofac.Builder; using Autofac.Core; -using Chill; -using System; namespace Chill.Autofac { diff --git a/Tests/Net47.Specs/Chill/AutofacChillContainer.cs b/Tests/Net47.Specs/Chill/AutofacChillContainer.cs index 8a1bedec7c..f8923a0dcf 100644 --- a/Tests/Net47.Specs/Chill/AutofacChillContainer.cs +++ b/Tests/Net47.Specs/Chill/AutofacChillContainer.cs @@ -1,8 +1,6 @@ using Autofac; using Autofac.Builder; using Autofac.Core; -using Chill; -using System; namespace Chill.Autofac { diff --git a/Tests/Shared.Specs/AsyncFunctionExceptionAssertionSpecs.cs b/Tests/Shared.Specs/AsyncFunctionExceptionAssertionSpecs.cs index 09ed56561e..c0b4eb6e20 100644 --- a/Tests/Shared.Specs/AsyncFunctionExceptionAssertionSpecs.cs +++ b/Tests/Shared.Specs/AsyncFunctionExceptionAssertionSpecs.cs @@ -1,5 +1,4 @@ using System; -using System.Threading; using System.Threading.Tasks; using Xunit; using Xunit.Sdk; @@ -284,7 +283,6 @@ public async Task When_async_method_throws_exception_and_expected_not_to_throw_a // Act //----------------------------------------------------------------------------------------------------------- Func action = async () => await asyncObject.ThrowAsync(); - //----------------------------------------------------------------------------------------------------------- // Assert diff --git a/Tests/Shared.Specs/BasicEquivalencySpecs.cs b/Tests/Shared.Specs/BasicEquivalencySpecs.cs index 011c2b7c69..1599b5c0e0 100644 --- a/Tests/Shared.Specs/BasicEquivalencySpecs.cs +++ b/Tests/Shared.Specs/BasicEquivalencySpecs.cs @@ -1,9 +1,9 @@ using System; +using System.Collections; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Linq.Expressions; -using System.Collections; using System.Net; using FluentAssertions.Common; using FluentAssertions.Equivalency; @@ -1191,6 +1191,46 @@ public void When_a_property_is_hidden_in_a_derived_class_it_should_ignore_it() action.Should().NotThrow(); } + [Fact] + public void When_including_a_property_that_is_hidden_in_a_derived_class_it_should_select_the_correct_one() + { + //----------------------------------------------------------------------------------------------------------- + // Arrange + //----------------------------------------------------------------------------------------------------------- + var b1 = new ClassThatHidesBaseClassProperty(); + var b2 = new ClassThatHidesBaseClassProperty(); + + //----------------------------------------------------------------------------------------------------------- + // Act / Assert + //----------------------------------------------------------------------------------------------------------- + b1.Should().BeEquivalentTo(b2, config => config.Including(b => b.Property)); + } + + [Fact] + public void When_excluding_a_property_that_is_hidden_in_a_derived_class_it_should_select_the_correct_one() + { + //----------------------------------------------------------------------------------------------------------- + // Arrange + //----------------------------------------------------------------------------------------------------------- + var b1 = new ClassThatHidesBaseClassProperty(); + var b2 = new ClassThatHidesBaseClassProperty(); + + //----------------------------------------------------------------------------------------------------------- + // Act / Assert + //----------------------------------------------------------------------------------------------------------- + b1.Should().BeEquivalentTo(b2, config => config.Excluding(b => b.Property)); + } + + class ClassWithGuidProperty + { + public string Property { get; set; } = Guid.NewGuid().ToString(); + } + + class ClassThatHidesBaseClassProperty: ClassWithGuidProperty + { + public new string[] Property { get; set; } + } + [Fact] public void When_a_property_is_an_indexer_it_should_be_ignored() { @@ -3353,7 +3393,7 @@ public void When_an_enumerable_collection_returns_itself_it_should_detect_the_cy //----------------------------------------------------------------------------------------------------------- var instance1 = new SelfReturningEnumerable(); var instance2 = new SelfReturningEnumerable(); - var actual = new List {instance1, instance2}; + var actual = new List { instance1, instance2 }; //----------------------------------------------------------------------------------------------------------- // Assert @@ -3594,7 +3634,7 @@ public void When_asserting_members_from_different_enum_types_are_equivalent_by_s // Arrange //----------------------------------------------------------------------------------------------------------- var subject = new ClassWithEnumOne { Enum = EnumOne.Two }; - var expectation = new ClassWithEnumThree() { Enum = EnumThree.Two}; + var expectation = new ClassWithEnumThree() { Enum = EnumThree.Two }; //----------------------------------------------------------------------------------------------------------- // Act diff --git a/Tests/Shared.Specs/CollectionAssertionSpecs.cs b/Tests/Shared.Specs/CollectionAssertionSpecs.cs index b39402e930..6beb5df2b1 100644 --- a/Tests/Shared.Specs/CollectionAssertionSpecs.cs +++ b/Tests/Shared.Specs/CollectionAssertionSpecs.cs @@ -1,7 +1,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Collections.ObjectModel; using System.Linq; using Xunit; using Xunit.Sdk; diff --git a/Tests/Shared.Specs/CollectionEquivalencySpecs.cs b/Tests/Shared.Specs/CollectionEquivalencySpecs.cs index 115aed7ad0..9da768c752 100644 --- a/Tests/Shared.Specs/CollectionEquivalencySpecs.cs +++ b/Tests/Shared.Specs/CollectionEquivalencySpecs.cs @@ -970,7 +970,10 @@ public void When_some_subject_items_are_not_equivalent_to_expectation_for_huge_t //----------------------------------------------------------------------------------------------------------- Action action = () => { - try { subject.Should().AllBeEquivalentTo(1); } + try + { + subject.Should().AllBeEquivalentTo(1); + } catch { // ignored, we only care about execution time diff --git a/Tests/Shared.Specs/ComparableSpecs.cs b/Tests/Shared.Specs/ComparableSpecs.cs index f1db82cd9a..7852451f13 100644 --- a/Tests/Shared.Specs/ComparableSpecs.cs +++ b/Tests/Shared.Specs/ComparableSpecs.cs @@ -1,6 +1,4 @@ using System; - -using FluentAssertions.Primitives; using Xunit; using Xunit.Sdk; diff --git a/Tests/Shared.Specs/DateTimeAssertionSpecs.cs b/Tests/Shared.Specs/DateTimeAssertionSpecs.cs index 79125b4761..1222e68043 100644 --- a/Tests/Shared.Specs/DateTimeAssertionSpecs.cs +++ b/Tests/Shared.Specs/DateTimeAssertionSpecs.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using FluentAssertions.Extensions; -using FluentAssertions.Primitives; using Xunit; using Xunit.Sdk; diff --git a/Tests/Shared.Specs/DateTimeOffsetAssertionSpecs.cs b/Tests/Shared.Specs/DateTimeOffsetAssertionSpecs.cs index 737710a39e..0c797c6be5 100644 --- a/Tests/Shared.Specs/DateTimeOffsetAssertionSpecs.cs +++ b/Tests/Shared.Specs/DateTimeOffsetAssertionSpecs.cs @@ -1,7 +1,6 @@ using System; using FluentAssertions.Common; using FluentAssertions.Extensions; -using FluentAssertions.Primitives; using Xunit; using Xunit.Sdk; diff --git a/Tests/Shared.Specs/DictionaryEquivalencySpecs.cs b/Tests/Shared.Specs/DictionaryEquivalencySpecs.cs index 99fcba6664..8ae11fae37 100644 --- a/Tests/Shared.Specs/DictionaryEquivalencySpecs.cs +++ b/Tests/Shared.Specs/DictionaryEquivalencySpecs.cs @@ -381,7 +381,6 @@ public void When_a_read_only_dictionary_does_not_match_the_expectation_it_should // #930 public void When_a_dictionary_is_compared_to_null_it_should_not_throw_a_NullReferenceException() { - //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- diff --git a/Tests/Shared.Specs/EventAssertionSpecs.cs b/Tests/Shared.Specs/EventAssertionSpecs.cs index a73711f87c..663a6cb415 100644 --- a/Tests/Shared.Specs/EventAssertionSpecs.cs +++ b/Tests/Shared.Specs/EventAssertionSpecs.cs @@ -18,7 +18,7 @@ namespace FluentAssertions.Specs [Collection("EventMonitoring")] public class EventAssertionSpecs { - #region ShouldRaise +#region ShouldRaise [Fact] public void When_asserting_an_event_that_doesnt_exist_it_should_throw() @@ -442,9 +442,9 @@ public void When_a_non_conventional_event_with_many_specific_arguments_was_not_r } } - #endregion +#endregion - #region Should(Not)RaisePropertyChanged events +#region Should(Not)RaisePropertyChanged events [Fact] public void When_a_property_changed_event_was_raised_for_the_expected_property_it_should_not_throw() @@ -633,9 +633,9 @@ public void When_monitoring_a_class_it_should_be_possible_to_attach_to_additiona } } - #endregion +#endregion - #region Precondition Checks +#region Precondition Checks [Fact] public void When_monitoring_a_null_object_it_should_throw() @@ -678,9 +678,9 @@ public void When_nesting_monitoring_requests_scopes_should_be_isolated() } } - #endregion +#endregion - #region Metadata +#region Metadata [Fact] public void When_monitoring_an_object_it_should_monitor_all_the_events_it_exposes() @@ -885,7 +885,7 @@ public void When_an_object_raises_two_events_it_should_provide_the_data_about_th } } - #endregion +#endregion public class ClassThatRaisesEventsItself : IEventRaisingInterface { diff --git a/Tests/Shared.Specs/ExceptionAssertionSpecs.cs b/Tests/Shared.Specs/ExceptionAssertionSpecs.cs index b1ed24a83b..1d62c5a807 100644 --- a/Tests/Shared.Specs/ExceptionAssertionSpecs.cs +++ b/Tests/Shared.Specs/ExceptionAssertionSpecs.cs @@ -1,12 +1,9 @@ using System; using System.Collections.Generic; +using FakeItEasy; using Xunit; using Xunit.Sdk; -using FakeItEasy; - -using FluentAssertions.Primitives; - namespace FluentAssertions.Specs { public class ExceptionAssertionSpecs @@ -746,7 +743,7 @@ public void When_a_2nd_condition_is_not_met_it_should_throw() exc.Message.Should().StartWith( "Expected exception where (e.Message == \"Error\"), but the condition was not met"); } - catch (Exception exc) + catch (Exception exc) { exc.Message.Should().StartWith( "Expected exception where (e.Message == \"Error\"), but the condition was not met"); diff --git a/Tests/Shared.Specs/MethodBaseAssertionSpecs.cs b/Tests/Shared.Specs/MethodBaseAssertionSpecs.cs index 74a5fa4639..bb17c7d426 100644 --- a/Tests/Shared.Specs/MethodBaseAssertionSpecs.cs +++ b/Tests/Shared.Specs/MethodBaseAssertionSpecs.cs @@ -1,7 +1,6 @@ using System; using System.Reflection; using FluentAssertions.Common; -using FluentAssertions.Types; using Xunit; using Xunit.Sdk; @@ -702,7 +701,7 @@ public void When_asserting_a_private_protected_member_is_not_private_it_succeeds //------------------------------------------------------------------------------------------------------------------- act.Should().NotThrow(); } - + [Fact] public void When_asserting_a_public_member_is_not_public_it_throws_with_a_useful_message() { diff --git a/Tests/Shared.Specs/MethodInfoAssertionSpecs.cs b/Tests/Shared.Specs/MethodInfoAssertionSpecs.cs index f068b70504..30af6159f7 100644 --- a/Tests/Shared.Specs/MethodInfoAssertionSpecs.cs +++ b/Tests/Shared.Specs/MethodInfoAssertionSpecs.cs @@ -1,9 +1,9 @@ -using FluentAssertions.Common; -using System; +using System; using System.Collections.Generic; using System.Reflection; using System.Runtime.CompilerServices; using System.Threading.Tasks; +using FluentAssertions.Common; using Xunit; using Xunit.Sdk; diff --git a/Tests/Shared.Specs/NullableBooleanAssertionSpecs.cs b/Tests/Shared.Specs/NullableBooleanAssertionSpecs.cs index cb3fefaea3..c08561931f 100644 --- a/Tests/Shared.Specs/NullableBooleanAssertionSpecs.cs +++ b/Tests/Shared.Specs/NullableBooleanAssertionSpecs.cs @@ -1,6 +1,4 @@ using System; - -using FluentAssertions.Execution; using Xunit; using Xunit.Sdk; diff --git a/Tests/Shared.Specs/NullableSimpleTimeSpanAssertionSpecs.cs b/Tests/Shared.Specs/NullableSimpleTimeSpanAssertionSpecs.cs index 9958eeacad..d8c706aa71 100644 --- a/Tests/Shared.Specs/NullableSimpleTimeSpanAssertionSpecs.cs +++ b/Tests/Shared.Specs/NullableSimpleTimeSpanAssertionSpecs.cs @@ -1,9 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using FluentAssertions.Common; using FluentAssertions.Extensions; using Xunit; using Xunit.Sdk; diff --git a/Tests/Shared.Specs/ObjectCastingSpecs.cs b/Tests/Shared.Specs/ObjectCastingSpecs.cs index ce6653fd6a..9c73c73e68 100644 --- a/Tests/Shared.Specs/ObjectCastingSpecs.cs +++ b/Tests/Shared.Specs/ObjectCastingSpecs.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Xunit; +using Xunit; namespace FluentAssertions.Specs { diff --git a/Tests/Shared.Specs/PropertyInfoAssertionSpecs.cs b/Tests/Shared.Specs/PropertyInfoAssertionSpecs.cs index 0f30f40cc4..9aa7dfee1c 100644 --- a/Tests/Shared.Specs/PropertyInfoAssertionSpecs.cs +++ b/Tests/Shared.Specs/PropertyInfoAssertionSpecs.cs @@ -1,7 +1,6 @@ using System; using System.Reflection; using FluentAssertions.Common; -using FluentAssertions.Types; using Xunit; using Xunit.Sdk; diff --git a/Tests/Shared.Specs/ReferenceTypeAssertionsSpecs.cs b/Tests/Shared.Specs/ReferenceTypeAssertionsSpecs.cs index 146d3c6145..329ccd8e72 100644 --- a/Tests/Shared.Specs/ReferenceTypeAssertionsSpecs.cs +++ b/Tests/Shared.Specs/ReferenceTypeAssertionsSpecs.cs @@ -1,8 +1,5 @@ using System; - -using FluentAssertions.Common; using FluentAssertions.Extensions; -using FluentAssertions.Formatting; using Xunit; using Xunit.Sdk; diff --git a/Tests/Shared.Specs/SimpleTimeSpanAssertionSpecs.cs b/Tests/Shared.Specs/SimpleTimeSpanAssertionSpecs.cs index e3395b00d1..e812f52622 100644 --- a/Tests/Shared.Specs/SimpleTimeSpanAssertionSpecs.cs +++ b/Tests/Shared.Specs/SimpleTimeSpanAssertionSpecs.cs @@ -1,9 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using FluentAssertions.Common; using FluentAssertions.Extensions; using Xunit; using Xunit.Sdk; diff --git a/Tests/Shared.Specs/StringAssertionSpecs.cs b/Tests/Shared.Specs/StringAssertionSpecs.cs index 7d56e4e959..fe3fa09be1 100644 --- a/Tests/Shared.Specs/StringAssertionSpecs.cs +++ b/Tests/Shared.Specs/StringAssertionSpecs.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using FluentAssertions.Execution; using Xunit; using Xunit.Sdk; diff --git a/Tests/Shared.Specs/ThrowAssertionsSpecs.cs b/Tests/Shared.Specs/ThrowAssertionsSpecs.cs index 721133f542..6fd5058442 100644 --- a/Tests/Shared.Specs/ThrowAssertionsSpecs.cs +++ b/Tests/Shared.Specs/ThrowAssertionsSpecs.cs @@ -1,9 +1,8 @@ using System; +using FakeItEasy; using Xunit; using Xunit.Sdk; -using FakeItEasy; - namespace FluentAssertions.Specs { public class ThrowAssertionsSpecs diff --git a/Tests/Shared.Specs/TimeSpanConversionExtensionSpecs.cs b/Tests/Shared.Specs/TimeSpanConversionExtensionSpecs.cs index 19420904c3..c55967771e 100644 --- a/Tests/Shared.Specs/TimeSpanConversionExtensionSpecs.cs +++ b/Tests/Shared.Specs/TimeSpanConversionExtensionSpecs.cs @@ -1,5 +1,4 @@ using System; -using FluentAssertions.Common; using FluentAssertions.Extensions; using Xunit; diff --git a/Tests/Shared.Specs/TypeExtensionsSpecs.cs b/Tests/Shared.Specs/TypeExtensionsSpecs.cs index 7dfa6fbe81..7c58ede4d9 100644 --- a/Tests/Shared.Specs/TypeExtensionsSpecs.cs +++ b/Tests/Shared.Specs/TypeExtensionsSpecs.cs @@ -1,8 +1,6 @@ -using System.Xml.Linq; -using System.Reflection; using System; using System.Linq; - +using System.Reflection; using FluentAssertions.Common; using Xunit; diff --git a/Tests/Shared.Specs/XmlNodeAssertionSpecs.cs b/Tests/Shared.Specs/XmlNodeAssertionSpecs.cs index be2d7edba6..af77e11e14 100644 --- a/Tests/Shared.Specs/XmlNodeAssertionSpecs.cs +++ b/Tests/Shared.Specs/XmlNodeAssertionSpecs.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Xml; using Xunit; using Xunit.Sdk; diff --git a/Tests/TestFrameworks/NSpec.Net45.Specs/FrameworkSpecs.cs b/Tests/TestFrameworks/NSpec.Net45.Specs/FrameworkSpecs.cs index a5d26e76ef..8ec755f85f 100644 --- a/Tests/TestFrameworks/NSpec.Net45.Specs/FrameworkSpecs.cs +++ b/Tests/TestFrameworks/NSpec.Net45.Specs/FrameworkSpecs.cs @@ -1,6 +1,5 @@ using System; using FluentAssertions; -using NSpec; namespace NSpec.Specs {