Skip to content

Commit

Permalink
Added and cleaned up comments
Browse files Browse the repository at this point in the history
  • Loading branch information
EdwardCooke committed Dec 14, 2022
1 parent 640e84d commit 467204b
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 4 deletions.
2 changes: 1 addition & 1 deletion YamlDotNet/Serialization/DeserializerBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace YamlDotNet.Serialization
/// </summary>

#if NET7_0_OR_GREATER
[RequiresDynamicCode("By default, the deserializer uses reflection. Use the code generator/analyzer to generate static code and use the 'WithAoTContext' method.")]
[RequiresDynamicCode("By default, the deserializer uses reflection. Use the code generator/analyzer to generate static code and use the 'WithStaticContext' method.")]
#endif
public sealed class DeserializerBuilder : BuilderSkeleton<DeserializerBuilder>
{
Expand Down
18 changes: 16 additions & 2 deletions YamlDotNet/Serialization/IObjectAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,27 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

using System;

namespace YamlDotNet.Serialization
{
/// <summary>
/// The interface to implement for getting/setting an objects fields and properties when using a static context
/// </summary>
public interface IObjectAccessor
{
/// <summary>
/// Set a field/property value
/// </summary>
/// <param name="name">Name of the field or property.</param>
/// <param name="target">Object to set the field/property on.</param>
/// <param name="value">Value to set the field/property to.</param>
void Set(string name, object target, object value);

/// <summary>
/// Reads a value from a field/property
/// </summary>
/// <param name="name">Name of the field or property.</param>
/// <param name="target">Object to get the field/property from.</param>
/// <returns></returns>
object? Read(string name, object target);
}
}
32 changes: 32 additions & 0 deletions YamlDotNet/Serialization/ObjectFactories/StaticObjectFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,44 @@

namespace YamlDotNet.Serialization.ObjectFactories
{
/// <summary>
/// Gets information about and creates statically known, serializable, types.
/// </summary>
public abstract class StaticObjectFactory : IObjectFactory
{
/// <summary>
/// Create an object of the specified type
/// </summary>
/// <param name="type">Type of object to create</param>
/// <returns></returns>
public abstract object Create(Type type);

/// <summary>
/// Gets whether the type is a dictionary or not
/// </summary>
/// <param name="type">Type to check</param>
/// <returns></returns>
public abstract bool IsDictionary(Type type);

/// <summary>
/// Gets whether the type is a list
/// </summary>
/// <param name="type">Type to check</param>
/// <returns></returns>
public abstract bool IsList(Type type);

/// <summary>
/// Gets the type of the key of a dictionary
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
public abstract Type GetKeyType(Type type);

/// <summary>
/// Gets the type of the value part of a dictionary or list.
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
public abstract Type GetValueType(Type type);
}
}
2 changes: 1 addition & 1 deletion YamlDotNet/Serialization/SerializerBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace YamlDotNet.Serialization
/// with the desired customizations.
/// </summary>
#if NET7_0_OR_GREATER
[RequiresDynamicCode("By default, the serializer uses reflection. Use the code generator/analyzer to generate static code and use the 'WithAoTContext' method.")]
[RequiresDynamicCode("By default, the serializer uses reflection. Use the code generator/analyzer to generate static code and use the 'WithStaticContext' method.")]
#endif
public sealed class SerializerBuilder : BuilderSkeleton<SerializerBuilder>
{
Expand Down
11 changes: 11 additions & 0 deletions YamlDotNet/Serialization/StaticContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,24 @@

namespace YamlDotNet.Serialization
{
/// <summary>
/// Holds the static object factory and type inspector to use when statically serializing/deserializing YAML.
/// </summary>
public abstract class StaticContext
{
/// <summary>
/// Gets the factory to use for serialization and deserialization
/// </summary>
/// <returns></returns>
public virtual StaticObjectFactory GetFactory()
{
throw new NotImplementedException();
}

/// <summary>
/// Gets the type inspector to use when statically serializing/deserializing YAML.
/// </summary>
/// <returns></returns>
public virtual ITypeInspector GetTypeInspector()
{
throw new NotImplementedException();
Expand Down

0 comments on commit 467204b

Please sign in to comment.