diff --git a/examples/AvroSpecific/AvroSpecific.csproj b/examples/AvroSpecific/AvroSpecific.csproj
index bd5e4fefc..475f0bb17 100644
--- a/examples/AvroSpecific/AvroSpecific.csproj
+++ b/examples/AvroSpecific/AvroSpecific.csproj
@@ -5,7 +5,7 @@
AvroSpecific
Exe
net6.0
- 7.1
+ 8
diff --git a/examples/AvroSpecific/User.cs b/examples/AvroSpecific/User.cs
index aba02ae82..a1072291a 100644
--- a/examples/AvroSpecific/User.cs
+++ b/examples/AvroSpecific/User.cs
@@ -15,18 +15,12 @@ namespace Confluent.Kafka.Examples.AvroSpecific
public partial class User : ISpecificRecord
{
- public static Schema _SCHEMA = Avro.Schema.Parse(@"{""type"":""record"",""name"":""User"",""namespace"":""confluent.io.examples.serialization.avro"",""fields"":[{""name"":""name"",""type"":""string""},{""name"":""favorite_number"",""type"":""long""},{""name"":""favorite_color"",""type"":""string""},{""name"":""hourly_rate"",""default"":null,""type"":[""null"",{""type"":""bytes"",""logicalType"":""decimal"",""precision"":4,""scale"":2}]}]}");
+ // properties could be simplified and innitializations be shortened
+ public virtual Schema Schema => Avro.Schema.Parse(@"{""type"":""record"",""name"":""User"",""namespace"":""confluent.io.examples.serialization.avro"",""fields"":[{""name"":""name"",""type"":""string""},{""name"":""favorite_number"",""type"":""long""},{""name"":""favorite_color"",""type"":""string""},{""name"":""hourly_rate"",""default"":null,""type"":[""null"",{""type"":""bytes"",""logicalType"":""decimal"",""precision"":4,""scale"":2}]}]}");
private string _name;
private long _favorite_number;
private string _favorite_color;
private System.Nullable _hourly_rate;
- public virtual Schema Schema
- {
- get
- {
- return User._SCHEMA;
- }
- }
public string name
{
get
@@ -71,26 +65,23 @@ public System.Nullable hourly_rate
this._hourly_rate = value;
}
}
- public virtual object Get(int fieldPos)
+ public virtual object Get(int fieldPos) => fieldPos switch
{
- switch (fieldPos)
- {
- case 0: return this.name;
- case 1: return this.favorite_number;
- case 2: return this.favorite_color;
- case 3: return this.hourly_rate;
- default: throw new AvroRuntimeException("Bad index " + fieldPos + " in Get()");
- };
- }
+ 0 => name,
+ 1 => favorite_number,
+ 2 => favorite_color,
+ 3 => hourly_rate,
+ _ => throw new AvroRuntimeException("Bad index " + fieldPos + " in Get()")
+ };
public virtual void Put(int fieldPos, object fieldValue)
{
- switch (fieldPos)
+ object example = fieldPos switch
{
- case 0: this.name = (System.String)fieldValue; break;
- case 1: this.favorite_number = (System.Int64)fieldValue; break;
- case 2: this.favorite_color = (System.String)fieldValue; break;
- case 3: this.hourly_rate = (System.Nullable)fieldValue; break;
- default: throw new AvroRuntimeException("Bad index " + fieldPos + " in Put()");
+ 0 => name = (string)fieldValue,
+ 1 => favorite_number = (Int64)fieldValue,
+ 2 => favorite_color = (string)fieldValue,
+ 3 => hourly_rate = (System.Nullable)fieldValue,
+ _ => throw new AvroRuntimeException("Bad index " + fieldPos + " in Put()")
};
}
}
diff --git a/examples/AvroSpecificEncryption/AvroSpecificEncryption.csproj b/examples/AvroSpecificEncryption/AvroSpecificEncryption.csproj
index 711441b1b..b1a482f03 100644
--- a/examples/AvroSpecificEncryption/AvroSpecificEncryption.csproj
+++ b/examples/AvroSpecificEncryption/AvroSpecificEncryption.csproj
@@ -5,7 +5,7 @@
AvroSpecificEncryption
Exe
net6.0
- 7.1
+ 8
diff --git a/examples/AvroSpecificEncryption/User.cs b/examples/AvroSpecificEncryption/User.cs
index f234ad567..a1072291a 100644
--- a/examples/AvroSpecificEncryption/User.cs
+++ b/examples/AvroSpecificEncryption/User.cs
@@ -5,7 +5,7 @@
// is regenerated
//
// ------------------------------------------------------------------------------
-namespace Confluent.Kafka.Examples.AvroSpecificEncryption
+namespace Confluent.Kafka.Examples.AvroSpecific
{
using System;
using System.Collections.Generic;
@@ -15,18 +15,12 @@ namespace Confluent.Kafka.Examples.AvroSpecificEncryption
public partial class User : ISpecificRecord
{
- public static Schema _SCHEMA = Avro.Schema.Parse(@"{""type"":""record"",""name"":""User"",""namespace"":""confluent.io.examples.serialization.avro"",""fields"":[{""name"":""name"",""type"":""string"",""confluent:tags"":[""PII""]},{""name"":""favorite_number"",""type"":""long""},{""name"":""favorite_color"",""type"":""string""},{""name"":""hourly_rate"",""default"":null,""type"":[""null"",{""type"":""bytes"",""logicalType"":""decimal"",""precision"":4,""scale"":2}]}]}");
+ // properties could be simplified and innitializations be shortened
+ public virtual Schema Schema => Avro.Schema.Parse(@"{""type"":""record"",""name"":""User"",""namespace"":""confluent.io.examples.serialization.avro"",""fields"":[{""name"":""name"",""type"":""string""},{""name"":""favorite_number"",""type"":""long""},{""name"":""favorite_color"",""type"":""string""},{""name"":""hourly_rate"",""default"":null,""type"":[""null"",{""type"":""bytes"",""logicalType"":""decimal"",""precision"":4,""scale"":2}]}]}");
private string _name;
private long _favorite_number;
private string _favorite_color;
private System.Nullable _hourly_rate;
- public virtual Schema Schema
- {
- get
- {
- return User._SCHEMA;
- }
- }
public string name
{
get
@@ -71,26 +65,23 @@ public System.Nullable hourly_rate
this._hourly_rate = value;
}
}
- public virtual object Get(int fieldPos)
+ public virtual object Get(int fieldPos) => fieldPos switch
{
- switch (fieldPos)
- {
- case 0: return this.name;
- case 1: return this.favorite_number;
- case 2: return this.favorite_color;
- case 3: return this.hourly_rate;
- default: throw new AvroRuntimeException("Bad index " + fieldPos + " in Get()");
- };
- }
+ 0 => name,
+ 1 => favorite_number,
+ 2 => favorite_color,
+ 3 => hourly_rate,
+ _ => throw new AvroRuntimeException("Bad index " + fieldPos + " in Get()")
+ };
public virtual void Put(int fieldPos, object fieldValue)
{
- switch (fieldPos)
+ object example = fieldPos switch
{
- case 0: this.name = (System.String)fieldValue; break;
- case 1: this.favorite_number = (System.Int64)fieldValue; break;
- case 2: this.favorite_color = (System.String)fieldValue; break;
- case 3: this.hourly_rate = (System.Nullable)fieldValue; break;
- default: throw new AvroRuntimeException("Bad index " + fieldPos + " in Put()");
+ 0 => name = (string)fieldValue,
+ 1 => favorite_number = (Int64)fieldValue,
+ 2 => favorite_color = (string)fieldValue,
+ 3 => hourly_rate = (System.Nullable)fieldValue,
+ _ => throw new AvroRuntimeException("Bad index " + fieldPos + " in Put()")
};
}
}