@@ -15,7 +15,9 @@ public class MethodProvider
15
15
public MethodSignature Signature { get ; private set ; }
16
16
public MethodBodyStatement ? BodyStatements { get ; private set ; }
17
17
public ValueExpression ? BodyExpression { get ; private set ; }
18
- public XmlDocProvider ? XmlDocs { get ; private set ; }
18
+
19
+ public XmlDocProvider ? XmlDocs => _xmlDocs ??= BuildXmlDocs ( ) ;
20
+ private XmlDocProvider ? _xmlDocs ;
19
21
20
22
public TypeProvider EnclosingType { get ; }
21
23
@@ -37,9 +39,9 @@ public MethodProvider(MethodSignature signature, MethodBodyStatement bodyStateme
37
39
{
38
40
Signature = signature ;
39
41
bool skipParamValidation = ! signature . Modifiers . HasFlag ( MethodSignatureModifiers . Public ) ;
40
- var paramHash = MethodProviderHelpers . GetParamhash ( signature . Parameters , skipParamValidation ) ;
42
+ var paramHash = MethodProviderHelpers . GetParamHash ( signature . Parameters , skipParamValidation ) ;
41
43
BodyStatements = MethodProviderHelpers . GetBodyStatementWithValidation ( signature . Parameters , bodyStatements , paramHash ) ;
42
- XmlDocs = xmlDocProvider ?? MethodProviderHelpers . BuildXmlDocs ( signature . Parameters , signature . Description , signature . ReturnDescription , paramHash ) ;
44
+ _xmlDocs = xmlDocProvider ;
43
45
EnclosingType = enclosingType ;
44
46
}
45
47
@@ -54,10 +56,23 @@ public MethodProvider(MethodSignature signature, ValueExpression bodyExpression,
54
56
{
55
57
Signature = signature ;
56
58
BodyExpression = bodyExpression ;
57
- XmlDocs = xmlDocProvider ?? MethodProviderHelpers . BuildXmlDocs ( signature . Parameters , signature . Description , signature . ReturnDescription , null ) ;
59
+ _xmlDocs = xmlDocProvider ;
58
60
EnclosingType = enclosingType ;
59
61
}
60
62
63
+ private XmlDocProvider ? BuildXmlDocs ( )
64
+ {
65
+ return MethodProviderHelpers . BuildXmlDocs (
66
+ Signature . Parameters ,
67
+ Signature . Description ,
68
+ Signature . ReturnDescription ,
69
+ BodyStatements != null ?
70
+ MethodProviderHelpers . GetParamHash (
71
+ Signature . Parameters ,
72
+ ! Signature . Modifiers . HasFlag ( MethodSignatureModifiers . Public ) ) :
73
+ null ) ;
74
+ }
75
+
61
76
public void Update (
62
77
MethodSignature ? signature = null ,
63
78
MethodBodyStatement ? bodyStatements = null ,
@@ -67,6 +82,8 @@ public void Update(
67
82
if ( signature != null )
68
83
{
69
84
Signature = signature ;
85
+ // rebuild the XML docs if the signature changes
86
+ _xmlDocs = BuildXmlDocs ( ) ;
70
87
}
71
88
if ( bodyStatements != null )
72
89
{
@@ -80,7 +97,7 @@ public void Update(
80
97
}
81
98
if ( xmlDocProvider != null )
82
99
{
83
- XmlDocs = xmlDocProvider ;
100
+ _xmlDocs = xmlDocProvider ;
84
101
}
85
102
}
86
103
}
0 commit comments