diff --git a/samples/Example08-IndexedVectors/IndexedVectorExample.cs b/samples/Example08-IndexedVectors/IndexedVectorExample.cs index 2daf703..69a2bcb 100644 --- a/samples/Example08-IndexedVectors/IndexedVectorExample.cs +++ b/samples/Example08-IndexedVectors/IndexedVectorExample.cs @@ -14,6 +14,8 @@ * limitations under the License. */ +using System.Diagnostics.CodeAnalysis; + namespace Samples.IndexedVectors; /// @@ -44,11 +46,11 @@ public class IndexedVectorsExample : IFlatSharpSample { Users = new IndexedVector { - { new User("1") { FirstName = "Charlie", LastName = "Kelly" } }, - { new User("2") { FirstName = "Dennis", LastName = "Reynolds" } }, - { new User("3") { FirstName = "Ronald", LastName = "McDonald" } }, - { new User("4") { FirstName = "Frank", LastName = "Reynolds" } }, - { new User("5") { FirstName = "Deeandra", LastName = "Reynolds" } }, + { new User { Id = "1", FirstName = "Charlie", LastName = "Kelly" } }, + { new User { Id = "2", FirstName = "Dennis", LastName = "Reynolds" } }, + { new User { Id = "3", FirstName = "Ronald", LastName = "McDonald" } }, + { new User { Id = "4", FirstName = "Frank", LastName = "Reynolds" } }, + { new User { Id = "5", FirstName = "Deeandra", LastName = "Reynolds" } }, } }; @@ -78,15 +80,4 @@ public class IndexedVectorsExample : IFlatSharpSample "We can use an indexed vector like a dictionary"); } } -} - -/// -/// Define a partial class for user to expose a public constructor that correctly initializes the object. -/// -public partial class User -{ - public User(string id) - { - this.Id = id; - } -} +} \ No newline at end of file diff --git a/samples/Example08-IndexedVectors/IndexedVectors.fbs b/samples/Example08-IndexedVectors/IndexedVectors.fbs index 85a08de..10204e4 100644 --- a/samples/Example08-IndexedVectors/IndexedVectors.fbs +++ b/samples/Example08-IndexedVectors/IndexedVectors.fbs @@ -26,9 +26,9 @@ table IndexedVectorTable (fs_serializer:"Progressive") Users : [ User ] (fs_vector:"IIndexedVector"); } -// We tell Flatsharp not to generate a parameterless constructor for this type. -// In the corresponding C#, we define a constructor that requires an ID. -table User (fs_defaultCtor:"None") +// If using something before .NET 7, consider using fs_defaultCtor:"None" on the table +// so you can define a constructor that forces Id to be defined. +table User { id : string (key, required, fs_setter:"PublicInit"); first_name : string; diff --git a/samples/Example11-StructVectors/StructVectors.cs b/samples/Example11-StructVectors/StructVectors.cs index 22e8d10..f74e736 100644 --- a/samples/Example11-StructVectors/StructVectors.cs +++ b/samples/Example11-StructVectors/StructVectors.cs @@ -53,6 +53,8 @@ public class StructVectorsSample : IFlatSharpSample Sender = "5566779900", HashReference = new Sha256_Reference(), + HashValue = new Sha256_Value(), + HashFastValue = new Sha256_FastValue(), }; byte[] originalHash; diff --git a/samples/Example12-WriteThrough/WriteThrough.cs b/samples/Example12-WriteThrough/WriteThrough.cs index 6a6ed5c..49c62b1 100644 --- a/samples/Example12-WriteThrough/WriteThrough.cs +++ b/samples/Example12-WriteThrough/WriteThrough.cs @@ -59,7 +59,10 @@ public class WriteThroughSample : IFlatSharpSample { // Each block is 128 bytes. For a 1MB filter, we need 8192 blocks. - BloomFilter filter = new BloomFilter(1024 * 1024 / 128); + BloomFilter filter = new BloomFilter(1024 * 1024 / 128) + { + Blocks = new List() + }; // Write our bloom filter out to an array. It should be about 1MB in size. rawData = new byte[BloomFilter.Serializer.GetMaxSize(filter)]; diff --git a/samples/Samples.csproj b/samples/Samples.csproj index dd812b9..ef7a7d2 100644 --- a/samples/Samples.csproj +++ b/samples/Samples.csproj @@ -1,9 +1,9 @@  - net6.0 + net7.0 exe - 10.0 + 11.0 enable @@ -31,11 +31,11 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - +