You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by Welly Tambunan <if...@gmail.com> on 2016/09/05 12:12:59 UTC
Apache Avro to .NET Core
Hi All,
I'm trying to port apache avro to .NET core.
Here's the repository for the project
https://github.com/welly87/Apache-Avro-Core
However i found that some of the class and method is missing regarding
Assembly loading and IL generation. I'm really close to completing the
porting.
[image: Inline image 1]
#1. Is there any replacement on this line of code in .NET core ?
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
#2. Another one is IL Generator. Any idea how to replace this code ?
public CtorDelegate GetConstructor(string name, Schema.Type
schemaType, Type type)
{
ConstructorInfo ctorInfo = type.GetConstructor(Type.EmptyTypes);
if (ctorInfo == null)
throw new AvroException("Class " + name + " has no default
constructor");
DynamicMethod dynMethod = new DynamicMethod("DM$OBJ_FACTORY_" +
name, typeof(object), null, type, true);
ILGenerator ilGen = dynMethod.GetILGenerator();
ilGen.Emit(OpCodes.Nop);
ilGen.Emit(OpCodes.Newobj, ctorInfo);
ilGen.Emit(OpCodes.Ret);
return (CtorDelegate)dynMethod.CreateDelegate(ctorType);
}
Thanks
Cheers
--
Welly Tambunan
Triplelands
http://weltam.wordpress.com
http://www.triplelands.com <http://www.triplelands.com/blog/>
Re: Apache Avro to .NET Core
Posted by Welly Tambunan <if...@gmail.com>.
Hi Ryan,
Thanks for your feedback. I finally managed to port Apache Avro to .NET
Core. Here's the detail on how i solve the problem
https://weltam.wordpress.com/2016/09/07/porting-apache-avro-into-net-core/
Cheers
On Wed, Sep 7, 2016 at 12:16 AM, Ryan Blue <rb...@netflix.com> wrote:
> Hi Welly,
>
> I'm not very familiar with .NET or the C# Avro library, hopefully others
> can help answer your specific question. One alternative is to look at the
> Microsoft C# library, which also has codegen features and is intended for
> use for .NET:
>
> https://azure.microsoft.com/en-us/updates/microsoft-avro-
> library-updated-to-include-c-code-generator/
>
> rb
>
> On Mon, Sep 5, 2016 at 5:12 AM, Welly Tambunan <if...@gmail.com> wrote:
>
>> Hi All,
>>
>> I'm trying to port apache avro to .NET core.
>>
>> Here's the repository for the project
>>
>> https://github.com/welly87/Apache-Avro-Core
>>
>>
>> However i found that some of the class and method is missing regarding
>> Assembly loading and IL generation. I'm really close to completing the
>> porting.
>>
>> [image: Inline image 1]
>>
>> #1. Is there any replacement on this line of code in .NET core ?
>> Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
>>
>> #2. Another one is IL Generator. Any idea how to replace this code ?
>>
>> public CtorDelegate GetConstructor(string name, Schema.Type
>> schemaType, Type type)
>> {
>> ConstructorInfo ctorInfo = type.GetConstructor(Type.Empty
>> Types);
>> if (ctorInfo == null)
>> throw new AvroException("Class " + name + " has no
>> default constructor");
>>
>> DynamicMethod dynMethod = new DynamicMethod("DM$OBJ_FACTORY_"
>> + name, typeof(object), null, type, true);
>> ILGenerator ilGen = dynMethod.GetILGenerator();
>> ilGen.Emit(OpCodes.Nop);
>> ilGen.Emit(OpCodes.Newobj, ctorInfo);
>> ilGen.Emit(OpCodes.Ret);
>>
>> return (CtorDelegate)dynMethod.CreateDelegate(ctorType);
>> }
>>
>> Thanks
>>
>> Cheers
>> --
>> Welly Tambunan
>> Triplelands
>>
>> http://weltam.wordpress.com
>> http://www.triplelands.com <http://www.triplelands.com/blog/>
>>
>
>
>
> --
> Ryan Blue
> Software Engineer
> Netflix
>
--
Welly Tambunan
Triplelands
http://weltam.wordpress.com
http://www.triplelands.com <http://www.triplelands.com/blog/>
Re: Apache Avro to .NET Core
Posted by Welly Tambunan <if...@gmail.com>.
Hi Ryan,
Thanks for your feedback. I finally managed to port Apache Avro to .NET
Core. Here's the detail on how i solve the problem
https://weltam.wordpress.com/2016/09/07/porting-apache-avro-into-net-core/
Cheers
On Wed, Sep 7, 2016 at 12:16 AM, Ryan Blue <rb...@netflix.com> wrote:
> Hi Welly,
>
> I'm not very familiar with .NET or the C# Avro library, hopefully others
> can help answer your specific question. One alternative is to look at the
> Microsoft C# library, which also has codegen features and is intended for
> use for .NET:
>
> https://azure.microsoft.com/en-us/updates/microsoft-avro-
> library-updated-to-include-c-code-generator/
>
> rb
>
> On Mon, Sep 5, 2016 at 5:12 AM, Welly Tambunan <if...@gmail.com> wrote:
>
>> Hi All,
>>
>> I'm trying to port apache avro to .NET core.
>>
>> Here's the repository for the project
>>
>> https://github.com/welly87/Apache-Avro-Core
>>
>>
>> However i found that some of the class and method is missing regarding
>> Assembly loading and IL generation. I'm really close to completing the
>> porting.
>>
>> [image: Inline image 1]
>>
>> #1. Is there any replacement on this line of code in .NET core ?
>> Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
>>
>> #2. Another one is IL Generator. Any idea how to replace this code ?
>>
>> public CtorDelegate GetConstructor(string name, Schema.Type
>> schemaType, Type type)
>> {
>> ConstructorInfo ctorInfo = type.GetConstructor(Type.Empty
>> Types);
>> if (ctorInfo == null)
>> throw new AvroException("Class " + name + " has no
>> default constructor");
>>
>> DynamicMethod dynMethod = new DynamicMethod("DM$OBJ_FACTORY_"
>> + name, typeof(object), null, type, true);
>> ILGenerator ilGen = dynMethod.GetILGenerator();
>> ilGen.Emit(OpCodes.Nop);
>> ilGen.Emit(OpCodes.Newobj, ctorInfo);
>> ilGen.Emit(OpCodes.Ret);
>>
>> return (CtorDelegate)dynMethod.CreateDelegate(ctorType);
>> }
>>
>> Thanks
>>
>> Cheers
>> --
>> Welly Tambunan
>> Triplelands
>>
>> http://weltam.wordpress.com
>> http://www.triplelands.com <http://www.triplelands.com/blog/>
>>
>
>
>
> --
> Ryan Blue
> Software Engineer
> Netflix
>
--
Welly Tambunan
Triplelands
http://weltam.wordpress.com
http://www.triplelands.com <http://www.triplelands.com/blog/>
Re: Apache Avro to .NET Core
Posted by Ryan Blue <rb...@netflix.com.INVALID>.
Hi Welly,
I'm not very familiar with .NET or the C# Avro library, hopefully others
can help answer your specific question. One alternative is to look at the
Microsoft C# library, which also has codegen features and is intended for
use for .NET:
https://azure.microsoft.com/en-us/updates/microsoft-avro-library-updated-to-include-c-code-generator/
rb
On Mon, Sep 5, 2016 at 5:12 AM, Welly Tambunan <if...@gmail.com> wrote:
> Hi All,
>
> I'm trying to port apache avro to .NET core.
>
> Here's the repository for the project
>
> https://github.com/welly87/Apache-Avro-Core
>
>
> However i found that some of the class and method is missing regarding
> Assembly loading and IL generation. I'm really close to completing the
> porting.
>
> [image: Inline image 1]
>
> #1. Is there any replacement on this line of code in .NET core ?
> Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
>
> #2. Another one is IL Generator. Any idea how to replace this code ?
>
> public CtorDelegate GetConstructor(string name, Schema.Type
> schemaType, Type type)
> {
> ConstructorInfo ctorInfo = type.GetConstructor(Type.Empty
> Types);
> if (ctorInfo == null)
> throw new AvroException("Class " + name + " has no default
> constructor");
>
> DynamicMethod dynMethod = new DynamicMethod("DM$OBJ_FACTORY_"
> + name, typeof(object), null, type, true);
> ILGenerator ilGen = dynMethod.GetILGenerator();
> ilGen.Emit(OpCodes.Nop);
> ilGen.Emit(OpCodes.Newobj, ctorInfo);
> ilGen.Emit(OpCodes.Ret);
>
> return (CtorDelegate)dynMethod.CreateDelegate(ctorType);
> }
>
> Thanks
>
> Cheers
> --
> Welly Tambunan
> Triplelands
>
> http://weltam.wordpress.com
> http://www.triplelands.com <http://www.triplelands.com/blog/>
>
--
Ryan Blue
Software Engineer
Netflix
Re: Apache Avro to .NET Core
Posted by Ryan Blue <rb...@netflix.com>.
Hi Welly,
I'm not very familiar with .NET or the C# Avro library, hopefully others
can help answer your specific question. One alternative is to look at the
Microsoft C# library, which also has codegen features and is intended for
use for .NET:
https://azure.microsoft.com/en-us/updates/microsoft-avro-library-updated-to-include-c-code-generator/
rb
On Mon, Sep 5, 2016 at 5:12 AM, Welly Tambunan <if...@gmail.com> wrote:
> Hi All,
>
> I'm trying to port apache avro to .NET core.
>
> Here's the repository for the project
>
> https://github.com/welly87/Apache-Avro-Core
>
>
> However i found that some of the class and method is missing regarding
> Assembly loading and IL generation. I'm really close to completing the
> porting.
>
> [image: Inline image 1]
>
> #1. Is there any replacement on this line of code in .NET core ?
> Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
>
> #2. Another one is IL Generator. Any idea how to replace this code ?
>
> public CtorDelegate GetConstructor(string name, Schema.Type
> schemaType, Type type)
> {
> ConstructorInfo ctorInfo = type.GetConstructor(Type.Empty
> Types);
> if (ctorInfo == null)
> throw new AvroException("Class " + name + " has no default
> constructor");
>
> DynamicMethod dynMethod = new DynamicMethod("DM$OBJ_FACTORY_"
> + name, typeof(object), null, type, true);
> ILGenerator ilGen = dynMethod.GetILGenerator();
> ilGen.Emit(OpCodes.Nop);
> ilGen.Emit(OpCodes.Newobj, ctorInfo);
> ilGen.Emit(OpCodes.Ret);
>
> return (CtorDelegate)dynMethod.CreateDelegate(ctorType);
> }
>
> Thanks
>
> Cheers
> --
> Welly Tambunan
> Triplelands
>
> http://weltam.wordpress.com
> http://www.triplelands.com <http://www.triplelands.com/blog/>
>
--
Ryan Blue
Software Engineer
Netflix