Rewrite Method Member Syntax Elements Tests and Refactor Method Member Syntax Elements#465
Rewrite Method Member Syntax Elements Tests and Refactor Method Member Syntax Elements#465alexanderlinne wants to merge 2 commits into
Conversation
Signed-off-by: Alexander Linne <alexander.linne@tngtech.com>
Signed-off-by: Alexander Linne <alexander.linne@tngtech.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #465 +/- ##
==========================================
+ Coverage 79.97% 82.89% +2.91%
==========================================
Files 259 259
Lines 13326 12548 -778
Branches 1240 1194 -46
==========================================
- Hits 10658 10402 -256
+ Misses 2291 1785 -506
+ Partials 377 361 -16 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| public TNextElement HaveReturnType(IObjectProvider<IType> types) => CreateNextElement(MethodMemberConditionsDefinition.HaveReturnType(types)); | ||
| public TNextElement HaveReturnType(Type type, params Type[] moreTypes) => CreateNextElement(MethodMemberConditionsDefinition.HaveReturnType(type, moreTypes)); | ||
| public TNextElement HaveReturnType(IEnumerable<IType> types) => HaveReturnType(new ObjectProvider<IType>(types)); | ||
| public TNextElement HaveReturnType(IEnumerable<Type> types) => CreateNextElement(MethodMemberConditionsDefinition.HaveReturnType(types)); |
There was a problem hiding this comment.
Was this an oversight or left out on purpose? Same for NotHaveReturnType(IEnumerable<Type> types) further below in this same file and for the corresponding method calls in AddMethodMemberPredicate.cs.
| public TNextElement HaveReturnType(IEnumerable<Type> types) => CreateNextElement(MethodMemberConditionsDefinition.HaveReturnType(types)); | |
| public TNextElement HaveReturnType(IEnumerable<Type> types) => HaveReturnType(new SystemTypeObjectProvider<IType>(types)); |
There was a problem hiding this comment.
I just realized that there are still two versions of HaveReturnType depending on the input arguments in MethodMemberConditionDefinition.cs but I'm still not exactly sure if this was on purpose and if so why. Let's have a chat about this the next time.
| should.NotHaveReturnType(helper.OtherRegularClassSystemType, helper.RegularClassSystemType).AssertOnlyViolations(helper); | ||
| should.NotHaveReturnType(new List<System.Type> { helper.OtherRegularClassSystemType, helper.RegularClassSystemType }).AssertOnlyViolations(helper); | ||
|
|
||
| // DoNotHaveReturnType predicate now uses consistent set-based semantics — |
There was a problem hiding this comment.
Praise: good catch of the error in the prior implementation. :)
|
|
||
| Query: Method members that are "System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod()" should be called by one of no types (impossible) | ||
| Result: False | ||
| Description: System.Void MethodDependencyNamespace.MethodDependencyClass::CalledMethod() is not called by |
There was a problem hiding this comment.
Nitpick: The description is not ending correctly in this case. If it is easy to fix we should do so. If it isn't I guess it would still be okay since it is only an edge case.
|
|
||
| ----- Conditions ----- | ||
|
|
||
| Query: Method members that are "TypeNamespace.GenericClass`1<TypeNamespace.RegularClass> TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass()" should not have return type "TypeNamespace.GenericClass`1[[TypeNamespace.RegularClass, TypeAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=015f... |
There was a problem hiding this comment.
Nitpick: The description of the generic type is pretty verbose (including assembly name, version, culture, ...) and should be shortened if possible.
|
|
||
| Query: Method members that are "TypeNamespace.GenericClass`1<TypeNamespace.RegularClass> TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass()" should not have return type "TypeNamespace.GenericClass`1[[TypeNamespace.RegularClass, TypeAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=015f... | ||
| Result: False | ||
| Description: TypeNamespace.GenericClass`1<TypeNamespace.RegularClass> TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() has return type "TypeNamespace.GenericClass`1" |
There was a problem hiding this comment.
In contrast: Here the description is actually to short since it is missing the actual generic type - this leads to a rather confusing error message in the end...
| Description: TypeNamespace.GenericClass`1<TypeNamespace.RegularClass> TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() has return type "TypeNamespace.GenericClass`1" | ||
| Message: | ||
| "Method members that are "TypeNamespace.GenericClass`1<TypeNamespace.RegularClass> TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass()" should have return type "TypeNamespace.GenericClass`1[[TypeNamespace.OtherRegularClass, TypeAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=015..." failed: | ||
| TypeNamespace.GenericClass`1<TypeNamespace.RegularClass> TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() has return type "TypeNamespace.GenericClass`1" |
There was a problem hiding this comment.
See comment in MethodMemberSyntaxElementsTests.DoNotHaveReturnTypeTest.verified.txt - here the error message is actually wrong now because of this.
| Description: TypeNamespace.GenericClass`1<TypeNamespace.RegularClass> TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() has return type "TypeNamespace.GenericClass`1" | ||
| Message: | ||
| "Method members that are "TypeNamespace.GenericClass`1<TypeNamespace.RegularClass> TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass()" should have return type "TypeNamespace.GenericClass`1[[TypeNamespace.OtherRegularClass, TypeAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=015..." failed: | ||
| TypeNamespace.GenericClass`1<TypeNamespace.RegularClass> TypeNamespace.ClassWithGenericReturnType::MethodReturningGenericClass() has return type "TypeNamespace.GenericClass`1" |
There was a problem hiding this comment.
See comment in MethodMemberSyntaxElementsTests.DoNotHaveReturnTypeTest.verified.txt - here the error message is actually wrong now because of this.
Note: there are still two implementations of
HaveReturnType/NotHaveReturnTypeto keep the current differences in howSystem.TypeandITypeare handled.