@@ -23,13 +23,13 @@ public static void ValidateTupleReturnType(MethodInfo method)
23
23
ThrowHelper . MethodReturnsInvalidValueTuple ( method ) ;
24
24
}
25
25
26
- if ( method . ReturnParameter . IsDefined ( typeof ( TupleElementNamesAttribute ) ) )
26
+ TupleElementNamesAttribute attribute =
27
+ method . ReturnParameter . GetCustomAttribute < TupleElementNamesAttribute > ( ) ;
28
+
29
+ if ( attribute != null )
27
30
{
28
31
int tupleLength = tupleType . GetValueTupleLength ( ) ;
29
32
30
- TupleElementNamesAttribute attribute =
31
- method . ReturnParameter . GetCustomAttribute < TupleElementNamesAttribute > ( ) ;
32
-
33
33
IList < string > transformNames = attribute . TransformNames ;
34
34
35
35
List < string > tupleNames =
@@ -123,19 +123,19 @@ public static void ValidateProgressiveMethod(MethodInfo method)
123
123
124
124
private static void ValidateTupleReturnTypeOfProgressiveMethod ( MethodInfo method , ParameterInfo lastParameter )
125
125
{
126
- bool methodHasAttribute = method . ReturnParameter . IsDefined ( typeof ( TupleElementNamesAttribute ) ) ;
127
- bool parameterHasAttributte = lastParameter . IsDefined ( typeof ( TupleElementNamesAttribute ) ) ;
126
+ TupleElementNamesAttribute methodAttribute =
127
+ method . ReturnParameter . GetCustomAttribute < TupleElementNamesAttribute > ( ) ;
128
+
129
+ TupleElementNamesAttribute parameterAttribute =
130
+ lastParameter . GetCustomAttribute < TupleElementNamesAttribute > ( ) ;
131
+
132
+ bool methodHasAttribute = methodAttribute != null ;
133
+ bool parameterHasAttributte = parameterAttribute != null ;
128
134
129
135
bool attributesMatch = methodHasAttribute == parameterHasAttributte ;
130
136
131
137
if ( methodHasAttribute && parameterHasAttributte )
132
138
{
133
- TupleElementNamesAttribute methodAttribute =
134
- method . ReturnParameter . GetCustomAttribute < TupleElementNamesAttribute > ( ) ;
135
-
136
- TupleElementNamesAttribute parameterAttribute =
137
- lastParameter . GetCustomAttribute < TupleElementNamesAttribute > ( ) ;
138
-
139
139
IList < string > methodTransformNames = methodAttribute . TransformNames ;
140
140
IList < string > parameterTransformNames = parameterAttribute . TransformNames ;
141
141
0 commit comments