Browse Source

Fixed SD2-1422: VB Parser throws exception dealing with some attributes

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@3124 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 18 years ago
parent
commit
f57361a316
  1. 2
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs
  2. 2
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG
  3. 2
      src/Libraries/NRefactory/Project/Src/PrettyPrinter/VBNet/VBNetOutputVisitor.cs
  4. 12
      src/Libraries/NRefactory/Test/Output/VBNet/VBNetOutputTest.cs
  5. 7
      src/Libraries/NRefactory/Test/Parser/GlobalScope/AttributeSectionTests.cs

2
src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs

@ -159,7 +159,7 @@ out u); @@ -159,7 +159,7 @@ out u);
} else SynErr(209);
#line 2057 "VBNET.ATG"
string attributeTarget = t.val.ToLower(System.Globalization.CultureInfo.InvariantCulture);
string attributeTarget = t.val != null ? t.val.ToLower(System.Globalization.CultureInfo.InvariantCulture) : null;
List<ASTAttribute> attributes = new List<ASTAttribute>();
ASTAttribute attribute;

2
src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG

@ -2054,7 +2054,7 @@ TypeArgumentList<List<TypeReference> typeArguments> @@ -2054,7 +2054,7 @@ TypeArgumentList<List<TypeReference> typeArguments>
GlobalAttributeSection =
"<" (. Location startPos = t.Location; .)
("Assembly" | "Module")
(. string attributeTarget = t.val.ToLower(System.Globalization.CultureInfo.InvariantCulture);
(. string attributeTarget = t.val != null ? t.val.ToLower(System.Globalization.CultureInfo.InvariantCulture) : null;
List<ASTAttribute> attributes = new List<ASTAttribute>();
ASTAttribute attribute;
.)

2
src/Libraries/NRefactory/Project/Src/PrettyPrinter/VBNet/VBNetOutputVisitor.cs

@ -187,7 +187,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -187,7 +187,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.Indent();
outputFormatter.PrintText("<");
if (attributeSection.AttributeTarget != null && attributeSection.AttributeTarget.Length > 0) {
outputFormatter.PrintIdentifier(attributeSection.AttributeTarget);
outputFormatter.PrintText(char.ToUpperInvariant(attributeSection.AttributeTarget[0]) + attributeSection.AttributeTarget.Substring(1));
outputFormatter.PrintToken(Tokens.Colon);
outputFormatter.Space();
}

12
src/Libraries/NRefactory/Test/Output/VBNet/VBNetOutputTest.cs

@ -316,6 +316,18 @@ End Using"); @@ -316,6 +316,18 @@ End Using");
"End Class");
}
[Test]
public void AssemblyAttribute()
{
TestProgram("<Assembly: CLSCompliant>");
}
[Test]
public void ModuleAttribute()
{
TestProgram("<Module: SuppressMessageAttribute>");
}
[Test]
public void Interface()
{

7
src/Libraries/NRefactory/Test/Parser/GlobalScope/AttributeSectionTests.cs

@ -108,5 +108,12 @@ public class Form1 { @@ -108,5 +108,12 @@ public class Form1 {
Assert.AreEqual(new Location(1, 1), decl.StartLocation);
Assert.AreEqual("assembly", decl.AttributeTarget);
}
[Test]
public void ModuleAttributeTargetEscapedVB()
{
// check that this doesn't crash the parser:
ParseUtilVBNet.ParseGlobal<AttributeSection>("<[Module]: SuppressMessageAttribute>", true);
}
}
}

Loading…
Cancel
Save