116 references to AIJsonUtilities
Microsoft.Extensions.AI (12)
Microsoft.Extensions.AI.Abstractions (23)
Functions\AIFunctionFactory.cs (13)
93/// or else using <see cref="AIJsonUtilities.DefaultOptions"/>. If the argument is anything else, it is round-tripped through JSON, serializing the object as JSON
104/// <see cref="AIFunctionFactoryOptions.SerializerOptions"/> if provided, or else using <see cref="AIJsonUtilities.DefaultOptions"/>.
167/// <see cref="AIJsonUtilities.DefaultOptions"/>. If the argument is anything else, it is round-tripped through JSON, serializing the object as JSON
178/// or else using <see cref="AIJsonUtilities.DefaultOptions"/>.
256/// or else using <see cref="AIJsonUtilities.DefaultOptions"/>. If the argument is anything else, it is round-tripped through JSON, serializing the object as JSON
267/// <see cref="AIFunctionFactoryOptions.SerializerOptions"/> if provided, or else using <see cref="AIJsonUtilities.DefaultOptions"/>.
340/// <see cref="AIJsonUtilities.DefaultOptions"/>. If the argument is anything else, it is round-tripped through JSON, serializing the object as JSON
351/// or else using <see cref="AIJsonUtilities.DefaultOptions"/>.
442/// or else using <see cref="AIJsonUtilities.DefaultOptions"/>. If the argument is anything else, it is round-tripped through JSON, serializing the object as JSON
453/// <see cref="AIFunctionFactoryOptions.SerializerOptions"/> if provided, or else using <see cref="AIJsonUtilities.DefaultOptions"/>.
612JsonSerializerOptions serializerOptions = options.SerializerOptions ?? AIJsonUtilities.DefaultOptions;
692ReturnJsonSchema = returnType is null ? null : AIJsonUtilities.CreateJsonSchema(
698JsonSchema = AIJsonUtilities.CreateFunctionJsonSchema(
Microsoft.Extensions.AI.Abstractions.Tests (54)
Utilities\AIJsonUtilitiesTests.cs (46)
25var options = AIJsonUtilities.DefaultOptions;
29Assert.Same(options, AIJsonUtilities.DefaultOptions);
51var options = AIJsonUtilities.DefaultOptions;
61var options = AIJsonUtilities.DefaultOptions;
65Assert.Equal(JsonSerializer.IsReflectionEnabledByDefault, AIJsonUtilities.DefaultOptions.TryGetTypeInfo(anonType, out _));
163JsonElement actual = AIJsonUtilities.CreateJsonSchema(typeof(MyPoco), serializerOptions: JsonContext.Default.Options);
206JsonElement actual = AIJsonUtilities.CreateJsonSchema(
256JsonElement actual = AIJsonUtilities.CreateJsonSchema(typeof(MyPoco), serializerOptions: JsonContext.Default.Options, inferenceOptions: inferenceOptions);
282JsonElement actual = AIJsonUtilities.CreateJsonSchema(typeof(PocoWithTypesWithOpenAIUnsupportedKeywords), serializerOptions: JsonContext.Default.Options);
302JsonSerializerOptions options = new(AIJsonUtilities.DefaultOptions);
307JsonElement resolvedSchema = AIJsonUtilities.CreateFunctionJsonSchema(func.UnderlyingMethod, title: string.Empty);
370JsonElement resolvedSchema = AIJsonUtilities.CreateFunctionJsonSchema(func.UnderlyingMethod, title: string.Empty, description: string.Empty, inferenceOptions: inferenceOptions);
377JsonSerializerOptions options = new(AIJsonUtilities.DefaultOptions) { NumberHandling = JsonNumberHandling.AllowReadingFromString };
419JsonElement schema = AIJsonUtilities.CreateJsonSchema(typeof(object));
438JsonElement schema = AIJsonUtilities.CreateJsonSchema(testData.Type, serializerOptions: options, inferenceOptions: createOptions);
462JsonElement schema = AIJsonUtilities.CreateJsonSchema(typeof(AIContent), serializerOptions: options);
466Assert.Same(options.TypeInfoResolver, AIJsonUtilities.DefaultOptions.TypeInfoResolver);
479JsonElement schema = AIJsonUtilities.CreateJsonSchema(typeof(MyEnumValue?), serializerOptions: JsonContext.Default.Options);
488TypeInfoResolver = JsonTypeInfoResolver.Combine(AIJsonUtilities.DefaultOptions.TypeInfoResolver, JsonContext.Default),
504Assert.Throws<InvalidOperationException>(() => AIJsonUtilities.DefaultOptions.AddAIContentType<DerivedAIContent>("derivativeContent"));
551TypeInfoResolver = AIJsonUtilities.DefaultOptions.TypeInfoResolver
554foreach (JsonSerializerOptions? options in new[] { AIJsonUtilities.DefaultOptions, null, customOptions })
556string key1 = AIJsonUtilities.HashDataToString(["a", 'b', 42], options);
557string key2 = AIJsonUtilities.HashDataToString(["a", 'b', 42], options);
558string key3 = AIJsonUtilities.HashDataToString([TimeSpan.FromSeconds(1), null, 1.23], options);
559string key4 = AIJsonUtilities.HashDataToString([TimeSpan.FromSeconds(1), null, 1.23], options);
560string key5 = AIJsonUtilities.HashDataToString([new Dictionary<string, object> { ["key1"] = 1, ["key2"] = 2 }], options);
561string key6 = AIJsonUtilities.HashDataToString([new Dictionary<string, object> { ["key2"] = 2, ["key1"] = 1 }], options);
574JsonSerializerOptions indentOptions = new(AIJsonUtilities.DefaultOptions) { WriteIndented = true };
575JsonSerializerOptions noIndentOptions = new(AIJsonUtilities.DefaultOptions) { WriteIndented = false };
578string key1 = AIJsonUtilities.HashDataToString([dict], indentOptions);
579string key2 = AIJsonUtilities.HashDataToString([dict], noIndentOptions);
590JsonElement schema = AIJsonUtilities.CreateFunctionJsonSchema(method.Method, inferenceOptions: new()
639JsonElement transformedSchema = AIJsonUtilities.TransformSchema(schema, options);
673JsonElement transformedSchema = AIJsonUtilities.TransformSchema(schema, options);
708JsonElement transformedSchema = AIJsonUtilities.TransformSchema(schema, options);
745JsonElement transformedSchema = AIJsonUtilities.TransformSchema(schema, options);
772JsonElement transformedSchema = AIJsonUtilities.TransformSchema(schema, options);
791JsonElement schema = AIJsonUtilities.CreateJsonSchema(testData.Type, serializerOptions: options, inferenceOptions: createOptions);
809JsonElement transformedSchema = AIJsonUtilities.TransformSchema(schema, transformOptions);
836AIJsonUtilities.TransformSchema(transformedSchema, transformOptions);
844Assert.Throws<ArgumentNullException>(() => AIJsonUtilities.TransformSchema(schema, transformOptions: null!));
845Assert.Throws<ArgumentException>(() => AIJsonUtilities.TransformSchema(schema, transformOptions: new()));
858Assert.Throws<ArgumentException>(() => AIJsonUtilities.TransformSchema(schema, transformOptions));
878JsonSerializer.SerializeToNode(element1, AIJsonUtilities.DefaultOptions),
879JsonSerializer.SerializeToNode(element2, AIJsonUtilities.DefaultOptions));
Microsoft.Extensions.AI.AzureAIInference (7)
Microsoft.Extensions.AI.AzureAIInference.Tests (3)
Microsoft.Extensions.AI.Evaluation.Reporting (1)
Microsoft.Extensions.AI.Evaluation.Reporting.Azure (1)
Microsoft.Extensions.AI.Ollama (1)
Microsoft.Extensions.AI.Ollama.Tests (4)
Microsoft.Extensions.AI.OpenAI (4)
Microsoft.Extensions.AI.OpenAI.Tests (3)
Microsoft.Extensions.AI.Tests (3)