@@ -51,7 +51,7 @@ protected override MethodProvider[] BuildMethods()
5151 {
5252 var getCachedClientMethod = getCachedClientMethods [ mockableResource . ArmCoreType ] ;
5353 redirectedMethods . AddRange (
54- mockableResource . Methods . Select ( m => BuildRedirectMethod ( mockableResource . ArmCoreType , m , getCachedClientMethod ) )
54+ mockableResource . Methods . Select ( m => BuildRedirectMethod ( mockableResource , m , getCachedClientMethod ) )
5555 ) ;
5656 }
5757
@@ -83,10 +83,10 @@ private MethodProvider BuildGetCachedClientMethod(MockableResourceProvider mocka
8383 return new MethodProvider ( methodSignature , statements , this ) ;
8484 }
8585
86- private MethodProvider BuildRedirectMethod ( CSharpType coreType , MethodProvider targetMethod , MethodProvider getCachedClientMethod )
86+ private MethodProvider BuildRedirectMethod ( MockableResourceProvider mockableResource , MethodProvider targetMethod , MethodProvider getCachedClientMethod )
8787 {
88+ var coreType = mockableResource . ArmCoreType ;
8889 var target = targetMethod . Signature ;
89- // TODO -- add mocking information in method description
9090 var extensionParameter = new ParameterProvider (
9191 GetArmCoreTypeVariableName ( coreType ) ,
9292 $ "The { coreType : C} the method will execute against.",
@@ -121,7 +121,12 @@ private MethodProvider BuildRedirectMethod(CSharpType coreType, MethodProvider t
121121 }
122122 }
123123
124- return new MethodProvider( methodSignature , body , this ) ;
124+ var method = new MethodProvider( methodSignature , body , this ) ;
125+
126+ // Add mocking documentation
127+ AddMockingDocumentation( method , mockableResource , targetMethod ) ;
128+
129+ return method;
125130
126131 static ParameterProvider DuplicateParameter( ParameterProvider original )
127132 {
@@ -140,6 +145,42 @@ static ParameterProvider DuplicateParameter(ParameterProvider original)
140145 }
141146 }
142147
148+ private void AddMockingDocumentation( MethodProvider method , MockableResourceProvider mockableResource , MethodProvider targetMethod )
149+ {
150+ if ( method . XmlDocs == null )
151+ {
152+ return ;
153+ }
154+
155+ // Build the mocking documentation item
156+ // Format: To mock this method, please mock <see cref="MockableType.MethodName(params)"/> instead.
157+ var mockingDescription = BuildMockingDescription( mockableResource . Type , targetMethod . Signature ) ;
158+ var mockingItem = new XmlDocStatement( "item" , [ ] ,
159+ new XmlDocStatement ( "term" , [ $ "Mocking"] ) ,
160+ new XmlDocStatement ( "description" , [ mockingDescription ] ) ) ;
161+
162+ // Create a new summary with the existing description and the mocking item
163+ // The targetMethod already has the description we want to keep
164+ var descriptionText = targetMethod. Signature . Description ?? $ "";
165+ var updatedSummary = new XmlDocSummaryStatement ( [ descriptionText ] , mockingItem ) ;
166+ method. XmlDocs . Update ( summary : updatedSummary ) ;
167+ }
168+
169+ private FormattableString BuildMockingDescription( CSharpType mockableType , MethodSignature targetSignature )
170+ {
171+ // Build description: "To mock this method, please mock <see cref="MockableType.MethodName(params)"/> instead."
172+ // We need to construct a method reference that includes parameter types
173+ // In C# XML docs, method references look like: MethodName(TypeName1, TypeName2)
174+
175+ // Build parameter type list as a simple string since XML doc cref attributes use simple type names
176+ var parameterTypeNames = string . Join ( ", " , targetSignature . Parameters . Select ( p => p . Type . Name ) ) ;
177+ var methodRef = $"{mockableType.Name}.{targetSignature.Name}({parameterTypeNames})" ;
178+
179+ // Return a FormattableString that will be converted to: To mock this method, please mock <see cref="..."/> instead.
180+ // The :C formatter on mockableType will create the <see cref> tag
181+ return $"To mock this method, please mock <see cref=\" {methodRef}\" /> instead." ;
182+ }
183+
143184 private string GetArmCoreTypeVariableName( CSharpType armCoreType )
144185 {
145186 if ( armCoreType . Equals ( typeof ( ArmClient ) ) )
0 commit comments