@@ -117,6 +117,7 @@ public async Task Parameters_MissingRequiredParametersFail_Async()
117117 AIFunctionFactory . Create ( ( string ? theParam ) => theParam + " " + theParam ) ,
118118 AIFunctionFactory . Create ( ( int theParam ) => theParam * 2 ) ,
119119 AIFunctionFactory . Create ( ( int ? theParam ) => theParam * 2 ) ,
120+ AIFunctionFactory . Create ( ( [ AIParameterName ( "theParam" ) ] string otherName ) => otherName ) ,
120121 ] ;
121122
122123 foreach ( AIFunction f in funcs )
@@ -335,19 +336,29 @@ public void Metadata_AIFunctionNameAttribute()
335336 Assert . Equal ( "options_name" , func . Name ) ;
336337 }
337338
339+ [ Fact ]
340+ public void Metadata_AIFunctionAndParameterNameAttributes_PreservedByAsDeclarationOnly ( )
341+ {
342+ AIFunction func = AIFunctionFactory . Create ( [ AIFunctionName ( "my_tool" ) ] ( [ AIParameterName ( "my_param" ) ] string myParam ) => myParam ) ;
343+
344+ AIFunctionDeclaration declaration = func . AsDeclarationOnly ( ) ;
345+
346+ Assert . Equal ( "my_tool" , declaration . Name ) ;
347+ Assert . Equal ( func . JsonSchema . ToString ( ) , declaration . JsonSchema . ToString ( ) ) ;
348+ Assert . Contains ( "my_param" , declaration . JsonSchema . ToString ( ) ) ;
349+ Assert . IsNotAssignableFrom < AIFunction > ( declaration ) ;
350+ }
351+
338352 [ Fact ]
339353 public async Task Parameters_MappedByAIParameterNameAttribute_Async ( )
340354 {
341355 AIFunction func = AIFunctionFactory . Create ( ( [ AIParameterName ( "$select" ) ] string select , int top ) => select + top ) ;
342356
343357 AssertExtensions . EqualFunctionCallResults ( "Name2" , await func . InvokeAsync ( new ( ) { [ "$select" ] = "Name" , [ "top" ] = 2 } ) ) ;
344-
345- ArgumentException ex = await Assert . ThrowsAsync < ArgumentException > ( ( ) => func . InvokeAsync ( new ( ) { [ "top" ] = 2 } ) . AsTask ( ) ) ;
346- Assert . Contains ( "$select" , ex . Message ) ;
347358 }
348359
349360 [ Fact ]
350- public void AIParameterNameAttribute_OverridesSchemaPropertyName ( )
361+ public void Parameters_AIParameterNameAttribute_OverridesSchemaPropertyName ( )
351362 {
352363 AIFunction func = AIFunctionFactory . Create (
353364 ( [ AIParameterName ( "my_param" ) ] string myParam , int top ) => myParam + top ) ;
@@ -367,37 +378,7 @@ public void AIParameterNameAttribute_OverridesSchemaPropertyName()
367378 }
368379
369380 [ Fact ]
370- public async Task AIParameterNameAttribute_BindsArgumentByOverriddenName_Async ( )
371- {
372- AIFunction func = AIFunctionFactory . Create (
373- ( [ AIParameterName ( "$select" ) ] string select ,
374- [ AIParameterName ( "$expand" ) ] string expand ,
375- string filter ) =>
376- $ "select='{ select } ', expand='{ expand } ', filter='{ filter } '") ;
377-
378- object ? result = await func . InvokeAsync ( new ( )
379- {
380- [ "$select" ] = "Name,Id" ,
381- [ "$expand" ] = "Orders" ,
382- [ "filter" ] = "Active" ,
383- } ) ;
384-
385- AssertExtensions . EqualFunctionCallResults ( "select='Name,Id', expand='Orders', filter='Active'" , result ) ;
386- }
387-
388- [ Fact ]
389- public async Task AIParameterNameAttribute_MissingRequiredArgument_ReportsSchemaName_Async ( )
390- {
391- AIFunction func = AIFunctionFactory . Create (
392- ( [ AIParameterName ( "my_param" ) ] string myParam ) => myParam ) ;
393-
394- ArgumentException ex = await Assert . ThrowsAsync < ArgumentException > ( ( ) => func . InvokeAsync ( ) . AsTask ( ) ) ;
395-
396- Assert . Contains ( "my_param" , ex . Message ) ;
397- }
398-
399- [ Fact ]
400- public async Task AIParameterNameAttribute_HonoredByStrictUnmappedMemberHandling_Async ( )
381+ public async Task Parameters_AIParameterNameAttribute_StrictUnmappedMemberHandling_Async ( )
401382 {
402383 JsonSerializerOptions strictOptions = new ( AIJsonUtilities . DefaultOptions )
403384 {
@@ -418,7 +399,7 @@ public async Task AIParameterNameAttribute_HonoredByStrictUnmappedMemberHandling
418399 }
419400
420401 [ Fact ]
421- public async Task AIParameterNameAttribute_InheritedByOverride_Async ( )
402+ public async Task Parameters_AIParameterNameAttribute_InheritedByOverride_Async ( )
422403 {
423404 MethodInfo overrideMethod = typeof ( MyDerivedType ) . GetMethod ( nameof ( MyDerivedType . Method ) ) ! ;
424405 AIFunction func = AIFunctionFactory . Create ( overrideMethod , new MyDerivedType ( ) ) ;
@@ -430,31 +411,7 @@ public async Task AIParameterNameAttribute_InheritedByOverride_Async()
430411 }
431412
432413 [ Fact ]
433- public async Task AIFunctionAndParameterNameAttributes_BothHonored_Async ( )
434- {
435- AIFunction func = AIFunctionFactory . Create ( [ AIFunctionName ( "my_tool" ) ] ( [ AIParameterName ( "my_param" ) ] string myParam ) => myParam ) ;
436-
437- Assert . Equal ( "my_tool" , func . Name ) ;
438- Assert . Contains ( "my_param" , func . JsonSchema . ToString ( ) ) ;
439-
440- AssertExtensions . EqualFunctionCallResults ( "Name" , await func . InvokeAsync ( new ( ) { [ "my_param" ] = "Name" } ) ) ;
441- }
442-
443- [ Fact ]
444- public void AIFunctionAndParameterNameAttributes_NameAndParameterSchema_PreservedByAsDeclarationOnly ( )
445- {
446- AIFunction func = AIFunctionFactory . Create ( [ AIFunctionName ( "my_tool" ) ] ( [ AIParameterName ( "my_param" ) ] string myParam ) => myParam ) ;
447-
448- AIFunctionDeclaration declaration = func . AsDeclarationOnly ( ) ;
449-
450- Assert . Equal ( "my_tool" , declaration . Name ) ;
451- Assert . Equal ( func . JsonSchema . ToString ( ) , declaration . JsonSchema . ToString ( ) ) ;
452- Assert . Contains ( "my_param" , declaration . JsonSchema . ToString ( ) ) ;
453- Assert . IsNotAssignableFrom < AIFunction > ( declaration ) ;
454- }
455-
456- [ Fact ]
457- public void AIParameterNameAttribute_EscapesNameInJsonPointerRef ( )
414+ public void Parameters_AIParameterNameAttribute_EscapesJsonPointerRef ( )
458415 {
459416 JsonSerializerOptions options = new ( AIJsonUtilities . DefaultOptions ) { TypeInfoResolver = new DefaultJsonTypeInfoResolver ( ) } ;
460417
@@ -469,7 +426,7 @@ public void AIParameterNameAttribute_EscapesNameInJsonPointerRef()
469426 }
470427
471428 [ Fact ]
472- public void AIParameterNameAttribute_DuplicateNames_Throw ( )
429+ public void Parameters_AIParameterNameAttribute_DuplicateNames_Throw ( )
473430 {
474431 ArgumentException ex = Assert . Throws < ArgumentException > ( ( ) => AIFunctionFactory . Create (
475432 ( [ AIParameterName ( "dup" ) ] string first , [ AIParameterName ( "dup" ) ] string second ) => first + second ) ) ;
@@ -481,7 +438,7 @@ public void AIParameterNameAttribute_DuplicateNames_Throw()
481438 }
482439
483440 [ Fact ]
484- public void AIParameterNameAttribute_DuplicateNames_DetectedEvenWhenExcludedFromSchema ( )
441+ public void Parameters_AIParameterNameAttribute_DuplicateNames_ExcludedFromSchema ( )
485442 {
486443 // Validates that collision detection occurs in ExpectedArgumentNames collection
487444 // even when one of the colliding parameters is excluded from schema generation.
@@ -502,14 +459,6 @@ public void AIParameterNameAttribute_DuplicateNames_DetectedEvenWhenExcludedFrom
502459 Assert . Contains ( "AIParameterNameAttribute" , ex . Message ) ;
503460 }
504461
505- [ Fact ]
506- public void AIFunctionNameAttribute_DisplayNameAttribute_StillHonoredWhenNoAIFunctionNameAttribute ( )
507- {
508- AIFunction func = AIFunctionFactory . Create ( [ DisplayName ( "from-display-name" ) ] ( ) => "result" ) ;
509-
510- Assert . Equal ( "from-display-name" , func . Name ) ;
511- }
512-
513462 [ Fact ]
514463 public void AIFunctionFactory_InheritedDescriptionAttributes_OnOverride ( )
515464 {
0 commit comments