Visual Studio 重构重命名导致 XAML 文件中的属性发生莫名其妙的全局替换
我觉得我一定是疯了,但我只是使用 Visual Studio 的重构将视图模型(C# 文件)中的属性名称从 Width
更改为 Size
-重命名功能。当我完成后,错误窗口中出现了这个错误:
错误 2:XML 命名空间“http://schemas.microsoft.com/winfx/2006/xaml/presentation”中不存在属性“Size”。
该错误引用了 XAML UserControl
文件。当我检查文件以查看发生了什么时,我意识到每个名为 Width
的属性都已更改为 Size
。
示例:
<UserControl x:Class="ApbSymbolGenerator.Views.Symbol"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
Size="{Binding Size}"
Height="{Binding Size}">
这是我第一次因重构重命名而导致 XAML 文件发生更改(除了 x:class
值)。 (注意:我没有进行全局查找/替换,我进行了重构重命名。我撤消了所有内容并再次执行了重命名,它做了同样的事情。)
奇怪的是,它只影响了其中之一我的应用程序中的几个具有 Width
属性的 XAML 文件。
有什么解释可以解释一下这里发生了什么吗?
I feel like I must be going crazy, but I just changed the name of a property in a view model (a C# file) from Width
to Size
using Visual Studio's refactor-rename feature. When I was done, this error appeared in the Error window:
Error 2: The property 'Size' does not exist in XML namespace 'http://schemas.microsoft.com/winfx/2006/xaml/presentation'.
The error was referring to a XAML UserControl
file. When I checked the file to see what was up, I realized that every attribute named Width
had been changed to Size
.
Example:
<UserControl x:Class="ApbSymbolGenerator.Views.Symbol"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
Size="{Binding Size}"
Height="{Binding Size}">
This is the first time I've ever had refactor-rename cause a change to a XAML file (besides the x:class
value). (Note: I did not do a global find/replace, I did refactor-rename. I undid everything and performed the rename again, and it did the same thing.)
Strangely, it only affected one of several XAML files in my app that has a Width
property.
Any explanation what could be going on here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来这是一个错误(不会被修复) - 重构重命名Bug
Looks like this is a bug (that won't be fixed) - Refactor Rename Bug