Adam's Lair Forum

game development and casual madness
It is currently 2018/12/15, 00:39

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: 2017/08/14, 06:56 
Junior Member
Junior Member

Joined: 2016/01/09, 22:52
Posts: 35
Role: Hobbyist
Hello everyone,

I spent a few hours today porting Wire (https://github.com/rogeralsing/Wire) to the PCL profile used by Duality Core Plugins. I have done absolutely no testing on it other than running the unit tests Wire has. The majority of the unit tests are passing, the ones that don't are related to things like serializing System.LINQ.Expressions types and MethodInfo objects. I believe it is usable for standard serialization use cases.

Wire is a very cool serialization library which can serialize arbitrary objects without the need for annotations (although it does support annotations to indicate whether to serialize members). It can also keep track of object references. It is uses runtime code generation to generate object serializers so it is fast. It serializes to a reasonably compact binary format.

I am planning on using this library for some networking related experiments I am doing with Duality so I should get some actual usage out of it soon. I thought some other Duality devs might want to use it for some of there own projects. Duality does of course already have a solid serialization system but it serializes to XML and as far as I know it does not use code generation like Wire does. I wanted the compact format and speed for my networking project.

Github: https://github.com/generatives/WirePCL
NuGet Package: https://www.nuget.org/packages/Wire.PCL


Top
 Profile  
 
PostPosted: 2017/08/14, 08:56 
Junior Member
Junior Member

Joined: 2017/07/20, 18:17
Posts: 27
Location: Germany
Role: Hobbyist
Hello,

while it may be noble to port something to PCL, it cannot be recommended. Portable-Class-Libraries are a dead technology, for example look at this Blogpost. PCL libraries have been replaced with .NET Standard libraries. .NET standard is intended to be platform indepent. Wire already supports .NET Standard 1.6 as you can see on Nuget.org.

You now may object that core plugins of Duality are PCL libraries out-of-the-box. That's correct. But this does not prevent you from using .NET Standard instead of PCL for the core plugin. Because PCL has such a small framework API and there are only little nuget packages on nuget.org, so it's really a bummer to use PCL, if you want to develop efficently with third-parties. If you want to maintain platform independence and not going to .NET Framework directly, .NET Standard is the way here. The compatibilities can be seen here.

.NET Standard and .NET Core are still relatively new in the .NET universe, so the support for actual .NET Standard 1.6 is only available in preview now. But this will change in the next weeks when Microsoft will release .NET Standard 2.0 and .NET Core 2.0, as you can see in the roadmap. Then you can easily use Wire directly based on .NET Standard.


Top
 Profile  
 
PostPosted: 2017/08/14, 18:08 
Junior Member
Junior Member

Joined: 2016/01/09, 22:52
Posts: 35
Role: Hobbyist
I tried to use Wire in my project but I was prevented by nuget. It said Wire was not compatible. Do I need to turn my Duality plugin into a .net standard project? I did notice that option in VS 2017.


Top
 Profile  
 
PostPosted: 2017/08/14, 21:57 
Site Admin
Site Admin
User avatar

Joined: 2013/05/11, 22:30
Posts: 2063
Location: Germany
Role: Professional
Faithless wrote:
while it may be noble to port something to PCL, it cannot be recommended. Portable-Class-Libraries are a dead technology, for example look at this Blogpost. PCL libraries have been replaced with .NET Standard libraries. .NET standard is intended to be platform indepent. Wire already supports .NET Standard 1.6 as you can see on Nuget.org.


While PCLs will be discontinued in the future, I wouldn't call them dead technology just yet. .Net Standard hasn't been around for very long, and for the most part, it feels like a rough sea to be in right now. It's the future, but I can understand if you'd decide to wait just a bit more until joining in.

Also, as both PCLs and .Net Standard are for the most part just API definitions, and compatible ones at that, it shouldn't be a big deal to convert PCLs to .Net Standard whenever you feel like it. The PCL profile that Duality uses, Profile 111, is roughly equivalent to .Net Standard 1.1, and I think a library built against PCL Profile 111 should "just work" in .Net Standard 1.1. be portable to .Net Standard 1.1 with a reasonably low effort later on.

So yeah. Doesn't hurt to start new projects in .Net Standard 1.1, but there shouldn't be too much work wasted when porting to PCL Profile 111 either. Reducing the required API surface from the framework side is one thing I don't think can turn out badly once it's done anyway.

Faithless wrote:
.NET Standard and .NET Core are still relatively new in the .NET universe, so the support for actual .NET Standard 1.6 is only available in preview now. But this will change in the next weeks when Microsoft will release .NET Standard 2.0 and .NET Core 2.0, as you can see in the roadmap. Then you can easily use Wire directly based on .NET Standard.


If that library is .Net Standard 1.6, that's still a lot more API surface that what the default Duality plugin will be at, which will likely be .Net Standard 1.1. It will still work, but the higher you get, the more you restrict yourself platform-wise. Won't matter for 99% of Duality users, just mentioning it for completeness.

_________________
Blog | GitHub | Twitter (@Adams_Lair)


Top
 Profile  
 
PostPosted: 2017/08/14, 23:51 
Junior Member
Junior Member

Joined: 2017/07/20, 18:17
Posts: 27
Location: Germany
Role: Hobbyist
Adam wrote:
While PCLs will be discontinued in the future, I wouldn't call them dead technology just yet.

My words may be a bit harsh to call it dead, I only want give point to one's words ^^ Especially for beginners and hobbyiest it's totally okay to use PCL. But porting stuff to obsolete technologies is really not what should be done. Additionally the port was already done by the Wire developer but to the state-of-the-art .NET Standard.

zakila wrote:
I tried to use Wire in my project but I was prevented by nuget. It said Wire was not compatible. Do I need to turn my Duality plugin into a .net standard project? I did notice that option in VS 2017.

As Adam already said, you can port your PCL core plugin to .NET Standard. But you need to use .NET Standard 1.6 in your core plugin, when you want to integrate Wire, but this is only available with Visual Studio 2017 Preview 15.3. So you have two options:

You cant wait and install Visual Studio 2017 Preview 15.3 (Blogpost). Microsoft says side by side installation with already installed Visual Studio 2017 version should work. I am bit more cautious, because it's a prerelease and you never know for sure. But if you install the preview you should be able to use .NET Standard 1.6 core plugin together with Wire immediately.

Seconds option: Wait until Microsoft releases .NET Standard 2.0 within the next weeks. The official Visual Studio 2017 Update 3 will go along with the release, so you dont need a separate Visual Studio installation. Until then you can only work with .NET Standard 1.5 at highest if you have installed at least the developer pack of .NET Framework 4.6.2 or .NET Standard 1.4 with .NET Framework 4.6.1.

Maybe third option: I suspect Wire uses enhanced Reflection so it has to rely on higher .NET Standard versions. If you are okay with attributed data classes you can also use protobuf-net. Microsoft itself recommends this package for platform independent binary serialization. It only needs .NET Standard 1.3. I am using it in my prototype and having a good experience so far.

One last important thing if you want to use .NET Standard within Duality: Duality does not integrate any .NET Standard Reference Library. But gladfully Duality resolves missing assemblies looking in the Plugin directory. Therefore you need to supply any used .NET Standard library (including the Wire .NET Standard lib) within the Plugin folder of Duality. You get FileNotFound- or AssemblyLoadExceptions in Duality or in the editor if some libs are missing. You then need to supply them to get your core plugin correctly to work. That's it.


Top
 Profile  
 
PostPosted: 2017/08/15, 04:40 
Junior Member
Junior Member

Joined: 2016/01/09, 22:52
Posts: 35
Role: Hobbyist
Alright well I will keep an eye on .net standard but I will probably stick to what I have working for now. I have seen protobuf-net but I would prefer not to use attributes for serialization.


Top
 Profile  
 
PostPosted: 2017/08/18, 13:50 
Junior Member
Junior Member

Joined: 2017/07/20, 18:17
Posts: 27
Location: Germany
Role: Hobbyist
Hmm, I didn't noticed on monday, but .NET Core and Standard 2.0 has been offically released. The supported API has been increased by round about 19.000 class members to 32.000. .NET Standard has a very respectable feature set now. The important Visual Studio 2017 Update 3 has also been released.

I already migrated my Duality core plugin of my protoype to .NET Standard 2.0 and it works so far. If you or someone else is interessted in, I can write a small tutorial on how to use .NET Standard 2.0 as Duality core plugin. The difficulty is not in porting from PCL to .NET Standard in Visual Studio. That's very easy. It's more about getting all the needed libraries to the plugin folder of Duality. Otherwise it will not work.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group