我正在编写一个源生成器,该生成器会自动编写JSONOBJECT类,该类将JSON转换为运行时对象。
如屏幕截图中所示,您可以看到红色波浪线。它们是 CS0246 。但是,该项目可以成功构建而没有任何错误。这意味着源生成器有效。
是否可以让编辑器识别源生成器的工作?
此外,在解决方案资源管理器中,它显示了“该生成器没有生成文件”。这显然是不正确的。
I am writing a source generator that automatically writes JsonObject classes, that translantes JSON to run-time objects.

As shown in the screenshot, you can see red wavy lines. These are CS0246. However, the project can be successfully built without any error. That means the source generator works.
Is it possible to let the editor recognize the work of source generator?
Furthermore, in the solution explorer, it shows "This generator is not generating files." This is obviously incorrect.

发布评论
评论(1)
最终在Visual Studio 17.8.4中固定。它在17.8.3中没有工作。
这是我的生成器项目的
.csproj
:与各种教程相反,我认为在这里使用
privateassets =“ all”
在此处使用。我的消费者居住在同一解决方案中,并使用
ProjectReference
:This was finally fixed in Visual Studio 17.8.4. It did not work in 17.8.3.
This is the
.csproj
for my generator project:Contrary to various tutorials, I did not find it necessary to use
PrivateAssets="all"
here.My consumer resides in the same solution and references the generator with a
ProjectReference
: