In C#, nullability of given property/field/argument is expressed by the compiler using metadata.
The POCO-collections describe specific type and have access to PropertyInfo, which provides not only type but also metadata info like attributes annotations.
The dynamic collections don’t have access to PropertyInfo so their members are always assumed to be nullable. This is by design and covered with tests.
We can’t workaround it by passing things like typeof(string?) as the compiler fails with:
Error (active) CS8639 The typeof operator cannot be used on a nullable reference type
We should expose a new public API that would allow the users to make given property of a dynamic collection as non-nullable.
Example:
new VectorStoreDataProperty("document_id", typeof(string))
{
IsNullable = false
}
In C#, nullability of given property/field/argument is expressed by the compiler using metadata.
The POCO-collections describe specific type and have access to PropertyInfo, which provides not only type but also metadata info like attributes annotations.
The dynamic collections don’t have access to PropertyInfo so their members are always assumed to be nullable. This is by design and covered with tests.
We can’t workaround it by passing things like
typeof(string?)as the compiler fails with:We should expose a new public API that would allow the users to make given property of a dynamic collection as non-nullable.
Example: