英文:
Can "less relevant" (mainly XAML) errors be suppressed in Visual Studio until needed?
问题
抱歉,关于主题的描述比较模糊,但为了解释:
我正在开发一个包含多个项目和相互依赖的大型 WPF / C# 应用程序。有许多 XAML 文件引用各种内容,如控件、XML 命名空间等。
如果我构建解决方案,假设其中包含一个 C# 编译错误。这个编译错误将导致其所属的项目不被构建,这反过来可能导致其他项目也不被构建,依此类推。现在,所有这些项目/命名空间在 XAML 文件中的引用将产生进一步的错误。
结果是错误列表可能会显示数百个错误,其中只有一个是“真实”的错误,并且不一定出现在顶部或底部。因此,我必须浏览整个列表,寻找任何可能不是 XAML 错误或项目引用错误的错误,以找到一个 C# 语法错误。
是否有方法可以防止这种情况发生,或者是否有一种策略可以让这项工作变得更容易?理想的解决方案是,在更多“真实”错误得到解决之前,任何引用错误或 XAML“未找到”类型错误都被抑制,但如果无法实现这一点,是否有其他办法?
我知道 Visual Studio 提供了隐藏 XAML 设计错误的选项,但那样我担心它们根本不会显示出来(或者我将不得不不断启用/禁用选项) - 无论如何,它们可能仍然会在实际构建中显示出来。
英文:
Sorry about the vague subject line, but to explain:
I am working on a large WPF / C# application with many projects and interdependencies. There are a lot of XAML files which refer to various things like controls, XML namespaces, etc.
If I build the solution, and let's say it contains a C# compile error. That compile error will cause its project not to be built, which in turn might cause other projects not to be built, etc. Now all the references from these projects / namespaces in XAML files will produce further errors.
The result being that the Error List could show hundreds of errors, only one of which is "real", and which doesn't necessarily appear at the top or bottom. So I have to scroll through the entire list looking for any possible errors that aren't XAML errors or project reference errors to find the one C# syntax error.
Is there either a way of preventing this, or a strategy that could be followed for making this job easier? The ideal solution would be that any reference errors or XAML "not found" type errors be suppressed until more 'genuine' errors are resolved, but failing that is there anything that can be done?
I know Visual Studio does give you the option to hide XAML designer errors, but then I'd be afraid they'd never show up at all (or I would have to keep enabling / disabling options) - in any case they'd likely still show up on an actual build.
答案1
得分: 1
错误列表可以进行排序。默认情况下,它(多多少少)按顺序排序。但是您有几种可能性来找到相关错误:
- 查看“文件”列。与 xaml 文件相关的内容可能一开始并不重要。
- 查看“项目”列。通常您对依赖关系有一个想法。
- 重新排序列表(点击标题)。有时这有点棘手,但按照第一列或第二列的顺序排序列表应该按照它们发生的顺序进行排序(但请注意,有些项目并行构建,因此这可能不是确定性的)。
- 如果我遇到这个问题,我首选的解决方案是:切换到“输出”选项卡并向上滚动。在那里,错误的顺序确实是它们发生的顺序。
英文:
The error list can be sorted. By default, it's (more or less) sorted by order. But you have several possibilities to find the one relevant error:
- Look at the "File" column. Anything related to xaml files is probably not interesting at the beginning.
- Look at the "Project" column. You typically have an idea of the dependencies
- Reorder the list (click the headers). It's sometimes a bit tricky, but sorting by the first or the second column should order the list in the order they occurred (but note that some projects build in parallel, therefore this might not be deterministic)
- My preferred solution if I run into this problem: Switch to the "output" tab and scroll up. There, the order of errors is really the order in which they occurred.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论