File tree 1 file changed +7
-1
lines changed
1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -85,10 +85,12 @@ private void AnalyzeMemberAccessExpression(SyntaxNodeAnalysisContext context)
85
85
86
86
// 获取实体类 ChildType标签的约束类型
87
87
INamedTypeSymbol ? availableChildTypeSymbol = null ;
88
+ bool hasChildTypeAttribute = false ;
88
89
foreach ( AttributeData ? attributeData in parentTypeSymbol . GetAttributes ( ) )
89
90
{
90
91
if ( attributeData . AttributeClass ? . Name == "ChildTypeAttribute" )
91
92
{
93
+ hasChildTypeAttribute = true ;
92
94
if ( ! ( attributeData . ConstructorArguments [ 0 ] . Value is INamedTypeSymbol s ) )
93
95
{
94
96
continue ;
@@ -98,7 +100,10 @@ private void AnalyzeMemberAccessExpression(SyntaxNodeAnalysisContext context)
98
100
}
99
101
}
100
102
101
-
103
+ if ( hasChildTypeAttribute && ( availableChildTypeSymbol == null ) )
104
+ {
105
+ return ;
106
+ }
102
107
103
108
// 获取 child实体类型
104
109
ISymbol ? childTypeSymbol = null ;
@@ -175,6 +180,7 @@ private void AnalyzeMemberAccessExpression(SyntaxNodeAnalysisContext context)
175
180
return ;
176
181
}
177
182
183
+
178
184
// 判断child类型是否属于约束类型
179
185
if ( availableChildTypeSymbol ? . ToString ( ) == childTypeSymbol . ToString ( ) )
180
186
{
You can’t perform that action at this time.
0 commit comments