openai/openai-dotnet

Public

mirrored from https://github.com/openai/openai-dotnetAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
OpenAI_2.0.0-beta.1

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/Utility/Generator/CodeGenSerializationAttribute.cs

53lines · modeblame

9f9f2936Jose Arriaga Maldonado2 years ago1#nullable enable
2
3using System;
4
5namespace OpenAI;
6
7[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = true, Inherited = true)]
8internal class CodeGenSerializationAttribute : Attribute
9{
10/// <summary>
11/// Gets or sets the property name which these hooks should apply to
12/// </summary>
13public string? PropertyName { get; set; }
14/// <summary>
15/// Gets or sets the serialization path of the property in the JSON
16/// </summary>
17public string[]? SerializationPath { get; }
18/// <summary>
19/// Gets or sets the method name to use when serializing the property value (property name excluded)
20/// The signature of the serialization hook method must be or compatible with when invoking:
21/// private void SerializeHook(Utf8JsonWriter writer);
22/// </summary>
23public string? SerializationValueHook { get; set; }
24/// <summary>
25/// Gets or sets the method name to use when deserializing the property value from the JSON
26/// private static void DeserializationHook(JsonProperty property, ref TypeOfTheProperty propertyValue); // if the property is required
27/// private static void DeserializationHook(JsonProperty property, ref Optional&lt;TypeOfTheProperty&gt; propertyValue); // if the property is optional
28/// </summary>
29public string? DeserializationValueHook { get; set; }
30/// <summary>
31/// Gets or sets the method name to use when serializing the property value (property name excluded)
32/// The signature of the serialization hook method must be or compatible with when invoking:
33/// private void SerializeHook(StringBuilder builder);
34/// </summary>
35public string? BicepSerializationValueHook { get; set; }
36
37public CodeGenSerializationAttribute(string propertyName)
38{
39PropertyName = propertyName;
40}
41
42public CodeGenSerializationAttribute(string propertyName, string serializationName)
43{
44PropertyName = propertyName;
45SerializationPath = new[] { serializationName };
46}
47
48public CodeGenSerializationAttribute(string propertyName, string[] serializationPath)
49{
50PropertyName = propertyName;
51SerializationPath = serializationPath;
52}
53}