提交 649383ff 编写于 作者: C Cyrus Najmabadi

Don't offer 'Generate Type' on lowercase names in VB

上级 91660094
...@@ -49,6 +49,12 @@ NewLines("Class C \n dim f as Foo \n End Class \n Friend Class Foo \n End Class" ...@@ -49,6 +49,12 @@ NewLines("Class C \n dim f as Foo \n End Class \n Friend Class Foo \n End Class"
index:=1) index:=1)
End Sub End Sub
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateType)>
Public Sub TestMissingOnLowercaseName()
TestMissing(
NewLines("Class C \n dim f as [|foo|] \n End Class"))
End Sub
<WorkItem(539716)> <WorkItem(539716)>
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateType)> <Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateType)>
Public Sub TestGenerateClassFromFullyQualifiedFieldIntoSameNamespace() Public Sub TestGenerateClassFromFullyQualifiedFieldIntoSameNamespace()
......
...@@ -111,6 +111,16 @@ private State(Compilation compilation) ...@@ -111,6 +111,16 @@ private State(Compilation compilation)
return false; return false;
} }
if (char.IsLower(name[0]) && !document.SemanticModel.Compilation.IsCaseSensitive)
{
// It's near universal in .Net that types start with a capital letter. As such,
// if this name starts with a lowercase letter, don't even bother to offer
// "generate type". The user most likely wants to run 'Add Import' (which will
// then fix up a case where they typed an existing type name in lowercase,
// intending the fix to case correct it).
return false;
}
this.NameOrMemberAccessExpression = generateTypeServiceStateOptions.NameOrMemberAccessExpression; this.NameOrMemberAccessExpression = generateTypeServiceStateOptions.NameOrMemberAccessExpression;
this.ObjectCreationExpressionOpt = generateTypeServiceStateOptions.ObjectCreationExpressionOpt; this.ObjectCreationExpressionOpt = generateTypeServiceStateOptions.ObjectCreationExpressionOpt;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册