Skip to content

Commit 0dfabb7

Browse files
committed
migrate to record
1 parent a99fbe4 commit 0dfabb7

23 files changed

+95
-297
lines changed

src/KubernetesClient.Aot/KubernetesClient.Aot.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@
2525
<Compile Include="..\KubernetesClient\IMetadata.cs" />
2626
<Compile Include="..\KubernetesClient\Models\IntOrStringJsonConverter.cs" />
2727
<Compile Include="..\KubernetesClient\Models\IntOrStringYamlConverter.cs" />
28-
<Compile Include="..\KubernetesClient\Models\IntstrIntOrString.cs" />
28+
<Compile Include="..\KubernetesClient\Models\IntOrString.cs" />
2929
<Compile Include="..\KubernetesClient\ISpec.cs" />
3030
<Compile Include="..\KubernetesClient\IStatus.cs" />
31-
<Compile Include="..\KubernetesClient\IValidate.cs" />
3231
<Compile Include="..\KubernetesClient\Models\KubernetesEntityAttribute.cs" />
3332
<Compile Include="..\KubernetesClient\Models\KubernetesList.cs" />
3433
<Compile Include="..\KubernetesClient\KubernetesObject.cs" />

src/KubernetesClient.Classic/KubernetesClient.Classic.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@
2727
<Compile Include="..\KubernetesClient\IMetadata.cs" />
2828
<Compile Include="..\KubernetesClient\Models\IntOrStringJsonConverter.cs" />
2929
<Compile Include="..\KubernetesClient\Models\IntOrStringYamlConverter.cs" />
30-
<Compile Include="..\KubernetesClient\Models\IntstrIntOrString.cs" />
30+
<Compile Include="..\KubernetesClient\Models\IntOrString.cs" />
3131
<Compile Include="..\KubernetesClient\ISpec.cs" />
3232
<Compile Include="..\KubernetesClient\IStatus.cs" />
33-
<Compile Include="..\KubernetesClient\IValidate.cs" />
3433
<Compile Include="..\KubernetesClient\Models\KubernetesEntityAttribute.cs" />
3534
<Compile Include="..\KubernetesClient\KubernetesJson.cs" />
3635
<Compile Include="..\KubernetesClient\Models\KubernetesList.cs" />

src/KubernetesClient/IValidate.cs

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/KubernetesClient/Models/IntstrIntOrString.cs renamed to src/KubernetesClient/Models/IntOrString.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
namespace k8s.Models
22
{
33
[JsonConverter(typeof(IntOrStringJsonConverter))]
4-
public partial class IntstrIntOrString
4+
public partial class IntOrString
55
{
6-
public static implicit operator IntstrIntOrString(int v)
6+
public static implicit operator IntOrString(int v)
77
{
8-
return new IntstrIntOrString(Convert.ToString(v));
8+
return new IntOrString { Value = Convert.ToString(v) };
99
}
1010

11-
public static implicit operator IntstrIntOrString(long v)
11+
public static implicit operator IntOrString(long v)
1212
{
13-
return new IntstrIntOrString(Convert.ToString(v));
13+
return new IntOrString { Value = Convert.ToString(v) };
1414
}
1515

16-
public static implicit operator string(IntstrIntOrString v)
16+
public static implicit operator string(IntOrString v)
1717
{
1818
return v?.Value;
1919
}
2020

21-
public static implicit operator IntstrIntOrString(string v)
21+
public static implicit operator IntOrString(string v)
2222
{
23-
return new IntstrIntOrString(v);
23+
return new IntOrString { Value = v };
2424
}
2525

26-
protected bool Equals(IntstrIntOrString other)
26+
protected bool Equals(IntOrString other)
2727
{
2828
return string.Equals(Value, other?.Value);
2929
}
@@ -45,7 +45,7 @@ public override bool Equals(object obj)
4545
return false;
4646
}
4747

48-
return Equals((IntstrIntOrString)obj);
48+
return Equals((IntOrString)obj);
4949
}
5050

5151
public override int GetHashCode()

src/KubernetesClient/Models/IntOrStringJsonConverter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
namespace k8s.Models
22
{
3-
internal sealed class IntOrStringJsonConverter : JsonConverter<IntstrIntOrString>
3+
internal sealed class IntOrStringJsonConverter : JsonConverter<IntOrString>
44
{
5-
public override IntstrIntOrString Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
5+
public override IntOrString Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
66
{
77
switch (reader.TokenType)
88
{
@@ -17,7 +17,7 @@ public override IntstrIntOrString Read(ref Utf8JsonReader reader, Type typeToCon
1717
throw new NotSupportedException();
1818
}
1919

20-
public override void Write(Utf8JsonWriter writer, IntstrIntOrString value, JsonSerializerOptions options)
20+
public override void Write(Utf8JsonWriter writer, IntOrString value, JsonSerializerOptions options)
2121
{
2222
if (writer == null)
2323
{

src/KubernetesClient/Models/IntOrStringYamlConverter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public class IntOrStringYamlConverter : IYamlTypeConverter
77
{
88
public bool Accepts(Type type)
99
{
10-
return type == typeof(IntstrIntOrString);
10+
return type == typeof(IntOrString);
1111
}
1212

1313
public object ReadYaml(IParser parser, Type type, ObjectDeserializer rootDeserializer)
@@ -21,7 +21,7 @@ public object ReadYaml(IParser parser, Type type, ObjectDeserializer rootDeseria
2121
return null;
2222
}
2323

24-
return new IntstrIntOrString(scalar?.Value);
24+
return new IntOrString { Value = scalar?.Value };
2525
}
2626
finally
2727
{
@@ -34,7 +34,7 @@ public object ReadYaml(IParser parser, Type type, ObjectDeserializer rootDeseria
3434

3535
public void WriteYaml(IEmitter emitter, object value, Type type, ObjectSerializer serializer)
3636
{
37-
var obj = (IntstrIntOrString)value;
37+
var obj = (IntOrString)value;
3838
emitter?.Emit(new YamlDotNet.Core.Events.Scalar(obj?.Value));
3939
}
4040
}

src/KubernetesClient/Models/KubernetesList.cs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,24 +40,5 @@ public KubernetesList(IList<T> items, string apiVersion = default, string kind =
4040
/// </summary>
4141
[JsonPropertyName("metadata")]
4242
public V1ListMeta Metadata { get; set; }
43-
44-
/// <summary>
45-
/// Validate the object.
46-
/// </summary>
47-
public void Validate()
48-
{
49-
if (Items == null)
50-
{
51-
throw new ArgumentNullException("Items");
52-
}
53-
54-
if (Items != null)
55-
{
56-
foreach (var element in Items.OfType<IValidate>())
57-
{
58-
element.Validate();
59-
}
60-
}
61-
}
6243
}
6344
}

src/KubernetesClient/Models/ModelVersionConverter.cs

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/KubernetesClient/Models/ResourceQuantityJsonConverter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ public override ResourceQuantity Read(ref Utf8JsonReader reader, Type typeToConv
88
switch (reader.TokenType)
99
{
1010
case JsonTokenType.Null:
11-
return new ResourceQuantity(null);
11+
return new ResourceQuantity { Value = null };
1212
case JsonTokenType.Number:
1313
if (reader.TryGetDouble(out var val))
1414
{
15-
return new ResourceQuantity(Convert.ToString(val));
15+
return new ResourceQuantity { Value = Convert.ToString(val) };
1616
}
1717

1818
return reader.GetDecimal();
1919
default:
20-
return new ResourceQuantity(reader.GetString());
20+
return new ResourceQuantity { Value = reader.GetString() };
2121
}
2222
}
2323

src/KubernetesClient/Models/ResourceQuantityYamlConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public object ReadYaml(IParser parser, Type type, ObjectDeserializer rootDeseria
2121
return null;
2222
}
2323

24-
return new ResourceQuantity(scalar?.Value);
24+
return new ResourceQuantity { Value = scalar?.Value };
2525
}
2626
finally
2727
{

0 commit comments

Comments
 (0)