常规编译器和重构编译器之间的行为不匹配

常规编译器和重构编译器之间的行为不匹配

本文介绍了常规编译器和重构编译器之间的行为不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

包含的程序编译没有错误,但是当您尝试使用重构工具时会产生错误




J:\ TypeofTest \ TypeofTest1 \Program.cs(3,27):错误CS0246:无法找到类型或

命名空间名称''Bar''(你错过了使用

指令或汇编参考?)


此外,语法荧光笔不会突出显示条形图。在

" typeof(Bar)"作为一个班级。如果我用typeof(Foo.Bar)替换它,

一切都按预期工作。我不明白的是为什么有一个不同的
。是否可以在这样的属性中隐式引用内部
类(在这种情况下,似乎

重构编译器是不正确的)或者实际上是不允许的(在

这个案例肯定是常规编译器应该说些什么)?我是

使用Visual Studio 2005.


使用System.Diagnostics;


[DebuggerTypeProxy(typeof) (酒吧))]

公共课Foo

{

公共级酒吧

{

private Foo m_foo;

public Bar(Foo foo){m_foo = foo; }

}

}


班级课程

{

static void Main(){}

}

The included program compiles without errors, but produces an error
when you attempt to use a refactoring tool:

J:\TypeofTest\TypeofTest1\Program.cs(3,27): error CS0246: The type or
namespace name ''Bar'' could not be found (are you missing a using
directive or an assembly reference?)

In addition, the syntax highlighter doesn''t highlight the "Bar" in
"typeof(Bar)" as a class. If I replace that with "typeof(Foo.Bar)",
everything works as expected. What I don''t understand is why there is
a difference. Should it be possible to implicitly reference an inner
class in an attribute like this (in which case it seems the
refactoring compiler is incorrect) or is it in fact not allowed (in
which case surely the regular compiler should say something)? I''m
using Visual Studio 2005.

using System.Diagnostics;

[DebuggerTypeProxy(typeof(Bar))]
public class Foo
{
public class Bar
{
private Foo m_foo;
public Bar(Foo foo) { m_foo = foo; }
}
}

class Program
{
static void Main() { }
}

推荐答案




哪个重构工具?代码很好按原样。常规C#...


Marc

Which refactoring tool? The code is fine "as is" for regular C#...

Marc




哪个重构工具?代码很好按原样。对于普通的C#...


Marc


Which refactoring tool? The code is fine "as is" for regular C#...

Marc



Visual Studio 2005中的任何内置重构工具似乎都可以

对我而言。例如,右键单击程序 (或任何其他

标识符)并选择Refactor-> Rename ...。输出窗口将

切换到显示输出:重构我所描述的错误将会出现在其中的
。正如我所说,另一个症状是语法高亮。

如果我有typeof(Bar)。然后Bar将显示为黑色,而如果我具有typeof(Foo.Bar),则Foo.Bar将显示为黑色。将显示蓝绿色,颜色

表示类的名称。


我安装了Visual Assist X,但我禁用了这些测试。

Any of the built-in refactoring tools in Visual Studio 2005 seem to do
it for me. For example, right-click on "Program" (or any other
identifier) and choose "Refactor->Rename..." The output window will
switch to "Show output from: Refactor" and the error I described will
appear in it. The other symptom is the syntax highlighting, as I said.
If I have "typeof(Bar)" then "Bar" will appear black, whereas if I
have "typeof(Foo.Bar)", the "Foo.Bar" will appear teal, the colour
that indicates the name of a class.

I do have Visual Assist X installed, but I disabled it for these tests.


这篇关于常规编译器和重构编译器之间的行为不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 01:14