118 references to AIJsonUtilities
Microsoft.Extensions.AI (12)
Microsoft.Extensions.AI.Abstractions (23)
Functions\AIFunctionFactory.cs (13)
94/// or else using <see cref="AIJsonUtilities.DefaultOptions"/>. If the argument is anything else, it is round-tripped through JSON, serializing the object as JSON
105/// <see cref="AIFunctionFactoryOptions.SerializerOptions"/> if provided, or else using <see cref="AIJsonUtilities.DefaultOptions"/>.
168/// <see cref="AIJsonUtilities.DefaultOptions"/>. If the argument is anything else, it is round-tripped through JSON, serializing the object as JSON
179/// or else using <see cref="AIJsonUtilities.DefaultOptions"/>.
257/// or else using <see cref="AIJsonUtilities.DefaultOptions"/>. If the argument is anything else, it is round-tripped through JSON, serializing the object as JSON
268/// <see cref="AIFunctionFactoryOptions.SerializerOptions"/> if provided, or else using <see cref="AIJsonUtilities.DefaultOptions"/>.
341/// <see cref="AIJsonUtilities.DefaultOptions"/>. If the argument is anything else, it is round-tripped through JSON, serializing the object as JSON
352/// or else using <see cref="AIJsonUtilities.DefaultOptions"/>.
443/// or else using <see cref="AIJsonUtilities.DefaultOptions"/>. If the argument is anything else, it is round-tripped through JSON, serializing the object as JSON
454/// <see cref="AIFunctionFactoryOptions.SerializerOptions"/> if provided, or else using <see cref="AIJsonUtilities.DefaultOptions"/>.
613JsonSerializerOptions serializerOptions = options.SerializerOptions ?? AIJsonUtilities.DefaultOptions;
693ReturnJsonSchema = returnType is null || key.ExcludeResultSchema ? null : AIJsonUtilities.CreateJsonSchema(
699JsonSchema = AIJsonUtilities.CreateFunctionJsonSchema(
Microsoft.Extensions.AI.Abstractions.Tests (55)
Utilities\AIJsonUtilitiesTests.cs (47)
30var options = AIJsonUtilities.DefaultOptions;
34Assert.Same(options, AIJsonUtilities.DefaultOptions);
56var options = AIJsonUtilities.DefaultOptions;
66var options = AIJsonUtilities.DefaultOptions;
70Assert.Equal(JsonSerializer.IsReflectionEnabledByDefault, AIJsonUtilities.DefaultOptions.TryGetTypeInfo(anonType, out _));
168JsonElement actual = AIJsonUtilities.CreateJsonSchema(typeof(MyPoco), serializerOptions: JsonContext.Default.Options);
211JsonElement actual = AIJsonUtilities.CreateJsonSchema(
261JsonElement actual = AIJsonUtilities.CreateJsonSchema(typeof(MyPoco), serializerOptions: JsonContext.Default.Options, inferenceOptions: inferenceOptions);
269JsonSerializerOptions options = new(AIJsonUtilities.DefaultOptions);
274JsonElement resolvedSchema = AIJsonUtilities.CreateFunctionJsonSchema(func.UnderlyingMethod, title: string.Empty);
337JsonElement resolvedSchema = AIJsonUtilities.CreateFunctionJsonSchema(func.UnderlyingMethod, title: string.Empty, description: string.Empty, inferenceOptions: inferenceOptions);
344JsonSerializerOptions options = new(AIJsonUtilities.DefaultOptions) { NumberHandling = JsonNumberHandling.AllowReadingFromString };
394JsonElement schema = AIJsonUtilities.CreateJsonSchema(typeof(object));
413JsonElement schema = AIJsonUtilities.CreateJsonSchema(testData.Type, serializerOptions: options, inferenceOptions: createOptions);
438JsonElement schema = AIJsonUtilities.CreateJsonSchema(typeof(AIContent), serializerOptions: options);
442Assert.Same(options.TypeInfoResolver, AIJsonUtilities.DefaultOptions.TypeInfoResolver);
455JsonElement schema = AIJsonUtilities.CreateJsonSchema(typeof(MyEnumValue?), serializerOptions: JsonContext.Default.Options);
690AIJsonUtilities.CreateJsonSchema(typeof(CreateJsonSchema_IncorporatesTypesAndAnnotations_Type), serializerOptions: JsonContext.Default.Options));
849AIJsonUtilities.CreateJsonSchema(typeof(CreateJsonSchema_IncorporatesTypesAndAnnotations_Type), serializerOptions: JsonContext.Default.Options));
945TypeInfoResolver = JsonTypeInfoResolver.Combine(AIJsonUtilities.DefaultOptions.TypeInfoResolver, JsonContext.Default),
961Assert.Throws<InvalidOperationException>(() => AIJsonUtilities.DefaultOptions.AddAIContentType<DerivedAIContent>("derivativeContent"));
1008TypeInfoResolver = AIJsonUtilities.DefaultOptions.TypeInfoResolver
1011foreach (JsonSerializerOptions? options in new[] { AIJsonUtilities.DefaultOptions, null, customOptions })
1013string key1 = AIJsonUtilities.HashDataToString(["a", 'b', 42], options);
1014string key2 = AIJsonUtilities.HashDataToString(["a", 'b', 42], options);
1015string key3 = AIJsonUtilities.HashDataToString([TimeSpan.FromSeconds(1), null, 1.23], options);
1016string key4 = AIJsonUtilities.HashDataToString([TimeSpan.FromSeconds(1), null, 1.23], options);
1017string key5 = AIJsonUtilities.HashDataToString([new Dictionary<string, object> { ["key1"] = 1, ["key2"] = 2 }], options);
1018string key6 = AIJsonUtilities.HashDataToString([new Dictionary<string, object> { ["key2"] = 2, ["key1"] = 1 }], options);
1031JsonSerializerOptions indentOptions = new(AIJsonUtilities.DefaultOptions) { WriteIndented = true };
1032JsonSerializerOptions noIndentOptions = new(AIJsonUtilities.DefaultOptions) { WriteIndented = false };
1035string key1 = AIJsonUtilities.HashDataToString([dict], indentOptions);
1036string key2 = AIJsonUtilities.HashDataToString([dict], noIndentOptions);
1047JsonElement schema = AIJsonUtilities.CreateFunctionJsonSchema(method.Method, inferenceOptions: new()
1096JsonElement transformedSchema = AIJsonUtilities.TransformSchema(schema, options);
1130JsonElement transformedSchema = AIJsonUtilities.TransformSchema(schema, options);
1165JsonElement transformedSchema = AIJsonUtilities.TransformSchema(schema, options);
1202JsonElement transformedSchema = AIJsonUtilities.TransformSchema(schema, options);
1229JsonElement transformedSchema = AIJsonUtilities.TransformSchema(schema, options);
1248JsonElement schema = AIJsonUtilities.CreateJsonSchema(testData.Type, serializerOptions: options, inferenceOptions: createOptions);
1266JsonElement transformedSchema = AIJsonUtilities.TransformSchema(schema, transformOptions);
1293AIJsonUtilities.TransformSchema(transformedSchema, transformOptions);
1301Assert.Throws<ArgumentNullException>(() => AIJsonUtilities.TransformSchema(schema, transformOptions: null!));
1302Assert.Throws<ArgumentException>(() => AIJsonUtilities.TransformSchema(schema, transformOptions: new()));
1315Assert.Throws<ArgumentException>(() => AIJsonUtilities.TransformSchema(schema, transformOptions));
1336JsonSerializer.SerializeToNode(element1, AIJsonUtilities.DefaultOptions),
1337JsonSerializer.SerializeToNode(element2, AIJsonUtilities.DefaultOptions));
Microsoft.Extensions.AI.AzureAIInference (7)
Microsoft.Extensions.AI.AzureAIInference.Tests (3)
Microsoft.Extensions.AI.Evaluation.Quality (2)
Microsoft.Extensions.AI.Evaluation.Reporting (1)
Microsoft.Extensions.AI.Evaluation.Reporting.Azure (1)
Microsoft.Extensions.AI.Integration.Tests (1)
Microsoft.Extensions.AI.OpenAI (4)
Microsoft.Extensions.AI.OpenAI.Tests (3)
Microsoft.Extensions.AI.Tests (6)