Browse Source

Fixed bug that caused VB resolver to not resolve fields of the current class within expressions like 'field(i)'.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@5726 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Daniel Grunwald 16 years ago
parent
commit
a378209c70
  1. 5
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/NRefactoryResolver.cs
  2. 32
      src/Main/ICSharpCode.SharpDevelop.Dom/Tests/ICSharpCode.SharpDevelop.Dom.Tests/CodeSnippetConverterTests.cs

5
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/NRefactoryResolver.cs

@ -642,6 +642,11 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
List<TypeReference> typeArguments, bool isInvocation, List<TypeReference> typeArguments, bool isInvocation,
bool allowExtensionMethods, bool? isAccessThoughReferenceOfCurrentClass) bool allowExtensionMethods, bool? isAccessThoughReferenceOfCurrentClass)
{ {
// in VB everything can be used with invocation syntax (because the same syntax also accesses indexers),
// do don't use 'isInvocation'.
if (language == NR.SupportedLanguage.VBNet)
isInvocation = false;
List<IList<IMember>> members = MemberLookupHelper.LookupMember(declaringType, memberName, callingClass, languageProperties, isInvocation, isAccessThoughReferenceOfCurrentClass); List<IList<IMember>> members = MemberLookupHelper.LookupMember(declaringType, memberName, callingClass, languageProperties, isInvocation, isAccessThoughReferenceOfCurrentClass);
List<IReturnType> typeArgs = null; List<IReturnType> typeArgs = null;
if (members != null && typeArguments != null && typeArguments.Count != 0) { if (members != null && typeArguments != null && typeArguments.Count != 0) {

32
src/Main/ICSharpCode.SharpDevelop.Dom/Tests/ICSharpCode.SharpDevelop.Dom.Tests/CodeSnippetConverterTests.cs

@ -140,6 +140,38 @@ namespace ICSharpCode.SharpDevelop.Dom.Tests
out errors))); out errors)));
} }
[Test]
public void ListAccessWithinForNextLoop()
{
Assert.AreEqual("public void A(System.Collections.Generic.List<string> l)\n" +
"{\n" +
" for (int i = 0; i <= l.Count - 1; i++) {\n" +
" sum += l[i].Length;\n" +
" }\n" +
"}",
Normalize(converter.VBToCSharp("Sub A(l As Generic.List(Of String))\n" +
" For i As Integer = 0 To l.Count - 1\n" +
" sum += l(i).Length\n" +
" Next\n" +
"End Sub",
out errors)));
}
[Test]
public void ListAccessOnField()
{
Assert.AreEqual("private System.Collections.Generic.List<System.Collections.Generic.List<string>> ParsedText = new System.Collections.Generic.List<System.Collections.Generic.List<string>>();\n" +
"public void A()\n" +
"{\n" +
" ParsedText[0].ToString();\n" +
"}",
Normalize(converter.VBToCSharp("Private ParsedText As New Generic.List(Of Generic.List(Of String))\n" +
"Sub A()\n" +
" ParsedText(0).ToString()\n" +
"End Sub",
out errors)));
}
string Normalize(string text) string Normalize(string text)
{ {
return text.Replace("\t", " ").Replace("\r", "").Trim(); return text.Replace("\t", " ").Replace("\r", "").Trim();

Loading…
Cancel
Save