Hello,
we have been successfully using you library for over a few months, however today I switched from packages.config to package reference in csproj file. That change resulted in ToolsVersion=15.
You claim that version 15 is supported on your site (I am using the very latest version of your mpc.exe tool (the quickfix version currently)). However the generated file is empty. The log does not contain any extra information that might be helpful.
#pragma warning disable 618
#pragma warning disable 612
#pragma warning disable 414
#pragma warning disable 168
namespace MessagePack.Resolvers
{
using System;
using MessagePack;
public class GeneratedResolver : global::MessagePack.IFormatterResolver
{
public static readonly global::MessagePack.IFormatterResolver Instance = new GeneratedResolver();
GeneratedResolver()
{
}
public global::MessagePack.Formatters.IMessagePackFormatter<T> GetFormatter<T>()
{
return FormatterCache<T>.formatter;
}
static class FormatterCache<T>
{
public static readonly global::MessagePack.Formatters.IMessagePackFormatter<T> formatter;
static FormatterCache()
{
var f = GeneratedResolverGetFormatterHelper.GetFormatter(typeof(T));
if (f != null)
{
formatter = (global::MessagePack.Formatters.IMessagePackFormatter<T>)f;
}
}
}
}
internal static class GeneratedResolverGetFormatterHelper
{
static readonly global::System.Collections.Generic.Dictionary<Type, int> lookup;
static GeneratedResolverGetFormatterHelper()
{
lookup = new global::System.Collections.Generic.Dictionary<Type, int>(0)
{
};
}
internal static object GetFormatter(Type t)
{
int key;
if (!lookup.TryGetValue(t, out key)) return null;
switch (key)
{
default: return null;
}
}
}
}
#pragma warning disable 168
#pragma warning restore 414
#pragma warning restore 618
#pragma warning restore 612
The console log is like this:
E:\Dev\mpc>mpc.exe -i "E:\Dev\moovshack\MoovShack.Api.Entities\MoovShack.Api.Ent
ities.csproj" -o "E:\Dev\moovshack\MoovShack.Core.NetStandard\MessagePackGenerat
ed.cs" -m
Project Compilation Start:E:\Dev\moovshack\MoovShack.Api.Entities\MoovShack.Api.
Entities.csproj
Project Compilation Complete:00:00:05.1846443Method Collect Start
Method Collect Complete:00:00:00.0019707
Output Generation Start
[Out]E:\Dev\moovshack\MoovShack.Core.NetStandard\MessagePackGenerated.cs
String Generation Complete:00:00:00.0148961
I'm having the exact same issue. I've been using this project since the beginning but I'm not sure if developer support is still coming to MessagePack. It's been almost 5 months without any update... :(
clone repo, open MessagePack.CodeGenerator, change nuget msbuild dependencies from nightly to stable.
if you use VS, add niglty nuget repositories in settings before.
you can find URLs in nuget.config file which is located next to .csproj
build it
update your Roslyn compiler to latest version (install latest version of .Net Framework 4.7.1 DevKit in VS Installer or just download it)
enjoy
Hello, does this apply for Mac users too?
Thanks.
@BenjaminMoore thanks a lot, it worked great!
@johnyK i guess yes. the problem is that mpc using nightly dependencies. if you can fix it on mac, then you're done.
If anyone of you have done this before, could you just submit a pull request? Hopefully neuecc would merge it in.
i'll submit fixes on weekends. just i have no time for separating the desired changes from ours repository
So has this already be done or forgotten - would be great to finally have a fixed mpc for mac :)
Thanks!
I tried to update Microsoft.Build.XXX packages to 15.8.166 and MessagePack.CodeGenerator outputted the Formatters of ToolsVersion 15 csproj classes.
I have got the same problem again - updated Visual Studio (kept the ToolsVersion to 14) and now getting the empty generated file again. Not sure why. Will investigate... sometimes it just starts working again (which is quite scary).
@JakubHolovsky Have a try to build my fork https://github.com/kiyoaki/MessagePack-CSharp/tree/master/src/MessagePack.CodeGenerator and copy that binary to your mpc.exe's directory.
@kiyoaki I can confirm that mpc.exe built from your fork does generate the file for me :) all of my tests are passing. Good job
Hey there and thanks for your help, sadly this doesn't seem to work on Mac OS? I tried to compile your fork on Visual Studio for Mac (that worked!). But using the mpc.exe with mono gives several errors: 'Microsoft.CodeAnalysis.MSBuild.ProjectFile:_loadedProject'....
@kiyoaki I can't resolve the MSBuildTools package when trying to build your fork as it is renamed to Build.Tools and MSBuildTools seems not to be avaialble on nuget anymore. When exchanging the package, it looks like the code does not compile as the classes have been renamed as well. Could you be so kind and guide me to a solution, I'm really annoyed with MessagePack-CSharp right now and it's abandonded state. Likely especially because at its core its a cool library.
Update: arg rider fooled me. It simply failed to resolve any dependency until I removed a check in the csproj file. Now I was able to build it and your fork indeed now properly generates thes Resolver. Thank you very much for it! Are there any other interesting bug fixes in your fork? :)
@kiyoaki has funded $5.00 to this issue. See it on IssueHunt
related #308, I've added new codegenerator.
It may solved.
@neuecc where can get the new mpc.exe... thanks
Code generator from this release:
https://github.com/neuecc/MessagePack-CSharp/releases/tag/v.1.7.3.6
resolves the issue.
Thus closing this.
Most helpful comment
Hey there and thanks for your help, sadly this doesn't seem to work on Mac OS? I tried to compile your fork on Visual Studio for Mac (that worked!). But using the mpc.exe with mono gives several errors: 'Microsoft.CodeAnalysis.MSBuild.ProjectFile:_loadedProject'....