diff --git a/Src/FluentAssertions/Types/MethodBaseAssertions.cs b/Src/FluentAssertions/Types/MethodBaseAssertions.cs index 7ab268bbb7..fd92a50dc9 100644 --- a/Src/FluentAssertions/Types/MethodBaseAssertions.cs +++ b/Src/FluentAssertions/Types/MethodBaseAssertions.cs @@ -52,7 +52,7 @@ public AndConstraint HaveAccessModifier( .ForCondition(accessModifier == subjectAccessModifier) .BecauseOf(because, becauseArgs) .FailWith( - $"Expected method {Subject.Name} to be {accessModifier}{{reason}}, but it is {subjectAccessModifier}."); + $"Expected method {Subject!.Name} to be {accessModifier}{{reason}}, but it is {subjectAccessModifier}."); } return new AndConstraint((TAssertions)this); @@ -88,7 +88,7 @@ public AndConstraint NotHaveAccessModifier(CSharpAccessModifier acc Execute.Assertion .ForCondition(accessModifier != subjectAccessModifier) .BecauseOf(because, becauseArgs) - .FailWith($"Expected method {Subject.Name} not to be {accessModifier}{{reason}}, but it is."); + .FailWith($"Expected method {Subject!.Name} not to be {accessModifier}{{reason}}, but it is."); } return new AndConstraint((TAssertions)this); diff --git a/Src/FluentAssertions/Types/MethodInfoAssertions.cs b/Src/FluentAssertions/Types/MethodInfoAssertions.cs index cafd02b3de..6d5cfde4f1 100644 --- a/Src/FluentAssertions/Types/MethodInfoAssertions.cs +++ b/Src/FluentAssertions/Types/MethodInfoAssertions.cs @@ -150,7 +150,7 @@ public AndConstraint> Ret if (success) { Execute.Assertion - .ForCondition(typeof(void) == Subject.ReturnType) + .ForCondition(typeof(void) == Subject!.ReturnType) .BecauseOf(because, becauseArgs) .FailWith("Expected the return type of method " + Subject.Name + " to be void{reason}, but it is {0}.", Subject.ReturnType.FullName); @@ -184,7 +184,7 @@ public AndConstraint> Ret if (success) { Execute.Assertion - .ForCondition(returnType == Subject.ReturnType) + .ForCondition(returnType == Subject!.ReturnType) .BecauseOf(because, becauseArgs) .FailWith("Expected the return type of method " + Subject.Name + " to be {0}{reason}, but it is {1}.", returnType, Subject.ReturnType.FullName); @@ -231,7 +231,7 @@ public AndConstraint> Not if (success) { Execute.Assertion - .ForCondition(typeof(void) != Subject.ReturnType) + .ForCondition(typeof(void) != Subject!.ReturnType) .BecauseOf(because, becauseArgs) .FailWith("Expected the return type of method " + Subject.Name + " not to be void{reason}, but it is."); } @@ -265,7 +265,7 @@ public AndConstraint> Not if (success) { Execute.Assertion - .ForCondition(returnType != Subject.ReturnType) + .ForCondition(returnType != Subject!.ReturnType) .BecauseOf(because, becauseArgs) .FailWith( "Expected the return type of method " + Subject.Name + " not to be {0}{reason}, but it is.", returnType); diff --git a/Src/FluentAssertions/Types/PropertyInfoAssertions.cs b/Src/FluentAssertions/Types/PropertyInfoAssertions.cs index e8f329d04f..a0476b243c 100644 --- a/Src/FluentAssertions/Types/PropertyInfoAssertions.cs +++ b/Src/FluentAssertions/Types/PropertyInfoAssertions.cs @@ -95,7 +95,7 @@ public AndConstraint BeWritable( if (success) { Execute.Assertion - .ForCondition(Subject.CanWrite) + .ForCondition(Subject!.CanWrite) .BecauseOf(because, becauseArgs) .FailWith( "Expected {context:property} {0} to have a setter{reason}.", @@ -132,7 +132,7 @@ public AndConstraint BeWritable(CSharpAccessModifier acc { Subject.Should().BeWritable(because, becauseArgs); - Subject.GetSetMethod(nonPublic: true).Should().HaveAccessModifier(accessModifier, because, becauseArgs); + Subject!.GetSetMethod(nonPublic: true).Should().HaveAccessModifier(accessModifier, because, becauseArgs); } return new AndConstraint(this); @@ -159,7 +159,7 @@ public AndConstraint NotBeWritable( if (success) { Execute.Assertion - .ForCondition(!Subject.CanWrite) + .ForCondition(!Subject!.CanWrite) .BecauseOf(because, becauseArgs) .FailWith( "Expected {context:property} {0} not to have a setter{reason}.", @@ -188,7 +188,7 @@ public AndConstraint BeReadable(string because = "", par if (success) { - Execute.Assertion.ForCondition(Subject.CanRead) + Execute.Assertion.ForCondition(Subject!.CanRead) .BecauseOf(because, becauseArgs) .FailWith("Expected property " + Subject.Name + " to have a getter{reason}, but it does not."); } @@ -223,7 +223,7 @@ public AndConstraint BeReadable(CSharpAccessModifier acc { Subject.Should().BeReadable(because, becauseArgs); - Subject.GetGetMethod(nonPublic: true).Should().HaveAccessModifier(accessModifier, because, becauseArgs); + Subject!.GetGetMethod(nonPublic: true).Should().HaveAccessModifier(accessModifier, because, becauseArgs); } return new AndConstraint(this); @@ -250,7 +250,7 @@ public AndConstraint NotBeReadable( if (success) { Execute.Assertion - .ForCondition(!Subject.CanRead) + .ForCondition(!Subject!.CanRead) .BecauseOf(because, becauseArgs) .FailWith( "Expected {context:property} {0} not to have a getter{reason}.", @@ -284,7 +284,7 @@ public AndConstraint Return(Type propertyType, if (success) { - Execute.Assertion.ForCondition(Subject.PropertyType == propertyType) + Execute.Assertion.ForCondition(Subject!.PropertyType == propertyType) .BecauseOf(because, becauseArgs) .FailWith("Expected Type of property " + Subject.Name + " to be {0}{reason}, but it is {1}.", propertyType, Subject.PropertyType); @@ -333,7 +333,7 @@ public AndConstraint NotReturn(Type propertyType, string if (success) { Execute.Assertion - .ForCondition(Subject.PropertyType != propertyType) + .ForCondition(Subject!.PropertyType != propertyType) .BecauseOf(because, becauseArgs) .FailWith("Expected Type of property " + Subject.Name + " not to be {0}{reason}, but it is.", propertyType); }