The namespace name #39;SyntaxTree#39; could not be found(找不到命名空间名称语法树)
问题描述
我正在Unity 2019.2.3f1中开发。我正在尝试编写一个可以Customize project files created by VSTU的脚本。为了防止链接被删除,我提供了一个与链接中的脚本非常相似的脚本。
#if ENABLE_VSTU
using System.IO;
using System.Text;
using System.Xml.Linq;
using UnityEditor;
using SyntaxTree.VisualStudio.Unity.Bridge;
[InitializeOnLoad]
public class ProjectFileHook
{
private class Utf8StringWriter : StringWriter
{
public override Encoding Encoding => Encoding.UTF8;
}
static ProjectFileHook()
{
ProjectFilesGenerator.ProjectFileGeneration += (string name, string content) =>
{
// parse the document and make some changes
XDocument document = XDocument.Parse(content);
document.Root?.Add(new XComment("FIX ME"));
// save the changes using the Utf8StringWriter
Utf8StringWriter str = new Utf8StringWriter();
document.Save(str);
return str.ToString();
};
}
}
#endif
问题是,由于错误error CS0246: The type or namespace name 'SyntaxTree' could not be found (are you missing a using directive or an assembly reference?),using SyntaxTree.VisualStudio.Unity.Bridge;无法编译。
我已检查Unity和Visual Studio是否已安装并启用Visual Studio Tools for Unity。
为什么代码无法编译?我是否遗漏了阻止它编译的内容?
推荐答案
以防其他人遇到此问题。
此问题是由脚本位置引起的。脚本必须位于Editor文件夹下,否则脚本不会按预期工作。
感谢therealjohn指出here。
这篇关于找不到命名空间名称语法树的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:找不到命名空间名称语法树
基础教程推荐
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- WPF 模态进度窗口 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
