Skip to content

Commit

Permalink
first move to record
Browse files Browse the repository at this point in the history
  • Loading branch information
tg123 committed Apr 19, 2024
1 parent 3dae1cf commit 4d66f8b
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 58 deletions.
50 changes: 25 additions & 25 deletions src/KubernetesClient/Models/IntstrIntOrString.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace k8s.Models
{
[JsonConverter(typeof(IntOrStringJsonConverter))]
public partial class IntstrIntOrString
public partial record IntstrIntOrString
{
public static implicit operator IntstrIntOrString(int v)
{
Expand All @@ -23,30 +23,30 @@ public static implicit operator IntstrIntOrString(string v)
return new IntstrIntOrString(v);
}

protected bool Equals(IntstrIntOrString other)
{
return string.Equals(Value, other?.Value);
}

public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}

if (ReferenceEquals(this, obj))
{
return true;
}

if (obj.GetType() != GetType())
{
return false;
}

return Equals((IntstrIntOrString)obj);
}
//protected bool Equals(IntstrIntOrString other)

Check warning on line 26 in src/KubernetesClient/Models/IntstrIntOrString.cs

View workflow job for this annotation

GitHub Actions / MSBuild build

Check warning on line 26 in src/KubernetesClient/Models/IntstrIntOrString.cs

View workflow job for this annotation

GitHub Actions / e2e

Check warning on line 26 in src/KubernetesClient/Models/IntstrIntOrString.cs

View workflow job for this annotation

GitHub Actions / e2e

Check warning on line 26 in src/KubernetesClient/Models/IntstrIntOrString.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

//{

Check warning on line 27 in src/KubernetesClient/Models/IntstrIntOrString.cs

View workflow job for this annotation

GitHub Actions / MSBuild build

Check warning on line 27 in src/KubernetesClient/Models/IntstrIntOrString.cs

View workflow job for this annotation

GitHub Actions / e2e

Check warning on line 27 in src/KubernetesClient/Models/IntstrIntOrString.cs

View workflow job for this annotation

GitHub Actions / e2e

Check warning on line 27 in src/KubernetesClient/Models/IntstrIntOrString.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

// return string.Equals(Value, other?.Value);
//}

Check warning on line 29 in src/KubernetesClient/Models/IntstrIntOrString.cs

View workflow job for this annotation

GitHub Actions / MSBuild build

Check warning on line 29 in src/KubernetesClient/Models/IntstrIntOrString.cs

View workflow job for this annotation

GitHub Actions / e2e

Check warning on line 29 in src/KubernetesClient/Models/IntstrIntOrString.cs

View workflow job for this annotation

GitHub Actions / e2e

Check warning on line 29 in src/KubernetesClient/Models/IntstrIntOrString.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)


//public override bool Equals(object obj)

Check warning on line 31 in src/KubernetesClient/Models/IntstrIntOrString.cs

View workflow job for this annotation

GitHub Actions / MSBuild build

Check warning on line 31 in src/KubernetesClient/Models/IntstrIntOrString.cs

View workflow job for this annotation

GitHub Actions / e2e

Check warning on line 31 in src/KubernetesClient/Models/IntstrIntOrString.cs

View workflow job for this annotation

GitHub Actions / e2e

Check warning on line 31 in src/KubernetesClient/Models/IntstrIntOrString.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

//V1Status{

Check warning on line 32 in src/KubernetesClient/Models/IntstrIntOrString.cs

View workflow job for this annotation

GitHub Actions / MSBuild build

Check warning on line 32 in src/KubernetesClient/Models/IntstrIntOrString.cs

View workflow job for this annotation

GitHub Actions / e2e

Check warning on line 32 in src/KubernetesClient/Models/IntstrIntOrString.cs

View workflow job for this annotation

GitHub Actions / e2e

Check warning on line 32 in src/KubernetesClient/Models/IntstrIntOrString.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

// if (ReferenceEquals(null, obj))
// {
// return false;
// }

// if (ReferenceEquals(this, obj))

Check warning on line 38 in src/KubernetesClient/Models/IntstrIntOrString.cs

View workflow job for this annotation

GitHub Actions / MSBuild build

Check warning on line 38 in src/KubernetesClient/Models/IntstrIntOrString.cs

View workflow job for this annotation

GitHub Actions / e2e

Check warning on line 38 in src/KubernetesClient/Models/IntstrIntOrString.cs

View workflow job for this annotation

GitHub Actions / e2e

Check warning on line 38 in src/KubernetesClient/Models/IntstrIntOrString.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

// {
// return true;
// }

// if (obj.GetType() != GetType())

Check warning on line 43 in src/KubernetesClient/Models/IntstrIntOrString.cs

View workflow job for this annotation

GitHub Actions / MSBuild build

Check warning on line 43 in src/KubernetesClient/Models/IntstrIntOrString.cs

View workflow job for this annotation

GitHub Actions / e2e

Check warning on line 43 in src/KubernetesClient/Models/IntstrIntOrString.cs

View workflow job for this annotation

GitHub Actions / e2e

Check warning on line 43 in src/KubernetesClient/Models/IntstrIntOrString.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

// {
// return false;
// }

// return Equals((IntstrIntOrString)obj);

Check warning on line 48 in src/KubernetesClient/Models/IntstrIntOrString.cs

View workflow job for this annotation

GitHub Actions / MSBuild build

Check warning on line 48 in src/KubernetesClient/Models/IntstrIntOrString.cs

View workflow job for this annotation

GitHub Actions / e2e

Check warning on line 48 in src/KubernetesClient/Models/IntstrIntOrString.cs

View workflow job for this annotation

GitHub Actions / e2e

Check warning on line 48 in src/KubernetesClient/Models/IntstrIntOrString.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

//}

Check warning on line 49 in src/KubernetesClient/Models/IntstrIntOrString.cs

View workflow job for this annotation

GitHub Actions / MSBuild build

Check warning on line 49 in src/KubernetesClient/Models/IntstrIntOrString.cs

View workflow job for this annotation

GitHub Actions / e2e

Check warning on line 49 in src/KubernetesClient/Models/IntstrIntOrString.cs

View workflow job for this annotation

GitHub Actions / e2e

Check warning on line 49 in src/KubernetesClient/Models/IntstrIntOrString.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)


public override int GetHashCode()
{
Expand Down
50 changes: 25 additions & 25 deletions src/KubernetesClient/Models/ResourceQuantity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace k8s.Models
/// cause implementors to also use a fixed point implementation.
/// </summary>
[JsonConverter(typeof(ResourceQuantityJsonConverter))]
public partial class ResourceQuantity
public partial record ResourceQuantity
{
public enum SuffixFormat
{
Expand Down Expand Up @@ -97,30 +97,30 @@ public override string ToString()
return CanonicalizeString();
}

protected bool Equals(ResourceQuantity other)
{
return _unitlessValue.Equals(other?._unitlessValue);
}

public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}

if (ReferenceEquals(this, obj))
{
return true;
}

if (obj.GetType() != GetType())
{
return false;
}

return Equals((ResourceQuantity)obj);
}
//protected bool Equals(ResourceQuantity other)

Check warning on line 100 in src/KubernetesClient/Models/ResourceQuantity.cs

View workflow job for this annotation

GitHub Actions / MSBuild build

Check warning on line 100 in src/KubernetesClient/Models/ResourceQuantity.cs

View workflow job for this annotation

GitHub Actions / e2e

Check warning on line 100 in src/KubernetesClient/Models/ResourceQuantity.cs

View workflow job for this annotation

GitHub Actions / e2e

Check warning on line 100 in src/KubernetesClient/Models/ResourceQuantity.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

//{
// return _unitlessValue.Equals(other?._unitlessValue);
//}

//public override bool Equals(object obj)
//{
// if (ReferenceEquals(null, obj))
// {
// return false;
// }

// if (ReferenceEquals(this, obj))
// {
// return true;
// }

// if (obj.GetType() != GetType())
// {
// return false;
// }

// return Equals((ResourceQuantity)obj);
//}

public override int GetHashCode()
{
Expand Down
2 changes: 1 addition & 1 deletion src/KubernetesClient/Models/V1Patch.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace k8s.Models
{
[JsonConverter(typeof(V1PatchJsonConverter))]
public partial class V1Patch
public partial record V1Patch
{
public enum PatchType
{
Expand Down
2 changes: 1 addition & 1 deletion src/KubernetesClient/Models/V1PodTemplateSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace k8s.Models
/// Partial implementation of the IMetadata interface
/// to open this class up to ModelExtensions methods
/// </summary>
public partial class V1PodTemplateSpec : IMetadata<V1ObjectMeta>
public partial record V1PodTemplateSpec : IMetadata<V1ObjectMeta>
{
}
}
2 changes: 1 addition & 1 deletion src/KubernetesClient/Models/V1Status.ObjectView.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace k8s.Models
{
public partial class V1Status
public partial record V1Status
{
internal sealed class V1StatusObjectViewConverter : JsonConverter<V1Status>
{
Expand Down
2 changes: 1 addition & 1 deletion src/KubernetesClient/Models/V1Status.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace k8s.Models
{
public partial class V1Status
public partial record V1Status
{
/// <summary>Converts a <see cref="V1Status"/> object into a short description of the status.</summary>
/// <returns>string description of the status</returns>
Expand Down
4 changes: 2 additions & 2 deletions src/LibKubernetesGenerator/VersionConverterStubGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ namespace k8s.Models;
foreach (var (t0, t1) in typePairs)
{
sbmodel.AppendLine($@"
public partial class {t0}
public partial record {t0}
{{
public static explicit operator {t0}({t1} s) => ModelVersionConverter.Convert<{t1}, {t0}>(s);
}}
public partial class {t1}
public partial record {t1}
{{
public static explicit operator {t1}({t0} s) => ModelVersionConverter.Convert<{t0}, {t1}>(s);
}}");
Expand Down
2 changes: 1 addition & 1 deletion src/LibKubernetesGenerator/templates/Model.cs.template
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace k8s.Models
/// <summary>
/// {{ToXmlDoc def.description}}
/// </summary>
public partial class {{clz}}
public partial record {{clz}}
{
/// <summary>
/// Initializes a new instance of the {{GetClassName def}} class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace k8s.Models
{
{{ for definition in definitions }}
[KubernetesEntity(Group=KubeGroup, Kind=KubeKind, ApiVersion=KubeApiVersion, PluralName=KubePluralName)]
public partial class {{ GetClassName definition }} : {{ GetInterfaceName definition }}
public partial record {{ GetClassName definition }} : {{ GetInterfaceName definition }}
{
public const string KubeApiVersion = "{{ GetApiVersion definition }}";
public const string KubeKind = "{{ GetKind definition }}";
Expand Down

0 comments on commit 4d66f8b

Please sign in to comment.