Drizin / Drizin/CodegenCS

Visual Studio 2026 XmlDocument not found

未关闭
#38 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
C#
星标
307
派生
40
PR 合并指标
30 天内没有已合并 PR

描述

I am using the NuGet Package `CodegenCS.SourceGenerator` 3.5.2, this is working well with VS 2022 and `XmlDocument` in the .csx files:

```
#r "System.Xml.dll"
#r "System.Xml.ReaderWriter.dll"
// Requires CodegenCS.SourceGenerator NuGet package
using CodegenCS.Runtime;
using Newtonsoft.Json;
using System.IO;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Xml;
using System.Reflection;

public class UserTemplate
{
...
async Task GenerateConfig(ICodegenTextWriter writer, ICodegenTextWriter logWriter)
{
string prefix = string.Empty;
string key = string.Empty;

try
{
string fileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".apk", "ionos_dns.xml");
if (File.Exists(fileName))
{
XmlDocument doc = new XmlDocument();
doc.Load(fileName);
XmlNode nodeDns = doc.SelectSingleNode("/dns_info/api");
if (nodeDns != null)
{
XmlAttribute attribPrefix = nodeDns.Attributes["prefix"];
if (attribPrefix != null)
{
prefix = attribPrefix.Value;
logWriter.WriteLine($"Api: Prefix={prefix}");
}
XmlAttribute attribKey = nodeDns.Attributes["key"];
if (attribKey != null)
{
key = attribKey.Value;
logWriter.WriteLine($"Api: Key={key}");
}
}
}
else
{
logWriter.WriteLine($"Configuration file not found: {fileName}");
}
}
catch (Exception ex)
{
logWriter.WriteLine($"Exception: {ex.Message}");
return false;
}
...
}

```
When using it with VS2026 I get the error message:
1>CSC : error CODEGENCS002: Failed to build CodegenCS Template 'User.csx' (line 64 column 17): 'Der Typname "XmlDocument" konnte nicht im Namespace "System.Xml" gefunden werden. Dieser Typ wurde an Assembly "System.Xml.ReaderWriter, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" weitergeleitet. Sie sollten einen Verweis auf die Assembly hinzufügen.'
Is this simply not compatible with VS2026 or is a different #r command required?

贡献指南

这个仓库没有索引到贡献指南

调研方向

从 User.csx 和报告中显示的 #r 引用开始,比较 CodegenCS.SourceGenerator 在 VS 2022 和 VS 2026 下如何解析 System.Xml。确认报告中的程序集引用是否需要调整;完成的标准是模板能够在较新的 Visual Studio 版本下使用 XmlDocument 构建。

由索引模型根据 Issue 内容生成。

评估

技术栈
csharp
领域
tooling
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。