AdrianStrugala / AvroConvert

Rapid Avro serializer for C# .NET
Other
102 stars 27 forks source link

Generate a schema with NO parameterless constructor #75

Closed dav1d992 closed 2 years ago

dav1d992 commented 2 years ago

Objective

Generate a schema from a c# class that has NO parameterless constructor

Issue

When trying to generate a schema from the class without a parameterless constructor: Type 'Domain.Animal' is not supported by the resolver. Can we get around this?

Details

Program.cs:

static void Main(string[] args)
{
     string schema = AvroConvert.GenerateSchema(typeof(Animal));
     Console.WriteLine(schema);
}

Animal.cs:

namespace Domain
{
    public class Animal
    {
        public string Name { get; private set; }

        public Animal(string name)
        {
            Name = name;
        }
    }
}
AdrianStrugala commented 2 years ago

Hello, Thanks for reporting this issue. I will take a look. Regards, Adrian

AdrianStrugala commented 2 years ago

Hello,

I have added a possibility to generate schema of class with no parameterless constructor and additionally, it can be used as a target type for deserialization. You can test the changes in v.3.2.6 of AvroConvert

Regards, Adrian