Skip to content

Commit 680b4b8

Browse files
authored
Merge pull request #177 from MartinM85/feature/175-untyped-nodes
Create types for untyped nodes
2 parents 5a93d12 + 07d3c99 commit 680b4b8

13 files changed

+253
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [1.8.0] - 2024-03-18
11+
12+
### Added
13+
14+
- Added support for untyped nodes. (https://github.com/microsoft/kiota-abstractions-dotnet/issues/175)
15+
1016
## [1.7.12] - 2024-03-08
1117

1218
### Changed

src/Microsoft.Kiota.Abstractions.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<PackageProjectUrl>https://aka.ms/kiota/docs</PackageProjectUrl>
1515
<EmbedUntrackedSources>true</EmbedUntrackedSources>
1616
<Deterministic>true</Deterministic>
17-
<VersionPrefix>1.7.12</VersionPrefix>
17+
<VersionPrefix>1.8.0</VersionPrefix>
1818
<VersionSuffix></VersionSuffix>
1919
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
2020
<SignAssembly>false</SignAssembly>

src/serialization/UntypedArray.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// ------------------------------------------------------------------------------
2+
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
3+
// ------------------------------------------------------------------------------
4+
5+
using System.Collections.Generic;
6+
7+
namespace Microsoft.Kiota.Abstractions.Serialization
8+
{
9+
/// <summary>
10+
/// Represents an untyped node with the collection of untyped values.
11+
/// </summary>
12+
/// <param name="value">The collection of child nodes.</param>
13+
public class UntypedArray(IEnumerable<UntypedNode> value) : UntypedNode
14+
{
15+
private readonly IEnumerable<UntypedNode> _value = value;
16+
/// <summary>
17+
/// Gets the collection of untyped child nodes.
18+
/// </summary>
19+
/// <returns>The collection of untyped child nodes.</returns>
20+
public new IEnumerable<UntypedNode> GetValue() => _value;
21+
}
22+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// ------------------------------------------------------------------------------
2+
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
3+
// ------------------------------------------------------------------------------
4+
5+
namespace Microsoft.Kiota.Abstractions.Serialization
6+
{
7+
/// <summary>
8+
/// Represents an untyped node with boolean value.
9+
/// </summary>
10+
/// <param name="value">The boolean value associated with the node.</param>
11+
public class UntypedBoolean(bool value) : UntypedNode
12+
{
13+
private readonly bool _value = value;
14+
/// <summary>
15+
/// Gets the value associated with untyped boolean node.
16+
/// </summary>
17+
/// <returns>The value associated with untyped boolean node.</returns>
18+
public new bool GetValue() => _value;
19+
}
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// ------------------------------------------------------------------------------
2+
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
3+
// ------------------------------------------------------------------------------
4+
5+
namespace Microsoft.Kiota.Abstractions.Serialization
6+
{
7+
/// <summary>
8+
/// Represents an untyped node with decimal value.
9+
/// </summary>
10+
/// <param name="value">The decimal value associated with the node.</param>
11+
public class UntypedDecimal(decimal value) : UntypedNode
12+
{
13+
private readonly decimal _value = value;
14+
/// <summary>
15+
/// Gets the value associated with untyped decimal node.
16+
/// </summary>
17+
/// <returns>The value associated with untyped decimal node.</returns>
18+
public new decimal GetValue() => _value;
19+
}
20+
}

src/serialization/UntypedDouble.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// ------------------------------------------------------------------------------
2+
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
3+
// ------------------------------------------------------------------------------
4+
5+
namespace Microsoft.Kiota.Abstractions.Serialization
6+
{
7+
/// <summary>
8+
/// Represents an untyped node with double value.
9+
/// </summary>
10+
/// <param name="value">The double value associated with the node.</param>
11+
public class UntypedDouble(double value) : UntypedNode
12+
{
13+
private readonly double _value = value;
14+
/// <summary>
15+
/// Gets the value associated with untyped double node.
16+
/// </summary>
17+
/// <returns>The value associated with untyped double node.</returns>
18+
public new double GetValue() => _value;
19+
}
20+
}

src/serialization/UntypedFloat.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// ------------------------------------------------------------------------------
2+
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
3+
// ------------------------------------------------------------------------------
4+
5+
namespace Microsoft.Kiota.Abstractions.Serialization
6+
{
7+
/// <summary>
8+
/// Represents an untyped node with float value.
9+
/// </summary>
10+
/// <param name="value">The float value associated with the node.</param>
11+
public class UntypedFloat(float value) : UntypedNode
12+
{
13+
private readonly float _value = value;
14+
/// <summary>
15+
/// Gets the value associated with untyped float node.
16+
/// </summary>
17+
/// <returns>The value associated with untyped float node.</returns>
18+
public new float GetValue() => _value;
19+
}
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// ------------------------------------------------------------------------------
2+
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
3+
// ------------------------------------------------------------------------------
4+
5+
namespace Microsoft.Kiota.Abstractions.Serialization
6+
{
7+
/// <summary>
8+
/// Represents an untyped node with integer value.
9+
/// </summary>
10+
/// <param name="value">The integer value associated with the node.</param>
11+
public class UntypedInteger(int value): UntypedNode
12+
{
13+
private readonly int _value = value;
14+
/// <summary>
15+
/// Gets the value associated with untyped integer node.
16+
/// </summary>
17+
/// <returns>The value associated with untyped integer node.</returns>
18+
public new int GetValue() => _value;
19+
}
20+
}

src/serialization/UntypedLong.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// ------------------------------------------------------------------------------
2+
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
3+
// ------------------------------------------------------------------------------
4+
5+
namespace Microsoft.Kiota.Abstractions.Serialization
6+
{
7+
/// <summary>
8+
/// Represents an untyped node with long value.
9+
/// </summary>
10+
/// <param name="value">The long value associated with the node.</param>
11+
public class UntypedLong(long value) : UntypedNode
12+
{
13+
/// <summary>
14+
/// The value associated with untyped long node.
15+
/// </summary>
16+
private readonly long _value = value;
17+
/// <summary>
18+
/// Gets the value associated with untyped long node.
19+
/// </summary>
20+
/// <returns>The value associated with untyped long node.</returns>
21+
public new long GetValue() => _value;
22+
}
23+
}

src/serialization/UntypedNode.cs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// ------------------------------------------------------------------------------
2+
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
3+
// ------------------------------------------------------------------------------
4+
5+
using System;
6+
using System.Collections.Generic;
7+
using System.Collections.ObjectModel;
8+
9+
namespace Microsoft.Kiota.Abstractions.Serialization
10+
{
11+
/// <summary>
12+
/// Base class for untyped node.
13+
/// </summary>
14+
public class UntypedNode : IParsable
15+
{
16+
private static readonly IDictionary<string, Action<IParseNode>> _fieldDeserializers = new ReadOnlyDictionary<string, Action<IParseNode>>(new Dictionary<string, Action<IParseNode>>());
17+
/// <summary>
18+
/// The deserialization information for the current model
19+
/// </summary>
20+
public virtual IDictionary<string, Action<IParseNode>> GetFieldDeserializers() => _fieldDeserializers;
21+
/// <summary>
22+
/// Serializes information the current object
23+
/// <param name="writer">Serialization writer to use to serialize this model</param>
24+
/// </summary>
25+
public virtual void Serialize(ISerializationWriter writer) => _ = writer ?? throw new ArgumentNullException(nameof(writer));
26+
/// <summary>
27+
/// Creates a new instance of the appropriate class based on discriminator value
28+
/// </summary>
29+
/// <param name="parseNode">The parse node to use to read the discriminator value and create the object</param>
30+
public static UntypedNode CreateFromDiscriminatorValue(IParseNode parseNode)
31+
{
32+
_ = parseNode ?? throw new ArgumentNullException(nameof(parseNode));
33+
return new();
34+
}
35+
/// <summary>
36+
/// Gets the value assigned to untyped node.
37+
/// </summary>
38+
/// <returns>The value assigned to untyped node.</returns>
39+
public object? GetValue() => throw new NotImplementedException();
40+
}
41+
}

0 commit comments

Comments
 (0)