每当存在可能的空引用异常时,Resharper建议使用这些注释来检查,断言或取消警告:
// ReSharper disable PossibleNullReferenceException
objectWhichCouldBeNull.DoSomething();
// ReSharper restore PossibleNullReferenceException
但是,注释总是在到源代码文档左边缘的路上缩进。有没有办法让注释与其他代码保持一致,特别是在使用Resharper Code Cleanup功能(Ctrl-Alt-F)时?
这是怎么回事:
// ReSharper disable PossibleNullReferenceException
objectWhichCouldBeNull.DoSomething();
// ReSharper restore PossibleNullReferenceException
答案 0 :(得分:1)
尝试停用ReSharper | Options | Code Editing | C# | Formatting Style | Other | Other | Don't indent comments started at first column