Browse Source

NRefactory: Remove TypeReference.SystemType. TypeReference.Type now always represents the system type for primitive types.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3660 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 17 years ago
parent
commit
c816abee89
  1. 4
      src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConvertVisitor.cs
  2. 2
      src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConvertVisitorExpressions.cs
  3. 2
      src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConvertVisitorTypeMembers.cs
  4. 2
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/NRefactoryToPythonConverter.cs
  5. 2
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerLoader/NRefactoryDesignerLoader.cs
  6. 7
      src/Libraries/NRefactory/NRefactoryASTGenerator/AST/Expressions.cs
  7. 36
      src/Libraries/NRefactory/Project/Src/Ast/Generated.cs
  8. 44
      src/Libraries/NRefactory/Project/Src/Ast/TypeReference.cs
  9. 2
      src/Libraries/NRefactory/Project/Src/AstBuilder/ExpressionBuilder.cs
  10. 84
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs
  11. 84
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG
  12. 90
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs
  13. 90
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG
  14. 60
      src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs
  15. 35
      src/Libraries/NRefactory/Project/Src/PrettyPrinter/VBNet/VBNetOutputVisitor.cs
  16. 2
      src/Libraries/NRefactory/Project/Src/Visitors/CSharpConstructsConvertVisitor.cs
  17. 8
      src/Libraries/NRefactory/Project/Src/Visitors/CodeDOMOutputVisitor.cs
  18. 4
      src/Libraries/NRefactory/Project/Src/Visitors/ToCSharpConvertVisitor.cs
  19. 6
      src/Libraries/NRefactory/Project/Src/Visitors/VBNetConstructsConvertVisitor.cs
  20. 4
      src/Libraries/NRefactory/Test/Output/VBNet/CSharpToVBNetConverterTest.cs
  21. 7
      src/Libraries/NRefactory/Test/Parser/Expressions/ArrayCreateExpressionTests.cs
  22. 21
      src/Libraries/NRefactory/Test/Parser/Expressions/CastExpressionTests.cs
  23. 2
      src/Libraries/NRefactory/Test/Parser/Expressions/DefaultValueExpressionTests.cs
  24. 8
      src/Libraries/NRefactory/Test/Parser/Expressions/InvocationExpressionTests.cs
  25. 4
      src/Libraries/NRefactory/Test/Parser/Expressions/LambdaExpressionTests.cs
  26. 16
      src/Libraries/NRefactory/Test/Parser/Expressions/MemberReferenceExpressionTests.cs
  27. 14
      src/Libraries/NRefactory/Test/Parser/Expressions/ObjectCreateExpressionTests.cs
  28. 2
      src/Libraries/NRefactory/Test/Parser/Expressions/PointerReferenceExpressionTests.cs
  29. 4
      src/Libraries/NRefactory/Test/Parser/Expressions/QueryExpressionTests.cs
  30. 22
      src/Libraries/NRefactory/Test/Parser/Expressions/TypeOfExpressionTests.cs
  31. 10
      src/Libraries/NRefactory/Test/Parser/Expressions/TypeOfIsExpressionTests.cs
  32. 12
      src/Libraries/NRefactory/Test/Parser/Expressions/TypeReferenceExpressionTests.cs
  33. 8
      src/Libraries/NRefactory/Test/Parser/GlobalScope/DelegateDeclarationTests.cs
  34. 2
      src/Libraries/NRefactory/Test/Parser/GlobalScope/TypeDeclarationTests.cs
  35. 2
      src/Libraries/NRefactory/Test/Parser/GlobalScope/UsingDeclarationTests.cs
  36. 58
      src/Libraries/NRefactory/Test/Parser/Statements/LocalVariableDeclarationTests.cs
  37. 4
      src/Libraries/NRefactory/Test/Parser/TypeLevel/ConstructorDeclarationTests.cs
  38. 2
      src/Libraries/NRefactory/Test/Parser/TypeLevel/DeclareDeclarationTests.cs
  39. 2
      src/Libraries/NRefactory/Test/Parser/TypeLevel/EventDeclarationTests.cs
  40. 18
      src/Libraries/NRefactory/Test/Parser/TypeLevel/FieldDeclarationTests.cs
  41. 2
      src/Libraries/NRefactory/Test/Parser/TypeLevel/IndexerDeclarationTests.cs
  42. 38
      src/Libraries/NRefactory/Test/Parser/TypeLevel/MethodDeclarationTests.cs
  43. 4
      src/Libraries/NRefactory/Test/Parser/TypeLevel/OperatorDeclarationTests.cs
  44. 2
      src/Libraries/NRefactory/Test/Parser/TypeLevel/PropertyDeclarationTests.cs
  45. 3
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/CSharpToVBNetConvertVisitor.cs
  46. 2
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/NRefactoryResolver.cs
  47. 2
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/ResolveVisitor.cs
  48. 22
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/TypeVisitor.cs
  49. 2
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/VBNetToCSharpConvertVisitor.cs
  50. 30
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Refactoring/CodeGenerator.cs
  51. 2
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Refactoring/NRefactoryRefactoringProvider.cs

4
src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConvertVisitor.cs

@ -227,12 +227,12 @@ namespace NRefactoryToBooConverter
return null; return null;
B.TypeReference r; B.TypeReference r;
if (t.GenericTypes.Count > 0) { if (t.GenericTypes.Count > 0) {
r = new B.GenericTypeReference(GetLexicalInfo(t), GetIntrinsicTypeName(t.SystemType)); r = new B.GenericTypeReference(GetLexicalInfo(t), GetIntrinsicTypeName(t.Type));
foreach (TypeReference ta in t.GenericTypes) { foreach (TypeReference ta in t.GenericTypes) {
((B.GenericTypeReference)r).GenericArguments.Add(ConvertTypeReference(ta)); ((B.GenericTypeReference)r).GenericArguments.Add(ConvertTypeReference(ta));
} }
} else { } else {
r = new B.SimpleTypeReference(GetLexicalInfo(t), GetIntrinsicTypeName(t.SystemType)); r = new B.SimpleTypeReference(GetLexicalInfo(t), GetIntrinsicTypeName(t.Type));
} }
if (t.IsArrayType) { if (t.IsArrayType) {
for (int i = t.RankSpecifier.Length - 1; i >= 0; --i) { for (int i = t.RankSpecifier.Length - 1; i >= 0; --i) {

2
src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConvertVisitorExpressions.cs

@ -364,7 +364,7 @@ namespace NRefactoryToBooConverter
throw new ApplicationException("ObjectCreateExpression cannot be called with an ArrayType"); throw new ApplicationException("ObjectCreateExpression cannot be called with an ArrayType");
} }
// HACK: Tricking out event handlers // HACK: Tricking out event handlers
if (t.SystemType.EndsWith("EventHandler") && objectCreateExpression.Parameters.Count == 1) if (t.Type.EndsWith("EventHandler") && objectCreateExpression.Parameters.Count == 1)
return ConvertExpression((Expression)objectCreateExpression.Parameters[0]); return ConvertExpression((Expression)objectCreateExpression.Parameters[0]);
B.MethodInvocationExpression mie = new B.MethodInvocationExpression(GetLexicalInfo(objectCreateExpression), MakeReferenceExpression(t)); B.MethodInvocationExpression mie = new B.MethodInvocationExpression(GetLexicalInfo(objectCreateExpression), MakeReferenceExpression(t));

2
src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConvertVisitorTypeMembers.cs

@ -105,7 +105,7 @@ namespace NRefactoryToBooConverter
m.ReturnType = ConvertTypeReference(methodDeclaration.TypeReference); m.ReturnType = ConvertTypeReference(methodDeclaration.TypeReference);
m.Body = ConvertMethodBlock(methodDeclaration.Body); m.Body = ConvertMethodBlock(methodDeclaration.Body);
if (m.Name == "Main" && m.IsStatic && m.Parameters.Count <= 1 && if (m.Name == "Main" && m.IsStatic && m.Parameters.Count <= 1 &&
(methodDeclaration.TypeReference.SystemType == "System.Void" || methodDeclaration.TypeReference.SystemType == "System.Int32")) (methodDeclaration.TypeReference.Type == "System.Void" || methodDeclaration.TypeReference.Type == "System.Int32"))
{ {
entryPointMethod = m; entryPointMethod = m;
} }

2
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/NRefactoryToPythonConverter.cs

@ -729,7 +729,7 @@ namespace ICSharpCode.PythonBinding
{ {
// Create variable declaration. // Create variable declaration.
VariableDeclaration variableDeclaration = localVariableDeclaration.Variables[0]; VariableDeclaration variableDeclaration = localVariableDeclaration.Variables[0];
string variableType = localVariableDeclaration.TypeReference.SystemType; string variableType = localVariableDeclaration.TypeReference.Type;
string variableName = variableDeclaration.Name; string variableName = variableDeclaration.Name;
CodeVariableDeclarationStatement codeVariableDeclarationStatement = new CodeVariableDeclarationStatement(variableType, variableName); CodeVariableDeclarationStatement codeVariableDeclarationStatement = new CodeVariableDeclarationStatement(variableType, variableName);

2
src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerLoader/NRefactoryDesignerLoader.cs

@ -255,7 +255,7 @@ namespace ICSharpCode.FormsDesigner
{ {
if (type == null) if (type == null)
return; return;
if (type.SystemType != type.Type) if (type.Type != type.Type)
return; return;
foreach (TypeReference tref in type.GenericTypes) { foreach (TypeReference tref in type.GenericTypes) {
FixTypeReference(tref, location, domCu); FixTypeReference(tref, location, domCu);

7
src/Libraries/NRefactory/NRefactoryASTGenerator/AST/Expressions.cs

@ -114,12 +114,13 @@ namespace NRefactoryASTGenerator.Ast
public MemberReferenceExpression(Expression targetObject, string memberName) {} public MemberReferenceExpression(Expression targetObject, string memberName) {}
} }
[IncludeMember("[Obsolete] public string Identifier { get { return MemberName; } set { MemberName = value; } }")]
class PointerReferenceExpression : Expression { class PointerReferenceExpression : Expression {
Expression targetObject; Expression targetObject;
string identifier; string memberName;
List<TypeReference> typeArguments; List<TypeReference> typeArguments;
public PointerReferenceExpression(Expression targetObject, string identifier) {} public PointerReferenceExpression(Expression targetObject, string memberName) {}
} }
class IdentifierExpression : Expression { class IdentifierExpression : Expression {
@ -151,7 +152,7 @@ namespace NRefactoryASTGenerator.Ast
public TypeOfExpression(TypeReference typeReference) {} public TypeOfExpression(TypeReference typeReference) {}
} }
[IncludeMember("public TypeReferenceExpression(string typeName) : this(new TypeReference(typeName)) {}")] [IncludeMember("[Obsolete] public TypeReferenceExpression(string typeName) : this(new TypeReference(typeName)) {}")]
class TypeReferenceExpression : Expression { class TypeReferenceExpression : Expression {
TypeReference typeReference; TypeReference typeReference;

36
src/Libraries/NRefactory/Project/Src/Ast/Generated.cs

@ -2299,12 +2299,11 @@ namespace ICSharpCode.NRefactory.Ast {
elseIfSections = new List<ElseIfSection>(); elseIfSections = new List<ElseIfSection>();
} }
public bool HasElseIfSections {
public IfElseStatement(Expression condition, Statement trueStatement) get {
: this(condition) { return elseIfSections.Count > 0;
this.trueStatement.Add(Statement.CheckNull(trueStatement));
if (trueStatement != null) trueStatement.Parent = this;
} }
}
public bool HasElseStatements { public bool HasElseStatements {
get { get {
@ -2312,11 +2311,12 @@ namespace ICSharpCode.NRefactory.Ast {
} }
} }
public bool HasElseIfSections {
get { public IfElseStatement(Expression condition, Statement trueStatement)
return elseIfSections.Count > 0; : this(condition) {
this.trueStatement.Add(Statement.CheckNull(trueStatement));
if (trueStatement != null) trueStatement.Parent = this;
} }
}
public IfElseStatement(Expression condition, Statement trueStatement, Statement falseStatement) public IfElseStatement(Expression condition, Statement trueStatement, Statement falseStatement)
@ -3256,7 +3256,7 @@ public Location ExtendedEndLocation { get; set; }
Expression targetObject; Expression targetObject;
string identifier; string memberName;
List<TypeReference> typeArguments; List<TypeReference> typeArguments;
@ -3270,12 +3270,12 @@ public Location ExtendedEndLocation { get; set; }
} }
} }
public string Identifier { public string MemberName {
get { get {
return identifier; return memberName;
} }
set { set {
identifier = value ?? ""; memberName = value ?? "";
} }
} }
@ -3288,18 +3288,20 @@ public Location ExtendedEndLocation { get; set; }
} }
} }
public PointerReferenceExpression(Expression targetObject, string identifier) { public PointerReferenceExpression(Expression targetObject, string memberName) {
TargetObject = targetObject; TargetObject = targetObject;
Identifier = identifier; MemberName = memberName;
typeArguments = new List<TypeReference>(); typeArguments = new List<TypeReference>();
} }
[Obsolete] public string Identifier { get { return MemberName; } set { MemberName = value; } }
public override object AcceptVisitor(IAstVisitor visitor, object data) { public override object AcceptVisitor(IAstVisitor visitor, object data) {
return visitor.VisitPointerReferenceExpression(this, data); return visitor.VisitPointerReferenceExpression(this, data);
} }
public override string ToString() { public override string ToString() {
return string.Format("[PointerReferenceExpression TargetObject={0} Identifier={1} TypeArguments={2}]", TargetObject, Identifier, GetCollectionString(TypeArguments)); return string.Format("[PointerReferenceExpression TargetObject={0} MemberName={1} TypeArguments={2}]", TargetObject, MemberName, GetCollectionString(TypeArguments));
} }
} }
@ -5034,7 +5036,7 @@ public Location ExtendedEndLocation { get; set; }
TypeReference = typeReference; TypeReference = typeReference;
} }
public TypeReferenceExpression(string typeName) : this(new TypeReference(typeName)) {} [Obsolete] public TypeReferenceExpression(string typeName) : this(new TypeReference(typeName)) {}
public override object AcceptVisitor(IAstVisitor visitor, object data) { public override object AcceptVisitor(IAstVisitor visitor, object data) {
return visitor.VisitTypeReferenceExpression(this, data); return visitor.VisitTypeReferenceExpression(this, data);

44
src/Libraries/NRefactory/Project/Src/Ast/TypeReference.cs

@ -9,6 +9,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Globalization; using System.Globalization;
using System.Runtime.InteropServices;
using System.Text; using System.Text;
namespace ICSharpCode.NRefactory.Ast namespace ICSharpCode.NRefactory.Ast
@ -20,11 +21,9 @@ namespace ICSharpCode.NRefactory.Ast
public static readonly TypeReference NewConstraint = new TypeReference("constraint: new"); public static readonly TypeReference NewConstraint = new TypeReference("constraint: new");
string type = ""; string type = "";
string systemType = "";
int pointerNestingLevel; int pointerNestingLevel;
int[] rankSpecifier; int[] rankSpecifier;
List<TypeReference> genericTypes = new List<TypeReference>(); List<TypeReference> genericTypes = new List<TypeReference>();
bool isGlobal;
#region Static primitive type list #region Static primitive type list
static Dictionary<string, string> types = new Dictionary<string, string>(); static Dictionary<string, string> types = new Dictionary<string, string>();
@ -129,7 +128,7 @@ namespace ICSharpCode.NRefactory.Ast
public virtual TypeReference Clone() public virtual TypeReference Clone()
{ {
TypeReference c = new TypeReference(type, systemType); TypeReference c = new TypeReference(type);
CopyFields(this, c); CopyFields(this, c);
return c; return c;
} }
@ -150,7 +149,8 @@ namespace ICSharpCode.NRefactory.Ast
foreach (TypeReference r in from.genericTypes) { foreach (TypeReference r in from.genericTypes) {
to.genericTypes.Add(r.Clone()); to.genericTypes.Add(r.Clone());
} }
to.isGlobal = from.isGlobal; to.IsGlobal = from.IsGlobal;
to.IsKeyword = from.IsKeyword;
} }
public string Type { public string Type {
@ -159,8 +159,7 @@ namespace ICSharpCode.NRefactory.Ast
} }
set { set {
Debug.Assert(value != null); Debug.Assert(value != null);
type = value; type = value ?? "?";
systemType = GetSystemType(type);
} }
} }
@ -186,9 +185,10 @@ namespace ICSharpCode.NRefactory.Ast
} }
} }
[Obsolete("Use 'Type' instead - it now contains the SystemType for primitive types.")]
public string SystemType { public string SystemType {
get { get {
return systemType; return this.Type;
} }
} }
@ -251,12 +251,14 @@ namespace ICSharpCode.NRefactory.Ast
/// Gets/Sets if the type reference had a "global::" prefix. /// Gets/Sets if the type reference had a "global::" prefix.
/// </summary> /// </summary>
public bool IsGlobal { public bool IsGlobal {
get { get; set;
return isGlobal; }
}
set { /// <summary>
isGlobal = value; /// Gets/Sets if the type reference was using a language keyword.
} /// </summary>
public bool IsKeyword {
get; set;
} }
public TypeReference(string type) public TypeReference(string type)
@ -264,10 +266,17 @@ namespace ICSharpCode.NRefactory.Ast
this.Type = type; this.Type = type;
} }
[Obsolete("Type and SystemType are no longer distinguised - use the (string type, bool isKeyword) constructor instead!")]
public TypeReference(string type, string systemType) public TypeReference(string type, string systemType)
{ {
this.type = type; this.Type = systemType;
this.systemType = systemType; this.IsKeyword = type != systemType;
}
public TypeReference(string type, bool isKeyword)
{
this.Type = type;
this.IsKeyword = isKeyword;
} }
public TypeReference(string type, List<TypeReference> genericTypes) : this(type) public TypeReference(string type, List<TypeReference> genericTypes) : this(type)
@ -289,7 +298,6 @@ namespace ICSharpCode.NRefactory.Ast
{ {
Debug.Assert(type != null); Debug.Assert(type != null);
this.type = type; this.type = type;
this.systemType = GetSystemType(type);
this.pointerNestingLevel = pointerNestingLevel; this.pointerNestingLevel = pointerNestingLevel;
this.rankSpecifier = rankSpecifier; this.rankSpecifier = rankSpecifier;
if (genericTypes != null) { if (genericTypes != null) {
@ -338,7 +346,9 @@ namespace ICSharpCode.NRefactory.Ast
if (a == null || b == null) return false; if (a == null || b == null) return false;
if (a is InnerClassTypeReference) a = ((InnerClassTypeReference)a).CombineToNormalTypeReference(); if (a is InnerClassTypeReference) a = ((InnerClassTypeReference)a).CombineToNormalTypeReference();
if (b is InnerClassTypeReference) b = ((InnerClassTypeReference)b).CombineToNormalTypeReference(); if (b is InnerClassTypeReference) b = ((InnerClassTypeReference)b).CombineToNormalTypeReference();
if (a.systemType != b.systemType) return false; if (a.type != b.type) return false;
if (a.IsKeyword != b.IsKeyword) return false;
if (a.IsGlobal != b.IsGlobal) return false;
if (a.pointerNestingLevel != b.pointerNestingLevel) return false; if (a.pointerNestingLevel != b.pointerNestingLevel) return false;
if (a.IsArrayType != b.IsArrayType) return false; if (a.IsArrayType != b.IsArrayType) return false;
if (a.IsArrayType) { if (a.IsArrayType) {

2
src/Libraries/NRefactory/Project/Src/AstBuilder/ExpressionBuilder.cs

@ -57,7 +57,7 @@ namespace ICSharpCode.NRefactory.AstBuilder
public static Expression CreateDefaultValueForType(TypeReference type) public static Expression CreateDefaultValueForType(TypeReference type)
{ {
if (type != null && !type.IsArrayType) { if (type != null && !type.IsArrayType) {
switch (type.SystemType) { switch (type.Type) {
case "System.SByte": case "System.SByte":
case "System.Byte": case "System.Byte":
case "System.Int16": case "System.Int16":

84
src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs

@ -234,13 +234,13 @@ out type, false);
out name); out name);
#line 591 "cs.ATG" #line 591 "cs.ATG"
type = new TypeReference(name); type = new TypeReference(name, true);
} else if (la.kind == 123) { } else if (la.kind == 123) {
lexer.NextToken(); lexer.NextToken();
Expect(6); Expect(6);
#line 592 "cs.ATG" #line 592 "cs.ATG"
pointer = 1; type = new TypeReference("void"); pointer = 1; type = new TypeReference("System.Void", true);
} else SynErr(147); } else SynErr(147);
if (la.kind == 12) { if (la.kind == 12) {
NullableQuestionMark( NullableQuestionMark(
@ -849,7 +849,7 @@ templates);
out name); out name);
#line 436 "cs.ATG" #line 436 "cs.ATG"
newType.BaseTypes.Add(new TypeReference(name)); newType.BaseTypes.Add(new TypeReference(name, true));
} }
#line 438 "cs.ATG" #line 438 "cs.ATG"
@ -877,7 +877,7 @@ NotVoidPointer()) {
Expect(123); Expect(123);
#line 448 "cs.ATG" #line 448 "cs.ATG"
delegateDeclr.ReturnType = new TypeReference("void", 0, null); delegateDeclr.ReturnType = new TypeReference("System.Void", true);
} else if (StartOf(10)) { } else if (StartOf(10)) {
Type( Type(
#line 449 "cs.ATG" #line 449 "cs.ATG"
@ -1159,63 +1159,63 @@ out string name) {
lexer.NextToken(); lexer.NextToken();
#line 694 "cs.ATG" #line 694 "cs.ATG"
name = "sbyte"; name = "System.SByte";
break; break;
} }
case 54: { case 54: {
lexer.NextToken(); lexer.NextToken();
#line 695 "cs.ATG" #line 695 "cs.ATG"
name = "byte"; name = "System.Byte";
break; break;
} }
case 104: { case 104: {
lexer.NextToken(); lexer.NextToken();
#line 696 "cs.ATG" #line 696 "cs.ATG"
name = "short"; name = "System.Int16";
break; break;
} }
case 120: { case 120: {
lexer.NextToken(); lexer.NextToken();
#line 697 "cs.ATG" #line 697 "cs.ATG"
name = "ushort"; name = "System.UInt16";
break; break;
} }
case 82: { case 82: {
lexer.NextToken(); lexer.NextToken();
#line 698 "cs.ATG" #line 698 "cs.ATG"
name = "int"; name = "System.Int32";
break; break;
} }
case 116: { case 116: {
lexer.NextToken(); lexer.NextToken();
#line 699 "cs.ATG" #line 699 "cs.ATG"
name = "uint"; name = "System.UInt32";
break; break;
} }
case 87: { case 87: {
lexer.NextToken(); lexer.NextToken();
#line 700 "cs.ATG" #line 700 "cs.ATG"
name = "long"; name = "System.Int64";
break; break;
} }
case 117: { case 117: {
lexer.NextToken(); lexer.NextToken();
#line 701 "cs.ATG" #line 701 "cs.ATG"
name = "ulong"; name = "System.UInt64";
break; break;
} }
case 57: { case 57: {
lexer.NextToken(); lexer.NextToken();
#line 702 "cs.ATG" #line 702 "cs.ATG"
name = "char"; name = "System.Char";
break; break;
} }
default: SynErr(156); break; default: SynErr(156); break;
@ -1343,12 +1343,12 @@ out r, canBeUnbound);
lexer.NextToken(); lexer.NextToken();
#line 688 "cs.ATG" #line 688 "cs.ATG"
typeRef = new TypeReference("object"); typeRef = new TypeReference("System.Object", true);
} else if (la.kind == 108) { } else if (la.kind == 108) {
lexer.NextToken(); lexer.NextToken();
#line 689 "cs.ATG" #line 689 "cs.ATG"
typeRef = new TypeReference("string"); typeRef = new TypeReference("System.String", true);
} else SynErr(159); } else SynErr(159);
} }
@ -1683,7 +1683,7 @@ p);
MethodDeclaration methodDeclaration = new MethodDeclaration { MethodDeclaration methodDeclaration = new MethodDeclaration {
Name = qualident, Name = qualident,
Modifier = m.Modifier, Modifier = m.Modifier,
TypeReference = new TypeReference("void"), TypeReference = new TypeReference("System.Void", true),
Parameters = p, Parameters = p,
Attributes = attributes, Attributes = attributes,
StartLocation = m.GetDeclarationLocation(startPos), StartLocation = m.GetDeclarationLocation(startPos),
@ -2269,7 +2269,7 @@ templates);
#line 1073 "cs.ATG" #line 1073 "cs.ATG"
MethodDeclaration md = new MethodDeclaration { MethodDeclaration md = new MethodDeclaration {
Name = name, Modifier = mod, TypeReference = new TypeReference("void"), Name = name, Modifier = mod, TypeReference = new TypeReference("System.Void", true),
Parameters = parameters, Attributes = attributes, Templates = templates, Parameters = parameters, Attributes = attributes, Templates = templates,
StartLocation = startLocation, EndLocation = t.EndLocation StartLocation = startLocation, EndLocation = t.EndLocation
}; };
@ -2437,13 +2437,13 @@ out type, canBeUnbound);
out name); out name);
#line 564 "cs.ATG" #line 564 "cs.ATG"
type = new TypeReference(name); type = new TypeReference(name, true);
} else if (la.kind == 123) { } else if (la.kind == 123) {
lexer.NextToken(); lexer.NextToken();
Expect(6); Expect(6);
#line 565 "cs.ATG" #line 565 "cs.ATG"
pointer = 1; type = new TypeReference("void"); pointer = 1; type = new TypeReference("System.Void", true);
} else SynErr(178); } else SynErr(178);
#line 566 "cs.ATG" #line 566 "cs.ATG"
@ -2503,22 +2503,22 @@ out name);
lexer.NextToken(); lexer.NextToken();
#line 607 "cs.ATG" #line 607 "cs.ATG"
name = "float"; name = "System.Single";
} else if (la.kind == 66) { } else if (la.kind == 66) {
lexer.NextToken(); lexer.NextToken();
#line 608 "cs.ATG" #line 608 "cs.ATG"
name = "double"; name = "System.Double";
} else if (la.kind == 62) { } else if (la.kind == 62) {
lexer.NextToken(); lexer.NextToken();
#line 609 "cs.ATG" #line 609 "cs.ATG"
name = "decimal"; name = "System.Decimal";
} else if (la.kind == 52) { } else if (la.kind == 52) {
lexer.NextToken(); lexer.NextToken();
#line 610 "cs.ATG" #line 610 "cs.ATG"
name = "bool"; name = "System.Boolean";
} else SynErr(180); } else SynErr(180);
} }
@ -2532,7 +2532,7 @@ ref TypeReference typeRef) {
#line 2283 "cs.ATG" #line 2283 "cs.ATG"
if (typeRef != null) typeArguments.Add(typeRef); if (typeRef != null) typeArguments.Add(typeRef);
typeRef = new TypeReference("System.Nullable", typeArguments); typeRef = new TypeReference("System.Nullable", typeArguments) { IsKeyword = true };
} }
@ -4419,118 +4419,118 @@ out expr);
lexer.NextToken(); lexer.NextToken();
#line 1856 "cs.ATG" #line 1856 "cs.ATG"
val = "bool"; val = "System.Boolean";
break; break;
} }
case 54: { case 54: {
lexer.NextToken(); lexer.NextToken();
#line 1857 "cs.ATG" #line 1857 "cs.ATG"
val = "byte"; val = "System.Byte";
break; break;
} }
case 57: { case 57: {
lexer.NextToken(); lexer.NextToken();
#line 1858 "cs.ATG" #line 1858 "cs.ATG"
val = "char"; val = "System.Char";
break; break;
} }
case 62: { case 62: {
lexer.NextToken(); lexer.NextToken();
#line 1859 "cs.ATG" #line 1859 "cs.ATG"
val = "decimal"; val = "System.Decimal";
break; break;
} }
case 66: { case 66: {
lexer.NextToken(); lexer.NextToken();
#line 1860 "cs.ATG" #line 1860 "cs.ATG"
val = "double"; val = "System.Double";
break; break;
} }
case 75: { case 75: {
lexer.NextToken(); lexer.NextToken();
#line 1861 "cs.ATG" #line 1861 "cs.ATG"
val = "float"; val = "System.Single";
break; break;
} }
case 82: { case 82: {
lexer.NextToken(); lexer.NextToken();
#line 1862 "cs.ATG" #line 1862 "cs.ATG"
val = "int"; val = "System.Int32";
break; break;
} }
case 87: { case 87: {
lexer.NextToken(); lexer.NextToken();
#line 1863 "cs.ATG" #line 1863 "cs.ATG"
val = "long"; val = "System.Int64";
break; break;
} }
case 91: { case 91: {
lexer.NextToken(); lexer.NextToken();
#line 1864 "cs.ATG" #line 1864 "cs.ATG"
val = "object"; val = "System.Object";
break; break;
} }
case 102: { case 102: {
lexer.NextToken(); lexer.NextToken();
#line 1865 "cs.ATG" #line 1865 "cs.ATG"
val = "sbyte"; val = "System.SByte";
break; break;
} }
case 104: { case 104: {
lexer.NextToken(); lexer.NextToken();
#line 1866 "cs.ATG" #line 1866 "cs.ATG"
val = "short"; val = "System.Int16";
break; break;
} }
case 108: { case 108: {
lexer.NextToken(); lexer.NextToken();
#line 1867 "cs.ATG" #line 1867 "cs.ATG"
val = "string"; val = "System.String";
break; break;
} }
case 116: { case 116: {
lexer.NextToken(); lexer.NextToken();
#line 1868 "cs.ATG" #line 1868 "cs.ATG"
val = "uint"; val = "System.UInt32";
break; break;
} }
case 117: { case 117: {
lexer.NextToken(); lexer.NextToken();
#line 1869 "cs.ATG" #line 1869 "cs.ATG"
val = "ulong"; val = "System.UInt64";
break; break;
} }
case 120: { case 120: {
lexer.NextToken(); lexer.NextToken();
#line 1870 "cs.ATG" #line 1870 "cs.ATG"
val = "ushort"; val = "System.UInt16";
break; break;
} }
case 123: { case 123: {
lexer.NextToken(); lexer.NextToken();
#line 1871 "cs.ATG" #line 1871 "cs.ATG"
val = "void"; val = "System.Void";
break; break;
} }
} }
MemberAccess( MemberAccess(
#line 1873 "cs.ATG" #line 1873 "cs.ATG"
out pexpr, new TypeReferenceExpression(val) { StartLocation = t.Location, EndLocation = t.EndLocation } ); out pexpr, new TypeReferenceExpression(new TypeReference(val, true)) { StartLocation = t.Location, EndLocation = t.EndLocation } );
} else if (la.kind == 111) { } else if (la.kind == 111) {
lexer.NextToken(); lexer.NextToken();
@ -4554,7 +4554,7 @@ NotVoidPointer()) {
Expect(123); Expect(123);
#line 1885 "cs.ATG" #line 1885 "cs.ATG"
type = new TypeReference("void"); type = new TypeReference("System.Void", true);
} else if (StartOf(10)) { } else if (StartOf(10)) {
TypeWithRestriction( TypeWithRestriction(
#line 1886 "cs.ATG" #line 1886 "cs.ATG"

84
src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG

@ -433,7 +433,7 @@ TypeDecl<ModifierList m, List<AttributeSection> attributes>
newType.Type = Types.Enum; newType.Type = Types.Enum;
.) .)
Identifier (. newType.Name = t.val; .) Identifier (. newType.Name = t.val; .)
[ ":" IntegralType<out name> (. newType.BaseTypes.Add(new TypeReference(name)); .) [ ":" IntegralType<out name> (. newType.BaseTypes.Add(new TypeReference(name, true)); .)
] ]
(. newType.BodyStartLocation = t.EndLocation; .) (. newType.BodyStartLocation = t.EndLocation; .)
EnumBody EnumBody
@ -445,7 +445,7 @@ TypeDecl<ModifierList m, List<AttributeSection> attributes>
templates = delegateDeclr.Templates; templates = delegateDeclr.Templates;
delegateDeclr.StartLocation = m.GetDeclarationLocation(t.Location); delegateDeclr.StartLocation = m.GetDeclarationLocation(t.Location);
.) .)
( IF (NotVoidPointer()) "void" (. delegateDeclr.ReturnType = new TypeReference("void", 0, null); .) ( IF (NotVoidPointer()) "void" (. delegateDeclr.ReturnType = new TypeReference("System.Void", true); .)
| Type<out type> (. delegateDeclr.ReturnType = type; .) | Type<out type> (. delegateDeclr.ReturnType = type; .)
) )
Identifier (. delegateDeclr.Name = t.val; .) Identifier (. delegateDeclr.Name = t.val; .)
@ -561,8 +561,8 @@ TypeWithRestriction<out TypeReference type, bool allowNullable, bool canBeUnboun
.) .)
= =
( ClassType<out type, canBeUnbound> ( ClassType<out type, canBeUnbound>
| SimpleType<out name> (. type = new TypeReference(name); .) | SimpleType<out name> (. type = new TypeReference(name, true); .)
| "void" "*" (. pointer = 1; type = new TypeReference("void"); .) | "void" "*" (. pointer = 1; type = new TypeReference("System.Void", true); .)
) (. List<int> r = new List<int>(); .) ) (. List<int> r = new List<int>(); .)
[ IF (allowNullable && la.kind == Tokens.Question) NullableQuestionMark<ref type> ] [ IF (allowNullable && la.kind == Tokens.Question) NullableQuestionMark<ref type> ]
@ -588,8 +588,8 @@ NonArrayType<out TypeReference type>
.) .)
= =
( ClassType<out type, false> ( ClassType<out type, false>
| SimpleType<out name> (. type = new TypeReference(name); .) | SimpleType<out name> (. type = new TypeReference(name, true); .)
| "void" "*" (. pointer = 1; type = new TypeReference("void"); .) | "void" "*" (. pointer = 1; type = new TypeReference("System.Void", true); .)
) )
[ NullableQuestionMark<ref type> ] [ NullableQuestionMark<ref type> ]
@ -604,10 +604,10 @@ SimpleType<out string name>
(. name = String.Empty; .) (. name = String.Empty; .)
= =
IntegralType<out name> IntegralType<out name>
| "float" (. name = "float"; .) | "float" (. name = "System.Single"; .)
| "double" (. name = "double"; .) | "double" (. name = "System.Double"; .)
| "decimal" (. name = "decimal"; .) | "decimal" (. name = "System.Decimal"; .)
| "bool" (. name = "bool"; .) | "bool" (. name = "System.Boolean"; .)
. .
@ -685,21 +685,21 @@ ClassType<out TypeReference typeRef, bool canBeUnbound>
(. TypeReference r; typeRef = null; .) (. TypeReference r; typeRef = null; .)
= =
TypeName<out r, canBeUnbound> (. typeRef = r; .) TypeName<out r, canBeUnbound> (. typeRef = r; .)
| "object" (. typeRef = new TypeReference("object"); .) | "object" (. typeRef = new TypeReference("System.Object", true); .)
| "string" (. typeRef = new TypeReference("string"); .) | "string" (. typeRef = new TypeReference("System.String", true); .)
. .
IntegralType<out string name> (. name = ""; .) IntegralType<out string name> (. name = ""; .)
= =
"sbyte" (. name = "sbyte"; .) "sbyte" (. name = "System.SByte"; .)
| "byte" (. name = "byte"; .) | "byte" (. name = "System.Byte"; .)
| "short" (. name = "short"; .) | "short" (. name = "System.Int16"; .)
| "ushort" (. name = "ushort"; .) | "ushort" (. name = "System.UInt16"; .)
| "int" (. name = "int"; .) | "int" (. name = "System.Int32"; .)
| "uint" (. name = "uint"; .) | "uint" (. name = "System.UInt32"; .)
| "long" (. name = "long"; .) | "long" (. name = "System.Int64"; .)
| "ulong" (. name = "ulong"; .) | "ulong" (. name = "System.UInt64"; .)
| "char" (. name = "char"; .) | "char" (. name = "System.Char"; .)
. .
MemberModifiers<ModifierList m> MemberModifiers<ModifierList m>
@ -770,7 +770,7 @@ StructMemberDecl<ModifierList m, List<AttributeSection> attributes>
(. MethodDeclaration methodDeclaration = new MethodDeclaration { (. MethodDeclaration methodDeclaration = new MethodDeclaration {
Name = qualident, Name = qualident,
Modifier = m.Modifier, Modifier = m.Modifier,
TypeReference = new TypeReference("void"), TypeReference = new TypeReference("System.Void", true),
Parameters = p, Parameters = p,
Attributes = attributes, Attributes = attributes,
StartLocation = m.GetDeclarationLocation(startPos), StartLocation = m.GetDeclarationLocation(startPos),
@ -1071,7 +1071,7 @@ InterfaceMemberDecl
{ TypeParameterConstraintsClause<templates> } { TypeParameterConstraintsClause<templates> }
";" ";"
(. MethodDeclaration md = new MethodDeclaration { (. MethodDeclaration md = new MethodDeclaration {
Name = name, Modifier = mod, TypeReference = new TypeReference("void"), Name = name, Modifier = mod, TypeReference = new TypeReference("System.Void", true),
Parameters = parameters, Attributes = attributes, Templates = templates, Parameters = parameters, Attributes = attributes, Templates = templates,
StartLocation = startLocation, EndLocation = t.EndLocation StartLocation = startLocation, EndLocation = t.EndLocation
}; };
@ -1853,24 +1853,24 @@ PrimaryExpr<out Expression pexpr>
| /*--- predefined type member access: */ | /*--- predefined type member access: */
(. string val = null; .) (. string val = null; .)
( "bool" (. val = "bool"; .) ( "bool" (. val = "System.Boolean"; .)
| "byte" (. val = "byte"; .) | "byte" (. val = "System.Byte"; .)
| "char" (. val = "char"; .) | "char" (. val = "System.Char"; .)
| "decimal" (. val = "decimal"; .) | "decimal" (. val = "System.Decimal"; .)
| "double" (. val = "double"; .) | "double" (. val = "System.Double"; .)
| "float" (. val = "float"; .) | "float" (. val = "System.Single"; .)
| "int" (. val = "int"; .) | "int" (. val = "System.Int32"; .)
| "long" (. val = "long"; .) | "long" (. val = "System.Int64"; .)
| "object" (. val = "object"; .) | "object" (. val = "System.Object"; .)
| "sbyte" (. val = "sbyte"; .) | "sbyte" (. val = "System.SByte"; .)
| "short" (. val = "short"; .) | "short" (. val = "System.Int16"; .)
| "string" (. val = "string"; .) | "string" (. val = "System.String"; .)
| "uint" (. val = "uint"; .) | "uint" (. val = "System.UInt32"; .)
| "ulong" (. val = "ulong"; .) | "ulong" (. val = "System.UInt64"; .)
| "ushort" (. val = "ushort"; .) | "ushort" (. val = "System.UInt16"; .)
| "void" (. val = "void"; .) | "void" (. val = "System.Void"; .)
) )
MemberAccess<out pexpr, new TypeReferenceExpression(val) { StartLocation = t.Location, EndLocation = t.EndLocation } > MemberAccess<out pexpr, new TypeReferenceExpression(new TypeReference(val, true)) { StartLocation = t.Location, EndLocation = t.EndLocation } >
/*--- this access: */ /*--- this access: */
| "this" (. pexpr = new ThisReferenceExpression(); .) | "this" (. pexpr = new ThisReferenceExpression(); .)
@ -1882,7 +1882,7 @@ PrimaryExpr<out Expression pexpr>
| "typeof" "(" | "typeof" "("
( (
IF (NotVoidPointer()) "void" (. type = new TypeReference("void"); .) IF (NotVoidPointer()) "void" (. type = new TypeReference("System.Void", true); .)
| TypeWithRestriction<out type, true, true> | TypeWithRestriction<out type, true, true>
) )
")" (. pexpr = new TypeOfExpression(type); .) ")" (. pexpr = new TypeOfExpression(type); .)
@ -2281,7 +2281,7 @@ NullableQuestionMark<ref TypeReference typeRef>
"?" "?"
(. (.
if (typeRef != null) typeArguments.Add(typeRef); if (typeRef != null) typeArguments.Add(typeRef);
typeRef = new TypeReference("System.Nullable", typeArguments); typeRef = new TypeReference("System.Nullable", typeArguments) { IsKeyword = true };
.) .)
. .

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

@ -755,7 +755,7 @@ newType);
#line 526 "VBNET.ATG" #line 526 "VBNET.ATG"
m.Check(Modifiers.VBDelegates); m.Check(Modifiers.VBDelegates);
DelegateDeclaration delegateDeclr = new DelegateDeclaration(m.Modifier, attributes); DelegateDeclaration delegateDeclr = new DelegateDeclaration(m.Modifier, attributes);
delegateDeclr.ReturnType = new TypeReference("", "System.Void"); delegateDeclr.ReturnType = new TypeReference("System.Void", true);
delegateDeclr.StartLocation = m.GetDeclarationLocation(t.Location); delegateDeclr.StartLocation = m.GetDeclarationLocation(t.Location);
List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>(); List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>();
@ -1151,14 +1151,14 @@ out nestedTypeRef, canBeUnbound);
lexer.NextToken(); lexer.NextToken();
#line 2448 "VBNET.ATG" #line 2448 "VBNET.ATG"
typeref = new TypeReference("System.Object"); typeref = new TypeReference("System.Object", true);
if (la.kind == 21) { if (la.kind == 21) {
lexer.NextToken(); lexer.NextToken();
#line 2452 "VBNET.ATG" #line 2452 "VBNET.ATG"
List<TypeReference> typeArguments = new List<TypeReference>(1); List<TypeReference> typeArguments = new List<TypeReference>(1);
if (typeref != null) typeArguments.Add(typeref); if (typeref != null) typeArguments.Add(typeref);
typeref = new TypeReference("System.Nullable", typeArguments); typeref = new TypeReference("System.Nullable", typeArguments) { IsKeyword = true };
} }
} else if (StartOf(11)) { } else if (StartOf(11)) {
@ -1167,14 +1167,14 @@ out nestedTypeRef, canBeUnbound);
out name); out name);
#line 2458 "VBNET.ATG" #line 2458 "VBNET.ATG"
typeref = new TypeReference(name); typeref = new TypeReference(name, true);
if (la.kind == 21) { if (la.kind == 21) {
lexer.NextToken(); lexer.NextToken();
#line 2462 "VBNET.ATG" #line 2462 "VBNET.ATG"
List<TypeReference> typeArguments = new List<TypeReference>(1); List<TypeReference> typeArguments = new List<TypeReference>(1);
if (typeref != null) typeArguments.Add(typeref); if (typeref != null) typeArguments.Add(typeref);
typeref = new TypeReference("System.Nullable", typeArguments); typeref = new TypeReference("System.Nullable", typeArguments) { IsKeyword = true };
} }
} else SynErr(236); } else SynErr(236);
@ -1501,7 +1501,7 @@ IsMustOverride(m)) {
methodDeclaration = new MethodDeclaration { methodDeclaration = new MethodDeclaration {
Name = name, Modifier = m.Modifier, Parameters = p, Attributes = attributes, Name = name, Modifier = m.Modifier, Parameters = p, Attributes = attributes,
StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endLocation, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endLocation,
TypeReference = new TypeReference("", "System.Void"), TypeReference = new TypeReference("System.Void", true),
Templates = templates, Templates = templates,
HandlesClause = handlesClause, HandlesClause = handlesClause,
InterfaceImplementations = implementsClause InterfaceImplementations = implementsClause
@ -1515,7 +1515,7 @@ IsMustOverride(m)) {
methodDeclaration = new MethodDeclaration { methodDeclaration = new MethodDeclaration {
Name = name, Modifier = m.Modifier, Parameters = p, Attributes = attributes, Name = name, Modifier = m.Modifier, Parameters = p, Attributes = attributes,
StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endLocation, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endLocation,
TypeReference = new TypeReference("", "System.Void"), TypeReference = new TypeReference("System.Void", true),
Templates = templates, Templates = templates,
HandlesClause = handlesClause, HandlesClause = handlesClause,
InterfaceImplementations = implementsClause InterfaceImplementations = implementsClause
@ -1635,7 +1635,7 @@ out type);
#line 896 "VBNET.ATG" #line 896 "VBNET.ATG"
if(type == null) { if(type == null) {
type = new TypeReference("System.Object"); type = new TypeReference("System.Object", true);
} }
if (la.kind == 121 || la.kind == 123) { if (la.kind == 121 || la.kind == 123) {
@ -1952,7 +1952,7 @@ out type);
#line 1073 "VBNET.ATG" #line 1073 "VBNET.ATG"
if(type == null) { if(type == null) {
type = new TypeReference("System.Object"); type = new TypeReference("System.Object", true);
} }
if (la.kind == 123) { if (la.kind == 123) {
@ -2335,7 +2335,7 @@ p);
Modifier = mod.Modifier, Modifier = mod.Modifier,
Parameters = p, Parameters = p,
Attributes = attributes, Attributes = attributes,
TypeReference = new TypeReference("", "System.Void"), TypeReference = new TypeReference("System.Void", true),
StartLocation = startLocation, StartLocation = startLocation,
EndLocation = t.EndLocation, EndLocation = t.EndLocation,
Templates = templates Templates = templates
@ -2379,7 +2379,7 @@ out type);
#line 699 "VBNET.ATG" #line 699 "VBNET.ATG"
if(type == null) { if(type == null) {
type = new TypeReference("System.Object"); type = new TypeReference("System.Object", true);
} }
MethodDeclaration md = new MethodDeclaration { MethodDeclaration md = new MethodDeclaration {
Name = name, Modifier = mod.Modifier, Name = name, Modifier = mod.Modifier,
@ -2424,7 +2424,7 @@ out type);
#line 726 "VBNET.ATG" #line 726 "VBNET.ATG"
if(type == null) { if(type == null) {
type = new TypeReference("System.Object"); type = new TypeReference("System.Object", true);
} }
EndOfStmt(); EndOfStmt();
@ -3874,7 +3874,7 @@ out val);
lexer.NextToken(); lexer.NextToken();
#line 1678 "VBNET.ATG" #line 1678 "VBNET.ATG"
val = "Object"; val = "System.Object";
} else SynErr(257); } else SynErr(257);
Expect(16); Expect(16);
@ -3883,7 +3883,7 @@ out val);
Identifier(); Identifier();
#line 1679 "VBNET.ATG" #line 1679 "VBNET.ATG"
pexpr = new MemberReferenceExpression(new TypeReferenceExpression(val), t.val); pexpr = new MemberReferenceExpression(new TypeReferenceExpression(new TypeReference(val, true)), t.val);
break; break;
} }
case 139: { case 139: {
@ -4099,105 +4099,105 @@ out string type) {
lexer.NextToken(); lexer.NextToken();
#line 3363 "VBNET.ATG" #line 3363 "VBNET.ATG"
type = "Boolean"; type = "System.Boolean";
break; break;
} }
case 86: { case 86: {
lexer.NextToken(); lexer.NextToken();
#line 3364 "VBNET.ATG" #line 3364 "VBNET.ATG"
type = "Date"; type = "System.DateTime";
break; break;
} }
case 69: { case 69: {
lexer.NextToken(); lexer.NextToken();
#line 3365 "VBNET.ATG" #line 3365 "VBNET.ATG"
type = "Char"; type = "System.Char";
break; break;
} }
case 193: { case 193: {
lexer.NextToken(); lexer.NextToken();
#line 3366 "VBNET.ATG" #line 3366 "VBNET.ATG"
type = "String"; type = "System.String";
break; break;
} }
case 87: { case 87: {
lexer.NextToken(); lexer.NextToken();
#line 3367 "VBNET.ATG" #line 3367 "VBNET.ATG"
type = "Decimal"; type = "System.Decimal";
break; break;
} }
case 58: { case 58: {
lexer.NextToken(); lexer.NextToken();
#line 3368 "VBNET.ATG" #line 3368 "VBNET.ATG"
type = "Byte"; type = "System.Byte";
break; break;
} }
case 186: { case 186: {
lexer.NextToken(); lexer.NextToken();
#line 3369 "VBNET.ATG" #line 3369 "VBNET.ATG"
type = "Short"; type = "System.Int16";
break; break;
} }
case 128: { case 128: {
lexer.NextToken(); lexer.NextToken();
#line 3370 "VBNET.ATG" #line 3370 "VBNET.ATG"
type = "Integer"; type = "System.Int32";
break; break;
} }
case 137: { case 137: {
lexer.NextToken(); lexer.NextToken();
#line 3371 "VBNET.ATG" #line 3371 "VBNET.ATG"
type = "Long"; type = "System.Int64";
break; break;
} }
case 187: { case 187: {
lexer.NextToken(); lexer.NextToken();
#line 3372 "VBNET.ATG" #line 3372 "VBNET.ATG"
type = "Single"; type = "System.Single";
break; break;
} }
case 96: { case 96: {
lexer.NextToken(); lexer.NextToken();
#line 3373 "VBNET.ATG" #line 3373 "VBNET.ATG"
type = "Double"; type = "System.Double";
break; break;
} }
case 206: { case 206: {
lexer.NextToken(); lexer.NextToken();
#line 3374 "VBNET.ATG" #line 3374 "VBNET.ATG"
type = "UInteger"; type = "System.UInt32";
break; break;
} }
case 207: { case 207: {
lexer.NextToken(); lexer.NextToken();
#line 3375 "VBNET.ATG" #line 3375 "VBNET.ATG"
type = "ULong"; type = "System.UInt64";
break; break;
} }
case 210: { case 210: {
lexer.NextToken(); lexer.NextToken();
#line 3376 "VBNET.ATG" #line 3376 "VBNET.ATG"
type = "UShort"; type = "System.UInt16";
break; break;
} }
case 181: { case 181: {
lexer.NextToken(); lexer.NextToken();
#line 3377 "VBNET.ATG" #line 3377 "VBNET.ATG"
type = "SByte"; type = "System.SByte";
break; break;
} }
default: SynErr(261); break; default: SynErr(261); break;
@ -4216,112 +4216,112 @@ out TypeReference type) {
lexer.NextToken(); lexer.NextToken();
#line 1765 "VBNET.ATG" #line 1765 "VBNET.ATG"
type = new TypeReference("System.Boolean"); type = new TypeReference("System.Boolean", true);
break; break;
} }
case 64: { case 64: {
lexer.NextToken(); lexer.NextToken();
#line 1766 "VBNET.ATG" #line 1766 "VBNET.ATG"
type = new TypeReference("System.Byte"); type = new TypeReference("System.Byte", true);
break; break;
} }
case 77: { case 77: {
lexer.NextToken(); lexer.NextToken();
#line 1767 "VBNET.ATG" #line 1767 "VBNET.ATG"
type = new TypeReference("System.SByte"); type = new TypeReference("System.SByte", true);
break; break;
} }
case 65: { case 65: {
lexer.NextToken(); lexer.NextToken();
#line 1768 "VBNET.ATG" #line 1768 "VBNET.ATG"
type = new TypeReference("System.Char"); type = new TypeReference("System.Char", true);
break; break;
} }
case 66: { case 66: {
lexer.NextToken(); lexer.NextToken();
#line 1769 "VBNET.ATG" #line 1769 "VBNET.ATG"
type = new TypeReference("System.DateTime"); type = new TypeReference("System.DateTime", true);
break; break;
} }
case 68: { case 68: {
lexer.NextToken(); lexer.NextToken();
#line 1770 "VBNET.ATG" #line 1770 "VBNET.ATG"
type = new TypeReference("System.Decimal"); type = new TypeReference("System.Decimal", true);
break; break;
} }
case 67: { case 67: {
lexer.NextToken(); lexer.NextToken();
#line 1771 "VBNET.ATG" #line 1771 "VBNET.ATG"
type = new TypeReference("System.Double"); type = new TypeReference("System.Double", true);
break; break;
} }
case 78: { case 78: {
lexer.NextToken(); lexer.NextToken();
#line 1772 "VBNET.ATG" #line 1772 "VBNET.ATG"
type = new TypeReference("System.Int16"); type = new TypeReference("System.Int16", true);
break; break;
} }
case 70: { case 70: {
lexer.NextToken(); lexer.NextToken();
#line 1773 "VBNET.ATG" #line 1773 "VBNET.ATG"
type = new TypeReference("System.Int32"); type = new TypeReference("System.Int32", true);
break; break;
} }
case 72: { case 72: {
lexer.NextToken(); lexer.NextToken();
#line 1774 "VBNET.ATG" #line 1774 "VBNET.ATG"
type = new TypeReference("System.Int64"); type = new TypeReference("System.Int64", true);
break; break;
} }
case 84: { case 84: {
lexer.NextToken(); lexer.NextToken();
#line 1775 "VBNET.ATG" #line 1775 "VBNET.ATG"
type = new TypeReference("System.UInt16"); type = new TypeReference("System.UInt16", true);
break; break;
} }
case 82: { case 82: {
lexer.NextToken(); lexer.NextToken();
#line 1776 "VBNET.ATG" #line 1776 "VBNET.ATG"
type = new TypeReference("System.UInt32"); type = new TypeReference("System.UInt32", true);
break; break;
} }
case 83: { case 83: {
lexer.NextToken(); lexer.NextToken();
#line 1777 "VBNET.ATG" #line 1777 "VBNET.ATG"
type = new TypeReference("System.UInt64"); type = new TypeReference("System.UInt64", true);
break; break;
} }
case 73: { case 73: {
lexer.NextToken(); lexer.NextToken();
#line 1778 "VBNET.ATG" #line 1778 "VBNET.ATG"
type = new TypeReference("System.Object"); type = new TypeReference("System.Object", true);
break; break;
} }
case 79: { case 79: {
lexer.NextToken(); lexer.NextToken();
#line 1779 "VBNET.ATG" #line 1779 "VBNET.ATG"
type = new TypeReference("System.Single"); type = new TypeReference("System.Single", true);
break; break;
} }
case 80: { case 80: {
lexer.NextToken(); lexer.NextToken();
#line 1780 "VBNET.ATG" #line 1780 "VBNET.ATG"
type = new TypeReference("System.String"); type = new TypeReference("System.String", true);
break; break;
} }
default: SynErr(262); break; default: SynErr(262); break;

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

@ -525,7 +525,7 @@ NonModuleDeclaration<ModifierList m, List<AttributeSection> attributes>
(. (.
m.Check(Modifiers.VBDelegates); m.Check(Modifiers.VBDelegates);
DelegateDeclaration delegateDeclr = new DelegateDeclaration(m.Modifier, attributes); DelegateDeclaration delegateDeclr = new DelegateDeclaration(m.Modifier, attributes);
delegateDeclr.ReturnType = new TypeReference("", "System.Void"); delegateDeclr.ReturnType = new TypeReference("System.Void", true);
delegateDeclr.StartLocation = m.GetDeclarationLocation(t.Location); delegateDeclr.StartLocation = m.GetDeclarationLocation(t.Location);
List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>(); List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>();
.) .)
@ -678,7 +678,7 @@ InterfaceMemberDecl
Modifier = mod.Modifier, Modifier = mod.Modifier,
Parameters = p, Parameters = p,
Attributes = attributes, Attributes = attributes,
TypeReference = new TypeReference("", "System.Void"), TypeReference = new TypeReference("System.Void", true),
StartLocation = startLocation, StartLocation = startLocation,
EndLocation = t.EndLocation, EndLocation = t.EndLocation,
Templates = templates Templates = templates
@ -697,7 +697,7 @@ InterfaceMemberDecl
[ "As" { AttributeSection<out returnTypeAttributeSection> } TypeName<out type> ] [ "As" { AttributeSection<out returnTypeAttributeSection> } TypeName<out type> ]
(. (.
if(type == null) { if(type == null) {
type = new TypeReference("System.Object"); type = new TypeReference("System.Object", true);
} }
MethodDeclaration md = new MethodDeclaration { MethodDeclaration md = new MethodDeclaration {
Name = name, Modifier = mod.Modifier, Name = name, Modifier = mod.Modifier,
@ -724,7 +724,7 @@ InterfaceMemberDecl
[ "As" TypeName<out type> ] [ "As" TypeName<out type> ]
(. (.
if(type == null) { if(type == null) {
type = new TypeReference("System.Object"); type = new TypeReference("System.Object", true);
} }
.) .)
EndOfStmt EndOfStmt
@ -817,7 +817,7 @@ StructureMemberDecl<ModifierList m, List<AttributeSection> attributes>
methodDeclaration = new MethodDeclaration { methodDeclaration = new MethodDeclaration {
Name = name, Modifier = m.Modifier, Parameters = p, Attributes = attributes, Name = name, Modifier = m.Modifier, Parameters = p, Attributes = attributes,
StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endLocation, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endLocation,
TypeReference = new TypeReference("", "System.Void"), TypeReference = new TypeReference("System.Void", true),
Templates = templates, Templates = templates,
HandlesClause = handlesClause, HandlesClause = handlesClause,
InterfaceImplementations = implementsClause InterfaceImplementations = implementsClause
@ -830,7 +830,7 @@ StructureMemberDecl<ModifierList m, List<AttributeSection> attributes>
methodDeclaration = new MethodDeclaration { methodDeclaration = new MethodDeclaration {
Name = name, Modifier = m.Modifier, Parameters = p, Attributes = attributes, Name = name, Modifier = m.Modifier, Parameters = p, Attributes = attributes,
StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endLocation, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endLocation,
TypeReference = new TypeReference("", "System.Void"), TypeReference = new TypeReference("System.Void", true),
Templates = templates, Templates = templates,
HandlesClause = handlesClause, HandlesClause = handlesClause,
InterfaceImplementations = implementsClause InterfaceImplementations = implementsClause
@ -894,7 +894,7 @@ StructureMemberDecl<ModifierList m, List<AttributeSection> attributes>
["As" { AttributeSection<out returnTypeAttributeSection> } TypeName<out type> ] ["As" { AttributeSection<out returnTypeAttributeSection> } TypeName<out type> ]
(. (.
if(type == null) { if(type == null) {
type = new TypeReference("System.Object"); type = new TypeReference("System.Object", true);
} }
.) .)
[ [
@ -1071,7 +1071,7 @@ StructureMemberDecl<ModifierList m, List<AttributeSection> attributes>
[ "As" TypeName<out type> ] [ "As" TypeName<out type> ]
(. (.
if(type == null) { if(type == null) {
type = new TypeReference("System.Object"); type = new TypeReference("System.Object", true);
} }
.) .)
[ ImplementsClause<out implementsClause> ] [ ImplementsClause<out implementsClause> ]
@ -1675,8 +1675,8 @@ SimpleNonInvocationExpression<out Expression pexpr>
"(" "Of" TypeArgumentList<((IdentifierExpression)pexpr).TypeArguments> ")" "(" "Of" TypeArgumentList<((IdentifierExpression)pexpr).TypeArguments> ")"
] ]
| (. string val = String.Empty; .) | (. string val = String.Empty; .)
( PrimitiveTypeName<out val> | "Object" (. val = "Object"; .) ) ( PrimitiveTypeName<out val> | "Object" (. val = "System.Object"; .) )
"." (. t.val = ""; .) Identifier (. pexpr = new MemberReferenceExpression(new TypeReferenceExpression(val), t.val); .) "." (. t.val = ""; .) Identifier (. pexpr = new MemberReferenceExpression(new TypeReferenceExpression(new TypeReference(val, true)), t.val); .)
| "Me" (. pexpr = new ThisReferenceExpression(); .) | "Me" (. pexpr = new ThisReferenceExpression(); .)
| (. Expression retExpr = null; .) | (. Expression retExpr = null; .)
( "MyBase" (. retExpr = new BaseReferenceExpression(); .) ( "MyBase" (. retExpr = new BaseReferenceExpression(); .)
@ -1762,22 +1762,22 @@ CastTarget<out TypeReference type>
(. (.
type = null; type = null;
.) = .) =
"CBool" (. type = new TypeReference("System.Boolean"); .) "CBool" (. type = new TypeReference("System.Boolean", true); .)
| "CByte" (. type = new TypeReference("System.Byte"); .) | "CByte" (. type = new TypeReference("System.Byte", true); .)
| "CSByte" (. type = new TypeReference("System.SByte"); .) | "CSByte" (. type = new TypeReference("System.SByte", true); .)
| "CChar" (. type = new TypeReference("System.Char"); .) | "CChar" (. type = new TypeReference("System.Char", true); .)
| "CDate" (. type = new TypeReference("System.DateTime"); .) | "CDate" (. type = new TypeReference("System.DateTime", true); .)
| "CDec" (. type = new TypeReference("System.Decimal"); .) | "CDec" (. type = new TypeReference("System.Decimal", true); .)
| "CDbl" (. type = new TypeReference("System.Double"); .) | "CDbl" (. type = new TypeReference("System.Double", true); .)
| "CShort" (. type = new TypeReference("System.Int16"); .) | "CShort" (. type = new TypeReference("System.Int16", true); .)
| "CInt" (. type = new TypeReference("System.Int32"); .) | "CInt" (. type = new TypeReference("System.Int32", true); .)
| "CLng" (. type = new TypeReference("System.Int64"); .) | "CLng" (. type = new TypeReference("System.Int64", true); .)
| "CUShort" (. type = new TypeReference("System.UInt16"); .) | "CUShort" (. type = new TypeReference("System.UInt16", true); .)
| "CUInt" (. type = new TypeReference("System.UInt32"); .) | "CUInt" (. type = new TypeReference("System.UInt32", true); .)
| "CULng" (. type = new TypeReference("System.UInt64"); .) | "CULng" (. type = new TypeReference("System.UInt64", true); .)
| "CObj" (. type = new TypeReference("System.Object"); .) | "CObj" (. type = new TypeReference("System.Object", true); .)
| "CSng" (. type = new TypeReference("System.Single"); .) | "CSng" (. type = new TypeReference("System.Single", true); .)
| "CStr" (. type = new TypeReference("System.String"); .) | "CStr" (. type = new TypeReference("System.String", true); .)
. .
DisjunctionExpr<out Expression outExpr> DisjunctionExpr<out Expression outExpr>
@ -2445,23 +2445,23 @@ NonArrayTypeName<out TypeReference typeref, bool canBeUnbound>
(. typeref = new InnerClassTypeReference(typeref, nestedTypeRef.Type, nestedTypeRef.GenericTypes); .) (. typeref = new InnerClassTypeReference(typeref, nestedTypeRef.Type, nestedTypeRef.GenericTypes); .)
} }
) )
| "Object" (. typeref = new TypeReference("System.Object"); .) | "Object" (. typeref = new TypeReference("System.Object", true); .)
[ [
"?" "?"
(. (.
List<TypeReference> typeArguments = new List<TypeReference>(1); List<TypeReference> typeArguments = new List<TypeReference>(1);
if (typeref != null) typeArguments.Add(typeref); if (typeref != null) typeArguments.Add(typeref);
typeref = new TypeReference("System.Nullable", typeArguments); typeref = new TypeReference("System.Nullable", typeArguments) { IsKeyword = true };
.) .)
] ]
| PrimitiveTypeName<out name> (. typeref = new TypeReference(name); .) | PrimitiveTypeName<out name> (. typeref = new TypeReference(name, true); .)
[ [
"?" "?"
(. (.
List<TypeReference> typeArguments = new List<TypeReference>(1); List<TypeReference> typeArguments = new List<TypeReference>(1);
if (typeref != null) typeArguments.Add(typeref); if (typeref != null) typeArguments.Add(typeref);
typeref = new TypeReference("System.Nullable", typeArguments); typeref = new TypeReference("System.Nullable", typeArguments) { IsKeyword = true };
.) .)
] ]
. .
@ -3360,21 +3360,21 @@ IdentifierOrKeyword<out string name>
/* 7.3 */ /* 7.3 */
PrimitiveTypeName<out string type> PrimitiveTypeName<out string type>
(. type = String.Empty; .) = (. type = String.Empty; .) =
"Boolean" (. type = "Boolean"; .) "Boolean" (. type = "System.Boolean"; .)
| "Date" (. type = "Date"; .) | "Date" (. type = "System.DateTime"; .)
| "Char" (. type = "Char"; .) | "Char" (. type = "System.Char"; .)
| "String" (. type = "String"; .) | "String" (. type = "System.String"; .)
| "Decimal" (. type = "Decimal"; .) | "Decimal" (. type = "System.Decimal"; .)
| "Byte" (. type = "Byte"; .) | "Byte" (. type = "System.Byte"; .)
| "Short" (. type = "Short"; .) | "Short" (. type = "System.Int16"; .)
| "Integer" (. type = "Integer"; .) | "Integer" (. type = "System.Int32"; .)
| "Long" (. type = "Long"; .) | "Long" (. type = "System.Int64"; .)
| "Single" (. type = "Single"; .) | "Single" (. type = "System.Single"; .)
| "Double" (. type = "Double"; .) | "Double" (. type = "System.Double"; .)
| "UInteger" (. type = "UInteger"; .) | "UInteger" (. type = "System.UInt32"; .)
| "ULong" (. type = "ULong"; .) | "ULong" (. type = "System.UInt64"; .)
| "UShort" (. type = "UShort"; .) | "UShort" (. type = "System.UInt16"; .)
| "SByte" (. type = "SByte"; .) | "SByte" (. type = "System.SByte"; .)
. .
ParameterModifier<ParamModifierList m> ParameterModifier<ParamModifierList m>

60
src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs

@ -24,7 +24,6 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
Errors errors = new Errors(); Errors errors = new Errors();
CSharpOutputFormatter outputFormatter; CSharpOutputFormatter outputFormatter;
PrettyPrintOptions prettyPrintOptions = new PrettyPrintOptions(); PrettyPrintOptions prettyPrintOptions = new PrettyPrintOptions();
bool printFullSystemType;
public string Text { public string Text {
get { get {
@ -96,7 +95,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
} }
/// <summary> /// <summary>
/// Converts type name to primitive type name. Returns null if typeString is not /// Converts type name to primitive type name. Returns typeString if typeString is not
/// a primitive type. /// a primitive type.
/// </summary> /// </summary>
static string ConvertTypeString(string typeString) static string ConvertTypeString(string typeString)
@ -160,28 +159,25 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
if (typeReference.IsGlobal) { if (typeReference.IsGlobal) {
outputFormatter.PrintText("global::"); outputFormatter.PrintText("global::");
} }
if (typeReference.Type == null || typeReference.Type.Length == 0) { bool printGenerics = true;
outputFormatter.PrintText("void"); if (typeReference.IsKeyword) {
} else if (typeReference.SystemType == "System.Nullable" && typeReference.GenericTypes != null if (typeReference.Type == "System.Nullable"
&& typeReference.GenericTypes.Count == 1 && !typeReference.IsGlobal) && typeReference.GenericTypes != null
{ && typeReference.GenericTypes.Count == 1)
TrackVisit(typeReference.GenericTypes[0], null); {
outputFormatter.PrintText("?"); TrackVisit(typeReference.GenericTypes[0], null);
} else { outputFormatter.PrintText("?");
if (typeReference.SystemType.Length > 0) { printGenerics = false;
if (printFullSystemType || typeReference.IsGlobal) {
outputFormatter.PrintIdentifier(typeReference.SystemType);
} else {
outputFormatter.PrintText(ConvertTypeString(typeReference.SystemType));
}
} else { } else {
outputFormatter.PrintText(typeReference.Type); outputFormatter.PrintText(ConvertTypeString(typeReference.Type));
}
if (typeReference.GenericTypes != null && typeReference.GenericTypes.Count > 0) {
outputFormatter.PrintToken(Tokens.LessThan);
AppendCommaSeparatedList(typeReference.GenericTypes);
outputFormatter.PrintToken(Tokens.GreaterThan);
} }
} else {
outputFormatter.PrintIdentifier(typeReference.Type);
}
if (printGenerics && typeReference.GenericTypes != null && typeReference.GenericTypes.Count > 0) {
outputFormatter.PrintToken(Tokens.LessThan);
AppendCommaSeparatedList(typeReference.GenericTypes);
outputFormatter.PrintToken(Tokens.GreaterThan);
} }
for (int i = 0; i < typeReference.PointerNestingLevel; ++i) { for (int i = 0; i < typeReference.PointerNestingLevel; ++i) {
outputFormatter.PrintToken(Tokens.Times); outputFormatter.PrintToken(Tokens.Times);
@ -286,9 +282,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.Space(); outputFormatter.Space();
outputFormatter.PrintToken(Tokens.Assign); outputFormatter.PrintToken(Tokens.Assign);
outputFormatter.Space(); outputFormatter.Space();
printFullSystemType = true;
TrackVisit(@using.Alias, data); TrackVisit(@using.Alias, data);
printFullSystemType = false;
} }
outputFormatter.PrintToken(Tokens.Semicolon); outputFormatter.PrintToken(Tokens.Semicolon);
@ -1095,7 +1089,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
} }
// all variables have the same type // all variables have the same type
OutputModifier(localVariableDeclaration.Modifier); OutputModifier(localVariableDeclaration.Modifier);
TrackVisit(type ?? new TypeReference("object"), data); TrackVisit(type ?? new TypeReference("System.Object", true), data);
outputFormatter.Space(); outputFormatter.Space();
AppendCommaSeparatedList(localVariableDeclaration.Variables); AppendCommaSeparatedList(localVariableDeclaration.Variables);
outputFormatter.PrintToken(Tokens.Semicolon); outputFormatter.PrintToken(Tokens.Semicolon);
@ -1111,7 +1105,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.Indent(); outputFormatter.Indent();
} }
OutputModifier(localVariableDeclaration.Modifier); OutputModifier(localVariableDeclaration.Modifier);
TrackVisit(localVariableDeclaration.GetTypeForVariable(i) ?? new TypeReference("object"), data); TrackVisit(localVariableDeclaration.GetTypeForVariable(i) ?? new TypeReference("System.Object", true), data);
outputFormatter.Space(); outputFormatter.Space();
TrackVisit(v, data); TrackVisit(v, data);
outputFormatter.PrintToken(Tokens.Semicolon); outputFormatter.PrintToken(Tokens.Semicolon);
@ -2318,9 +2312,19 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
public override object TrackedVisitPointerReferenceExpression(PointerReferenceExpression pointerReferenceExpression, object data) public override object TrackedVisitPointerReferenceExpression(PointerReferenceExpression pointerReferenceExpression, object data)
{ {
TrackVisit(pointerReferenceExpression.TargetObject, data); Expression target = pointerReferenceExpression.TargetObject;
if (target is BinaryOperatorExpression || target is CastExpression) {
outputFormatter.PrintToken(Tokens.OpenParenthesis);
}
TrackVisit(target, data);
if (target is BinaryOperatorExpression || target is CastExpression) {
outputFormatter.PrintToken(Tokens.CloseParenthesis);
}
outputFormatter.PrintToken(Tokens.Pointer); outputFormatter.PrintToken(Tokens.Pointer);
outputFormatter.PrintIdentifier(pointerReferenceExpression.Identifier); outputFormatter.PrintIdentifier(pointerReferenceExpression.MemberName);
PrintTypeArgumentList(pointerReferenceExpression.TypeArguments);
return null; return null;
} }

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

@ -25,7 +25,6 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
VBNetOutputFormatter outputFormatter; VBNetOutputFormatter outputFormatter;
VBNetPrettyPrintOptions prettyPrintOptions = new VBNetPrettyPrintOptions(); VBNetPrettyPrintOptions prettyPrintOptions = new VBNetPrettyPrintOptions();
TypeDeclaration currentType; TypeDeclaration currentType;
bool printFullSystemType;
Stack<int> exitTokenStack = new Stack<int>(); Stack<int> exitTokenStack = new Stack<int>();
@ -103,14 +102,16 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
} }
/// <summary> /// <summary>
/// Converts type name to primitive type name. Returns null if typeString is not /// Converts type name to primitive type name. Returns typeString if typeString is not
/// a primitive type. /// a primitive type.
/// </summary> /// </summary>
static string ConvertTypeString(string typeString) static string ConvertTypeString(string typeString)
{ {
string primitiveType; string primitiveType;
TypeReference.PrimitiveTypesVBReverse.TryGetValue(typeString, out primitiveType); if (TypeReference.PrimitiveTypesVBReverse.TryGetValue(typeString, out primitiveType))
return primitiveType; return primitiveType;
else
return typeString;
} }
public override object TrackedVisitTypeReference(TypeReference typeReference, object data) public override object TrackedVisitTypeReference(TypeReference typeReference, object data)
@ -136,19 +137,13 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.PrintToken(Tokens.Global); outputFormatter.PrintToken(Tokens.Global);
outputFormatter.PrintToken(Tokens.Dot); outputFormatter.PrintToken(Tokens.Dot);
} }
if (typeReference.Type == null || typeReference.Type.Length ==0) { bool printGenerics = true;
outputFormatter.PrintText("Void"); if (typeReference.IsKeyword) {
} else if (printFullSystemType || typeReference.IsGlobal) { outputFormatter.PrintText(ConvertTypeString(typeReference.Type));
outputFormatter.PrintIdentifier(typeReference.SystemType);
} else { } else {
string shortTypeName = ConvertTypeString(typeReference.SystemType); outputFormatter.PrintIdentifier(typeReference.Type);
if (shortTypeName != null) {
outputFormatter.PrintText(shortTypeName);
} else {
outputFormatter.PrintIdentifier(typeReference.Type);
}
} }
if (typeReference.GenericTypes != null && typeReference.GenericTypes.Count > 0) { if (printGenerics && typeReference.GenericTypes != null && typeReference.GenericTypes.Count > 0) {
outputFormatter.PrintToken(Tokens.OpenParenthesis); outputFormatter.PrintToken(Tokens.OpenParenthesis);
outputFormatter.PrintToken(Tokens.Of); outputFormatter.PrintToken(Tokens.Of);
outputFormatter.Space(); outputFormatter.Space();
@ -256,9 +251,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.Space(); outputFormatter.Space();
outputFormatter.PrintToken(Tokens.Assign); outputFormatter.PrintToken(Tokens.Assign);
outputFormatter.Space(); outputFormatter.Space();
printFullSystemType = true;
TrackedVisit(((Using)usingDeclaration.Usings[i]).Alias, data); TrackedVisit(((Using)usingDeclaration.Usings[i]).Alias, data);
printFullSystemType = false;
} }
if (i + 1 < usingDeclaration.Usings.Count) { if (i + 1 < usingDeclaration.Usings.Count) {
outputFormatter.PrintToken(Tokens.Comma); outputFormatter.PrintToken(Tokens.Comma);
@ -430,7 +423,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
outputFormatter.PrintToken(Tokens.Delegate); outputFormatter.PrintToken(Tokens.Delegate);
outputFormatter.Space(); outputFormatter.Space();
bool isFunction = (delegateDeclaration.ReturnType.Type != "void"); bool isFunction = (delegateDeclaration.ReturnType.Type != "System.Void");
if (isFunction) { if (isFunction) {
outputFormatter.PrintToken(Tokens.Function); outputFormatter.PrintToken(Tokens.Function);
outputFormatter.Space(); outputFormatter.Space();
@ -832,7 +825,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
OutputModifier(methodDeclaration.Modifier); OutputModifier(methodDeclaration.Modifier);
bool isSub = methodDeclaration.TypeReference.IsNull || bool isSub = methodDeclaration.TypeReference.IsNull ||
methodDeclaration.TypeReference.SystemType == "System.Void"; methodDeclaration.TypeReference.Type == "System.Void";
if (isSub) { if (isSub) {
outputFormatter.PrintToken(Tokens.Sub); outputFormatter.PrintToken(Tokens.Sub);
@ -1209,7 +1202,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
break; break;
} }
bool isVoid = declareDeclaration.TypeReference.IsNull || declareDeclaration.TypeReference.SystemType == "System.Void"; bool isVoid = declareDeclaration.TypeReference.IsNull || declareDeclaration.TypeReference.Type == "System.Void";
if (isVoid) { if (isVoid) {
outputFormatter.PrintToken(Tokens.Sub); outputFormatter.PrintToken(Tokens.Sub);
} else { } else {
@ -2489,7 +2482,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
if (castExpression.CastType == CastType.Cast || castExpression.CastTo.IsArrayType) { if (castExpression.CastType == CastType.Cast || castExpression.CastTo.IsArrayType) {
return PrintCast(Tokens.DirectCast, castExpression); return PrintCast(Tokens.DirectCast, castExpression);
} }
switch (castExpression.CastTo.SystemType) { switch (castExpression.CastTo.Type) {
case "System.Boolean": case "System.Boolean":
outputFormatter.PrintToken(Tokens.CBool); outputFormatter.PrintToken(Tokens.CBool);
break; break;

2
src/Libraries/NRefactory/Project/Src/Visitors/CSharpConstructsConvertVisitor.cs

@ -221,7 +221,7 @@ namespace ICSharpCode.NRefactory.Visitors
// this code only supports primitive types, user-defined value types are handled by // this code only supports primitive types, user-defined value types are handled by
// the DOM-aware CSharpToVBNetConvertVisitor // the DOM-aware CSharpToVBNetConvertVisitor
string type; string type;
if (TypeReference.PrimitiveTypesCSharpReverse.TryGetValue(castExpression.CastTo.SystemType, out type)) { if (TypeReference.PrimitiveTypesCSharpReverse.TryGetValue(castExpression.CastTo.Type, out type)) {
if (type != "object" && type != "string") { if (type != "object" && type != "string") {
// type is value type // type is value type
castExpression.CastType = CastType.Conversion; castExpression.CastType = CastType.Conversion;

8
src/Libraries/NRefactory/Project/Src/Visitors/CodeDOMOutputVisitor.cs

@ -84,11 +84,11 @@ namespace ICSharpCode.NRefactory.Visitors
if (type == null) { if (type == null) {
throw new ArgumentNullException("type"); throw new ArgumentNullException("type");
} }
if (string.IsNullOrEmpty(type.SystemType)) { if (string.IsNullOrEmpty(type.Type)) {
throw new InvalidOperationException("empty type"); throw new InvalidOperationException("empty type");
} }
CodeTypeReference t = new CodeTypeReference(type.SystemType); CodeTypeReference t = new CodeTypeReference(type.Type);
foreach (TypeReference gt in type.GenericTypes) { foreach (TypeReference gt in type.GenericTypes) {
t.TypeArguments.Add(ConvType(gt)); t.TypeArguments.Add(ConvType(gt));
} }
@ -457,7 +457,7 @@ namespace ICSharpCode.NRefactory.Visitors
CodeVariableDeclarationStatement declStmt = null; CodeVariableDeclarationStatement declStmt = null;
for (int i = 0; i < localVariableDeclaration.Variables.Count; ++i) { for (int i = 0; i < localVariableDeclaration.Variables.Count; ++i) {
CodeTypeReference type = ConvType(localVariableDeclaration.GetTypeForVariable(i) ?? new TypeReference("object")); CodeTypeReference type = ConvType(localVariableDeclaration.GetTypeForVariable(i) ?? new TypeReference("System.Object", true));
VariableDeclaration var = (VariableDeclaration)localVariableDeclaration.Variables[i]; VariableDeclaration var = (VariableDeclaration)localVariableDeclaration.Variables[i];
if (!var.Initializer.IsNull) { if (!var.Initializer.IsNull) {
declStmt = new CodeVariableDeclarationStatement(type, declStmt = new CodeVariableDeclarationStatement(type,
@ -1654,7 +1654,7 @@ namespace ICSharpCode.NRefactory.Visitors
} }
return new CodeTypeReferenceExpression(type.ToString()); return new CodeTypeReferenceExpression(type.ToString());
} else if (fieldReferenceExpression.TargetObject is TypeReferenceExpression) { } else if (fieldReferenceExpression.TargetObject is TypeReferenceExpression) {
type.Insert(0, ((TypeReferenceExpression)fieldReferenceExpression.TargetObject).TypeReference.SystemType); type.Insert(0, ((TypeReferenceExpression)fieldReferenceExpression.TargetObject).TypeReference.Type);
return new CodeTypeReferenceExpression(type.ToString()); return new CodeTypeReferenceExpression(type.ToString());
} else { } else {
return null; return null;

4
src/Libraries/NRefactory/Project/Src/Visitors/ToCSharpConvertVisitor.cs

@ -53,7 +53,7 @@ namespace ICSharpCode.NRefactory.Visitors
DelegateDeclaration dd = new DelegateDeclaration(eventDeclaration.Modifier, null); DelegateDeclaration dd = new DelegateDeclaration(eventDeclaration.Modifier, null);
dd.Name = eventDeclaration.Name + "EventHandler"; dd.Name = eventDeclaration.Name + "EventHandler";
dd.Parameters = eventDeclaration.Parameters; dd.Parameters = eventDeclaration.Parameters;
dd.ReturnType = new TypeReference("System.Void"); dd.ReturnType = new TypeReference("System.Void", true);
dd.Parent = eventDeclaration.Parent; dd.Parent = eventDeclaration.Parent;
eventDeclaration.Parameters = null; eventDeclaration.Parameters = null;
InsertAfterSibling(eventDeclaration, dd); InsertAfterSibling(eventDeclaration, dd);
@ -88,7 +88,7 @@ namespace ICSharpCode.NRefactory.Visitors
foreach (ParameterDeclarationExpression decl in member.Parameters) { foreach (ParameterDeclarationExpression decl in member.Parameters) {
callExpression.Arguments.Add(new IdentifierExpression(decl.ParameterName)); callExpression.Arguments.Add(new IdentifierExpression(decl.ParameterName));
} }
if (member.TypeReference.SystemType == "System.Void") { if (member.TypeReference.Type == "System.Void") {
newMember.Body.AddChild(new ExpressionStatement(callExpression)); newMember.Body.AddChild(new ExpressionStatement(callExpression));
} else { } else {
newMember.Body.AddChild(new ReturnStatement(callExpression)); newMember.Body.AddChild(new ReturnStatement(callExpression));

6
src/Libraries/NRefactory/Project/Src/Visitors/VBNetConstructsConvertVisitor.cs

@ -148,7 +148,7 @@ namespace ICSharpCode.NRefactory.Visitors
method.Modifier |= Modifiers.Extern | Modifiers.Static; method.Modifier |= Modifiers.Extern | Modifiers.Static;
if (method.TypeReference.IsNull) { if (method.TypeReference.IsNull) {
method.TypeReference = new TypeReference("System.Void"); method.TypeReference = new TypeReference("System.Void", true);
} }
Attribute att = new Attribute("DllImport", null, null); Attribute att = new Attribute("DllImport", null, null);
@ -233,7 +233,7 @@ namespace ICSharpCode.NRefactory.Visitors
} }
} }
if (methodDeclaration.TypeReference.SystemType != "System.Void" && methodDeclaration.Body.Children.Count > 0) { if (methodDeclaration.TypeReference.Type != "System.Void" && methodDeclaration.Body.Children.Count > 0) {
if (IsAssignmentTo(methodDeclaration.Body.Children[methodDeclaration.Body.Children.Count - 1], methodDeclaration.Name)) if (IsAssignmentTo(methodDeclaration.Body.Children[methodDeclaration.Body.Children.Count - 1], methodDeclaration.Name))
{ {
ReturnStatement rs = new ReturnStatement(GetAssignmentFromStatement(methodDeclaration.Body.Children[methodDeclaration.Body.Children.Count - 1]).Right); ReturnStatement rs = new ReturnStatement(GetAssignmentFromStatement(methodDeclaration.Body.Children[methodDeclaration.Body.Children.Count - 1]).Right);
@ -465,7 +465,7 @@ namespace ICSharpCode.NRefactory.Visitors
List<Expression> arguments = new List<Expression>(); List<Expression> arguments = new List<Expression>();
arguments.Add(stringVariable); arguments.Add(stringVariable);
return new InvocationExpression( return new InvocationExpression(
new MemberReferenceExpression(new TypeReferenceExpression("System.String"), "IsNullOrEmpty"), new MemberReferenceExpression(new TypeReferenceExpression(new TypeReference("System.String", true)), "IsNullOrEmpty"),
arguments); arguments);
} }

4
src/Libraries/NRefactory/Test/Output/VBNet/CSharpToVBNetConverterTest.cs

@ -530,14 +530,14 @@ End Class
[Test] [Test]
public void CSharpLinefeedToVBString() public void CSharpLinefeedToVBString()
{ {
TestStatement(@"String Test = ""My Test\n"";", TestStatement(@"string Test = ""My Test\n"";",
@"Dim Test As String = ""My Test"" & vbLf"); @"Dim Test As String = ""My Test"" & vbLf");
} }
[Test] [Test]
public void CSharpTabToVBString() public void CSharpTabToVBString()
{ {
TestStatement(@"String Test = ""\t\a"";", TestStatement(@"string Test = ""\t\a"";",
@"Dim Test As String = vbTab & ChrW(7)"); @"Dim Test As String = vbTab & ChrW(7)");
} }
} }

7
src/Libraries/NRefactory/Test/Parser/Expressions/ArrayCreateExpressionTests.cs

@ -21,7 +21,8 @@ namespace ICSharpCode.NRefactory.Tests.Ast
public void CSharpArrayCreateExpressionTest1() public void CSharpArrayCreateExpressionTest1()
{ {
ArrayCreateExpression ace = ParseUtilCSharp.ParseExpression<ArrayCreateExpression>("new int[5]"); ArrayCreateExpression ace = ParseUtilCSharp.ParseExpression<ArrayCreateExpression>("new int[5]");
Assert.AreEqual("int", ace.CreateType.Type); Assert.AreEqual("System.Int32", ace.CreateType.Type);
Assert.IsTrue(ace.CreateType.IsKeyword);
Assert.AreEqual(1, ace.Arguments.Count); Assert.AreEqual(1, ace.Arguments.Count);
Assert.AreEqual(new int[] {0}, ace.CreateType.RankSpecifier); Assert.AreEqual(new int[] {0}, ace.CreateType.RankSpecifier);
} }
@ -43,7 +44,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
{ {
ArrayCreateExpression ace = ParseUtilVBNet.ParseExpression<ArrayCreateExpression>("new Integer() {1, 2, 3, 4}"); ArrayCreateExpression ace = ParseUtilVBNet.ParseExpression<ArrayCreateExpression>("new Integer() {1, 2, 3, 4}");
Assert.AreEqual("Integer", ace.CreateType.Type); Assert.AreEqual("System.Int32", ace.CreateType.Type);
Assert.AreEqual(0, ace.Arguments.Count); Assert.AreEqual(0, ace.Arguments.Count);
Assert.AreEqual(new int[] {0}, ace.CreateType.RankSpecifier); Assert.AreEqual(new int[] {0}, ace.CreateType.RankSpecifier);
} }
@ -53,7 +54,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
{ {
ArrayCreateExpression ace = ParseUtilVBNet.ParseExpression<ArrayCreateExpression>("New Integer(0 To 5){0, 1, 2, 3, 4, 5}"); ArrayCreateExpression ace = ParseUtilVBNet.ParseExpression<ArrayCreateExpression>("New Integer(0 To 5){0, 1, 2, 3, 4, 5}");
Assert.AreEqual("Integer", ace.CreateType.Type); Assert.AreEqual("System.Int32", ace.CreateType.Type);
Assert.AreEqual(1, ace.Arguments.Count); Assert.AreEqual(1, ace.Arguments.Count);
Assert.AreEqual(5, (ace.Arguments[0] as PrimitiveExpression).Value); Assert.AreEqual(5, (ace.Arguments[0] as PrimitiveExpression).Value);
Assert.AreEqual(new int[] {0}, ace.CreateType.RankSpecifier); Assert.AreEqual(new int[] {0}, ace.CreateType.RankSpecifier);

21
src/Libraries/NRefactory/Test/Parser/Expressions/CastExpressionTests.cs

@ -40,8 +40,8 @@ namespace ICSharpCode.NRefactory.Tests.Ast
public void NullablePrimitiveCastExpression() public void NullablePrimitiveCastExpression()
{ {
CastExpression ce = ParseUtilCSharp.ParseExpression<CastExpression>("(int?)o"); CastExpression ce = ParseUtilCSharp.ParseExpression<CastExpression>("(int?)o");
Assert.AreEqual("System.Nullable", ce.CastTo.SystemType); Assert.AreEqual("System.Nullable", ce.CastTo.Type);
Assert.AreEqual("int", ce.CastTo.GenericTypes[0].Type); Assert.AreEqual("System.Int32", ce.CastTo.GenericTypes[0].Type);
Assert.IsTrue(ce.Expression is IdentifierExpression); Assert.IsTrue(ce.Expression is IdentifierExpression);
Assert.AreEqual(CastType.Cast, ce.CastType); Assert.AreEqual(CastType.Cast, ce.CastType);
} }
@ -50,7 +50,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
public void NullableCastExpression() public void NullableCastExpression()
{ {
CastExpression ce = ParseUtilCSharp.ParseExpression<CastExpression>("(MyType?)o"); CastExpression ce = ParseUtilCSharp.ParseExpression<CastExpression>("(MyType?)o");
Assert.AreEqual("System.Nullable", ce.CastTo.SystemType); Assert.AreEqual("System.Nullable", ce.CastTo.Type);
Assert.AreEqual("MyType", ce.CastTo.GenericTypes[0].Type); Assert.AreEqual("MyType", ce.CastTo.GenericTypes[0].Type);
Assert.IsTrue(ce.Expression is IdentifierExpression); Assert.IsTrue(ce.Expression is IdentifierExpression);
Assert.AreEqual(CastType.Cast, ce.CastType); Assert.AreEqual(CastType.Cast, ce.CastType);
@ -60,8 +60,9 @@ namespace ICSharpCode.NRefactory.Tests.Ast
public void NullableTryCastExpression() public void NullableTryCastExpression()
{ {
CastExpression ce = ParseUtilCSharp.ParseExpression<CastExpression>("o as int?"); CastExpression ce = ParseUtilCSharp.ParseExpression<CastExpression>("o as int?");
Assert.AreEqual("System.Nullable", ce.CastTo.SystemType); Assert.AreEqual("System.Nullable", ce.CastTo.Type);
Assert.AreEqual("int", ce.CastTo.GenericTypes[0].Type); Assert.IsTrue(ce.CastTo.IsKeyword);
Assert.AreEqual("System.Int32", ce.CastTo.GenericTypes[0].Type);
Assert.IsTrue(ce.Expression is IdentifierExpression); Assert.IsTrue(ce.Expression is IdentifierExpression);
Assert.AreEqual(CastType.TryCast, ce.CastType); Assert.AreEqual(CastType.TryCast, ce.CastType);
} }
@ -71,7 +72,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
{ {
CastExpression ce = ParseUtilCSharp.ParseExpression<CastExpression>("(List<string>)o"); CastExpression ce = ParseUtilCSharp.ParseExpression<CastExpression>("(List<string>)o");
Assert.AreEqual("List", ce.CastTo.Type); Assert.AreEqual("List", ce.CastTo.Type);
Assert.AreEqual("string", ce.CastTo.GenericTypes[0].Type); Assert.AreEqual("System.String", ce.CastTo.GenericTypes[0].Type);
Assert.IsTrue(ce.Expression is IdentifierExpression); Assert.IsTrue(ce.Expression is IdentifierExpression);
Assert.AreEqual(CastType.Cast, ce.CastType); Assert.AreEqual(CastType.Cast, ce.CastType);
} }
@ -81,7 +82,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
{ {
CastExpression ce = ParseUtilCSharp.ParseExpression<CastExpression>("(List<string>[])o"); CastExpression ce = ParseUtilCSharp.ParseExpression<CastExpression>("(List<string>[])o");
Assert.AreEqual("List", ce.CastTo.Type); Assert.AreEqual("List", ce.CastTo.Type);
Assert.AreEqual("string", ce.CastTo.GenericTypes[0].Type); Assert.AreEqual("System.String", ce.CastTo.GenericTypes[0].Type);
Assert.AreEqual(new int[] { 0 }, ce.CastTo.RankSpecifier); Assert.AreEqual(new int[] { 0 }, ce.CastTo.RankSpecifier);
Assert.IsTrue(ce.Expression is IdentifierExpression); Assert.IsTrue(ce.Expression is IdentifierExpression);
Assert.AreEqual(CastType.Cast, ce.CastType); Assert.AreEqual(CastType.Cast, ce.CastType);
@ -92,7 +93,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
{ {
CastExpression ce = ParseUtilCSharp.ParseExpression<CastExpression>("o as List<string>[]"); CastExpression ce = ParseUtilCSharp.ParseExpression<CastExpression>("o as List<string>[]");
Assert.AreEqual("List", ce.CastTo.Type); Assert.AreEqual("List", ce.CastTo.Type);
Assert.AreEqual("string", ce.CastTo.GenericTypes[0].Type); Assert.AreEqual("System.String", ce.CastTo.GenericTypes[0].Type);
Assert.AreEqual(new int[] { 0 }, ce.CastTo.RankSpecifier); Assert.AreEqual(new int[] { 0 }, ce.CastTo.RankSpecifier);
Assert.IsTrue(ce.Expression is IdentifierExpression); Assert.IsTrue(ce.Expression is IdentifierExpression);
Assert.AreEqual(CastType.TryCast, ce.CastType); Assert.AreEqual(CastType.TryCast, ce.CastType);
@ -112,7 +113,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
public void CSharpTryCastParenthesizedExpression() public void CSharpTryCastParenthesizedExpression()
{ {
CastExpression ce = ParseUtilCSharp.ParseExpression<CastExpression>("(o) as string"); CastExpression ce = ParseUtilCSharp.ParseExpression<CastExpression>("(o) as string");
Assert.AreEqual("string", ce.CastTo.ToString()); Assert.AreEqual("System.String", ce.CastTo.ToString());
Assert.IsTrue(ce.Expression is ParenthesizedExpression); Assert.IsTrue(ce.Expression is ParenthesizedExpression);
Assert.AreEqual(CastType.TryCast, ce.CastType); Assert.AreEqual(CastType.TryCast, ce.CastType);
} }
@ -121,7 +122,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
public void CSharpCastNegation() public void CSharpCastNegation()
{ {
CastExpression ce = ParseUtilCSharp.ParseExpression<CastExpression>("(uint)-negativeValue"); CastExpression ce = ParseUtilCSharp.ParseExpression<CastExpression>("(uint)-negativeValue");
Assert.AreEqual("uint", ce.CastTo.ToString()); Assert.AreEqual("System.UInt32", ce.CastTo.ToString());
Assert.IsTrue(ce.Expression is UnaryOperatorExpression); Assert.IsTrue(ce.Expression is UnaryOperatorExpression);
Assert.AreEqual(CastType.Cast, ce.CastType); Assert.AreEqual(CastType.Cast, ce.CastType);
} }

2
src/Libraries/NRefactory/Test/Parser/Expressions/DefaultValueExpressionTests.cs

@ -36,7 +36,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
{ {
DefaultValueExpression toe = ParseUtilCSharp.ParseExpression<DefaultValueExpression>("default(MyNamespace.N1.MyType<string>)"); DefaultValueExpression toe = ParseUtilCSharp.ParseExpression<DefaultValueExpression>("default(MyNamespace.N1.MyType<string>)");
Assert.AreEqual("MyNamespace.N1.MyType", toe.TypeReference.Type); Assert.AreEqual("MyNamespace.N1.MyType", toe.TypeReference.Type);
Assert.AreEqual("string", toe.TypeReference.GenericTypes[0].Type); Assert.AreEqual("System.String", toe.TypeReference.GenericTypes[0].Type);
} }
[Test] [Test]

8
src/Libraries/NRefactory/Test/Parser/Expressions/InvocationExpressionTests.cs

@ -30,7 +30,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
IdentifierExpression ident = (IdentifierExpression)expr.TargetObject; IdentifierExpression ident = (IdentifierExpression)expr.TargetObject;
Assert.AreEqual("myMethod", ident.Identifier); Assert.AreEqual("myMethod", ident.Identifier);
Assert.AreEqual(1, ident.TypeArguments.Count); Assert.AreEqual(1, ident.TypeArguments.Count);
Assert.AreEqual("System.Char", ident.TypeArguments[0].SystemType); Assert.AreEqual("System.Char", ident.TypeArguments[0].Type);
} }
void CheckGenericInvoke2(InvocationExpression expr) void CheckGenericInvoke2(InvocationExpression expr)
@ -40,8 +40,10 @@ namespace ICSharpCode.NRefactory.Tests.Ast
IdentifierExpression ident = (IdentifierExpression)expr.TargetObject; IdentifierExpression ident = (IdentifierExpression)expr.TargetObject;
Assert.AreEqual("myMethod", ident.Identifier); Assert.AreEqual("myMethod", ident.Identifier);
Assert.AreEqual(2, ident.TypeArguments.Count); Assert.AreEqual(2, ident.TypeArguments.Count);
Assert.AreEqual("T", ident.TypeArguments[0].SystemType); Assert.AreEqual("T", ident.TypeArguments[0].Type);
Assert.AreEqual("System.Boolean", ident.TypeArguments[1].SystemType); Assert.IsFalse(ident.TypeArguments[0].IsKeyword);
Assert.AreEqual("System.Boolean", ident.TypeArguments[1].Type);
Assert.IsTrue(ident.TypeArguments[1].IsKeyword);
} }

4
src/Libraries/NRefactory/Test/Parser/Expressions/LambdaExpressionTests.cs

@ -64,7 +64,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
{ {
LambdaExpression e = ParseCSharp("(int x) => { return x + 1; }"); LambdaExpression e = ParseCSharp("(int x) => { return x + 1; }");
Assert.AreEqual("x", e.Parameters[0].ParameterName); Assert.AreEqual("x", e.Parameters[0].ParameterName);
Assert.AreEqual("int", e.Parameters[0].TypeReference.Type); Assert.AreEqual("System.Int32", e.Parameters[0].TypeReference.Type);
Assert.IsTrue(e.StatementBody.Children[0] is ReturnStatement); Assert.IsTrue(e.StatementBody.Children[0] is ReturnStatement);
} }
@ -91,7 +91,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
LambdaExpression e = ParseVBNet("Function(x As Boolean) x Or True"); LambdaExpression e = ParseVBNet("Function(x As Boolean) x Or True");
Assert.AreEqual(1, e.Parameters.Count); Assert.AreEqual(1, e.Parameters.Count);
Assert.AreEqual("x", e.Parameters[0].ParameterName); Assert.AreEqual("x", e.Parameters[0].ParameterName);
Assert.AreEqual("Boolean", e.Parameters[0].TypeReference.Type); Assert.AreEqual("System.Boolean", e.Parameters[0].TypeReference.Type);
Assert.IsTrue(e.ExpressionBody is BinaryOperatorExpression); Assert.IsTrue(e.ExpressionBody is BinaryOperatorExpression);
} }

16
src/Libraries/NRefactory/Test/Parser/Expressions/MemberReferenceExpressionTests.cs

@ -35,7 +35,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
TypeReference tr = ((TypeReferenceExpression)fre.TargetObject).TypeReference; TypeReference tr = ((TypeReferenceExpression)fre.TargetObject).TypeReference;
Assert.AreEqual("SomeClass", tr.Type); Assert.AreEqual("SomeClass", tr.Type);
Assert.AreEqual(1, tr.GenericTypes.Count); Assert.AreEqual(1, tr.GenericTypes.Count);
Assert.AreEqual("System.String", tr.GenericTypes[0].SystemType); Assert.AreEqual("System.String", tr.GenericTypes[0].Type);
} }
[Test] [Test]
@ -47,7 +47,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
TypeReference tr = ((TypeReferenceExpression)fre.TargetObject).TypeReference; TypeReference tr = ((TypeReferenceExpression)fre.TargetObject).TypeReference;
Assert.AreEqual("Namespace.Subnamespace.SomeClass", tr.Type); Assert.AreEqual("Namespace.Subnamespace.SomeClass", tr.Type);
Assert.AreEqual(1, tr.GenericTypes.Count); Assert.AreEqual(1, tr.GenericTypes.Count);
Assert.AreEqual("System.String", tr.GenericTypes[0].SystemType); Assert.AreEqual("System.String", tr.GenericTypes[0].Type);
} }
[Test] [Test]
@ -60,7 +60,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
Assert.IsFalse(tr is InnerClassTypeReference); Assert.IsFalse(tr is InnerClassTypeReference);
Assert.AreEqual("Namespace.Subnamespace.SomeClass", tr.Type); Assert.AreEqual("Namespace.Subnamespace.SomeClass", tr.Type);
Assert.AreEqual(1, tr.GenericTypes.Count); Assert.AreEqual(1, tr.GenericTypes.Count);
Assert.AreEqual("System.String", tr.GenericTypes[0].SystemType); Assert.AreEqual("System.String", tr.GenericTypes[0].Type);
Assert.IsTrue(tr.IsGlobal); Assert.IsTrue(tr.IsGlobal);
} }
@ -73,10 +73,10 @@ namespace ICSharpCode.NRefactory.Tests.Ast
InnerClassTypeReference ic = (InnerClassTypeReference)((TypeReferenceExpression)fre.TargetObject).TypeReference; InnerClassTypeReference ic = (InnerClassTypeReference)((TypeReferenceExpression)fre.TargetObject).TypeReference;
Assert.AreEqual("InnerClass", ic.Type); Assert.AreEqual("InnerClass", ic.Type);
Assert.AreEqual(1, ic.GenericTypes.Count); Assert.AreEqual(1, ic.GenericTypes.Count);
Assert.AreEqual("System.Int32", ic.GenericTypes[0].SystemType); Assert.AreEqual("System.Int32", ic.GenericTypes[0].Type);
Assert.AreEqual("MyType", ic.BaseType.Type); Assert.AreEqual("MyType", ic.BaseType.Type);
Assert.AreEqual(1, ic.BaseType.GenericTypes.Count); Assert.AreEqual(1, ic.BaseType.GenericTypes.Count);
Assert.AreEqual("System.String", ic.BaseType.GenericTypes[0].SystemType); Assert.AreEqual("System.String", ic.BaseType.GenericTypes[0].Type);
} }
#endregion #endregion
@ -105,7 +105,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
Assert.AreEqual("myField", fre.MemberName); Assert.AreEqual("myField", fre.MemberName);
Assert.IsInstanceOfType(typeof(IdentifierExpression), fre.TargetObject); Assert.IsInstanceOfType(typeof(IdentifierExpression), fre.TargetObject);
TypeReference tr = ((IdentifierExpression)fre.TargetObject).TypeArguments[0]; TypeReference tr = ((IdentifierExpression)fre.TargetObject).TypeArguments[0];
Assert.AreEqual("String", tr.Type); Assert.AreEqual("System.String", tr.Type);
} }
[Test] [Test]
@ -118,7 +118,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
MemberReferenceExpression inner = (MemberReferenceExpression)fre.TargetObject; MemberReferenceExpression inner = (MemberReferenceExpression)fre.TargetObject;
Assert.AreEqual("SomeClass", inner.MemberName); Assert.AreEqual("SomeClass", inner.MemberName);
Assert.AreEqual(1, inner.TypeArguments.Count); Assert.AreEqual(1, inner.TypeArguments.Count);
Assert.AreEqual("System.String", inner.TypeArguments[0].SystemType); Assert.AreEqual("System.String", inner.TypeArguments[0].Type);
} }
[Test] [Test]
@ -131,7 +131,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
Assert.AreEqual("SomeClass", inner.MemberName); Assert.AreEqual("SomeClass", inner.MemberName);
Assert.AreEqual(1, inner.TypeArguments.Count); Assert.AreEqual(1, inner.TypeArguments.Count);
Assert.AreEqual("System.String", inner.TypeArguments[0].SystemType); Assert.AreEqual("System.String", inner.TypeArguments[0].Type);
} }
[Test] [Test]

14
src/Libraries/NRefactory/Test/Parser/Expressions/ObjectCreateExpressionTests.cs

@ -38,7 +38,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
public void CSharpNullableObjectCreateExpressionTest() public void CSharpNullableObjectCreateExpressionTest()
{ {
ObjectCreateExpression oce = ParseUtilCSharp.ParseExpression<ObjectCreateExpression>("new IntPtr?(1)"); ObjectCreateExpression oce = ParseUtilCSharp.ParseExpression<ObjectCreateExpression>("new IntPtr?(1)");
Assert.AreEqual("System.Nullable", oce.CreateType.SystemType); Assert.AreEqual("System.Nullable", oce.CreateType.Type);
Assert.AreEqual(1, oce.CreateType.GenericTypes.Count); Assert.AreEqual(1, oce.CreateType.GenericTypes.Count);
Assert.AreEqual("IntPtr", oce.CreateType.GenericTypes[0].Type); Assert.AreEqual("IntPtr", oce.CreateType.GenericTypes[0].Type);
} }
@ -72,7 +72,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
TypeReference typeRef = ((ObjectCreateExpression)expr.Arguments[0]).CreateType; TypeReference typeRef = ((ObjectCreateExpression)expr.Arguments[0]).CreateType;
Assert.AreEqual("SomeGenericType", typeRef.Type); Assert.AreEqual("SomeGenericType", typeRef.Type);
Assert.AreEqual(1, typeRef.GenericTypes.Count); Assert.AreEqual(1, typeRef.GenericTypes.Count);
Assert.AreEqual("int", typeRef.GenericTypes[0].Type); Assert.AreEqual("System.Int32", typeRef.GenericTypes[0].Type);
} }
Expression CheckPropertyInitializationExpression(Expression e, string name) Expression CheckPropertyInitializationExpression(Expression e, string name)
@ -225,7 +225,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
TypeReference typeRef = ((ObjectCreateExpression)expr.Arguments[0]).CreateType; TypeReference typeRef = ((ObjectCreateExpression)expr.Arguments[0]).CreateType;
Assert.AreEqual("SomeGenericType", typeRef.Type); Assert.AreEqual("SomeGenericType", typeRef.Type);
Assert.AreEqual(1, typeRef.GenericTypes.Count); Assert.AreEqual(1, typeRef.GenericTypes.Count);
Assert.AreEqual("Integer", typeRef.GenericTypes[0].Type); Assert.AreEqual("System.Int32", typeRef.GenericTypes[0].Type);
} }
[Test] [Test]
@ -245,18 +245,18 @@ namespace ICSharpCode.NRefactory.Tests.Ast
public void VBNetNullableObjectCreateExpressionTest() public void VBNetNullableObjectCreateExpressionTest()
{ {
ObjectCreateExpression oce = ParseUtilVBNet.ParseExpression<ObjectCreateExpression>("New Integer?"); ObjectCreateExpression oce = ParseUtilVBNet.ParseExpression<ObjectCreateExpression>("New Integer?");
Assert.AreEqual("System.Nullable", oce.CreateType.SystemType); Assert.AreEqual("System.Nullable", oce.CreateType.Type);
Assert.AreEqual(1, oce.CreateType.GenericTypes.Count); Assert.AreEqual(1, oce.CreateType.GenericTypes.Count);
Assert.AreEqual("Integer", oce.CreateType.GenericTypes[0].Type); Assert.AreEqual("System.Int32", oce.CreateType.GenericTypes[0].Type);
} }
[Test] [Test]
public void VBNetNullableObjectArrayCreateExpressionTest() public void VBNetNullableObjectArrayCreateExpressionTest()
{ {
ObjectCreateExpression oce = ParseUtilVBNet.ParseExpression<ObjectCreateExpression>("New Integer?()"); ObjectCreateExpression oce = ParseUtilVBNet.ParseExpression<ObjectCreateExpression>("New Integer?()");
Assert.AreEqual("System.Nullable", oce.CreateType.SystemType); Assert.AreEqual("System.Nullable", oce.CreateType.Type);
Assert.AreEqual(1, oce.CreateType.GenericTypes.Count); Assert.AreEqual(1, oce.CreateType.GenericTypes.Count);
Assert.AreEqual("Integer", oce.CreateType.GenericTypes[0].Type); Assert.AreEqual("System.Int32", oce.CreateType.GenericTypes[0].Type);
} }
#endregion #endregion

2
src/Libraries/NRefactory/Test/Parser/Expressions/PointerReferenceExpressionTests.cs

@ -22,7 +22,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
{ {
PointerReferenceExpression pre = ParseUtilCSharp.ParseExpression<PointerReferenceExpression>("myObj.field->b"); PointerReferenceExpression pre = ParseUtilCSharp.ParseExpression<PointerReferenceExpression>("myObj.field->b");
Assert.IsTrue(pre.TargetObject is MemberReferenceExpression); Assert.IsTrue(pre.TargetObject is MemberReferenceExpression);
Assert.AreEqual("b", pre.Identifier); Assert.AreEqual("b", pre.MemberName);
} }
#endregion #endregion

4
src/Libraries/NRefactory/Test/Parser/Expressions/QueryExpressionTests.cs

@ -50,7 +50,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
"from int c in customers select c" "from int c in customers select c"
); );
Assert.AreEqual("c", qe.FromClause.Identifier); Assert.AreEqual("c", qe.FromClause.Identifier);
Assert.AreEqual("System.Int32", qe.FromClause.Type.SystemType); Assert.AreEqual("System.Int32", qe.FromClause.Type.Type);
Assert.AreEqual("customers", ((IdentifierExpression)qe.FromClause.InExpression).Identifier); Assert.AreEqual("customers", ((IdentifierExpression)qe.FromClause.InExpression).Identifier);
Assert.IsInstanceOfType(typeof(QueryExpressionSelectClause), qe.SelectOrGroupClause); Assert.IsInstanceOfType(typeof(QueryExpressionSelectClause), qe.SelectOrGroupClause);
} }
@ -63,7 +63,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
"from S<int[]>? c in customers select c" "from S<int[]>? c in customers select c"
); );
Assert.AreEqual("c", qe.FromClause.Identifier); Assert.AreEqual("c", qe.FromClause.Identifier);
Assert.AreEqual("System.Nullable<S<int[]>>", qe.FromClause.Type.ToString()); Assert.AreEqual("System.Nullable<S<System.Int32[]>>", qe.FromClause.Type.ToString());
Assert.AreEqual("customers", ((IdentifierExpression)qe.FromClause.InExpression).Identifier); Assert.AreEqual("customers", ((IdentifierExpression)qe.FromClause.InExpression).Identifier);
Assert.IsInstanceOfType(typeof(QueryExpressionSelectClause), qe.SelectOrGroupClause); Assert.IsInstanceOfType(typeof(QueryExpressionSelectClause), qe.SelectOrGroupClause);
} }

22
src/Libraries/NRefactory/Test/Parser/Expressions/TypeOfExpressionTests.cs

@ -35,14 +35,14 @@ namespace ICSharpCode.NRefactory.Tests.Ast
public void CSharpPrimitiveTypeOfExpressionTest() public void CSharpPrimitiveTypeOfExpressionTest()
{ {
TypeOfExpression toe = ParseUtilCSharp.ParseExpression<TypeOfExpression>("typeof(int)"); TypeOfExpression toe = ParseUtilCSharp.ParseExpression<TypeOfExpression>("typeof(int)");
Assert.AreEqual("System.Int32", toe.TypeReference.SystemType); Assert.AreEqual("System.Int32", toe.TypeReference.Type);
} }
[Test] [Test]
public void CSharpVoidTypeOfExpressionTest() public void CSharpVoidTypeOfExpressionTest()
{ {
TypeOfExpression toe = ParseUtilCSharp.ParseExpression<TypeOfExpression>("typeof(void)"); TypeOfExpression toe = ParseUtilCSharp.ParseExpression<TypeOfExpression>("typeof(void)");
Assert.AreEqual("System.Void", toe.TypeReference.SystemType); Assert.AreEqual("System.Void", toe.TypeReference.Type);
} }
[Test] [Test]
@ -58,7 +58,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
{ {
TypeOfExpression toe = ParseUtilCSharp.ParseExpression<TypeOfExpression>("typeof(MyNamespace.N1.MyType<string>)"); TypeOfExpression toe = ParseUtilCSharp.ParseExpression<TypeOfExpression>("typeof(MyNamespace.N1.MyType<string>)");
Assert.AreEqual("MyNamespace.N1.MyType", toe.TypeReference.Type); Assert.AreEqual("MyNamespace.N1.MyType", toe.TypeReference.Type);
Assert.AreEqual("System.String", toe.TypeReference.GenericTypes[0].SystemType); Assert.AreEqual("System.String", toe.TypeReference.GenericTypes[0].Type);
} }
[Test] [Test]
@ -71,17 +71,17 @@ namespace ICSharpCode.NRefactory.Tests.Ast
ic = (InnerClassTypeReference)ic.BaseType; ic = (InnerClassTypeReference)ic.BaseType;
Assert.AreEqual("InnerClass", ic.Type); Assert.AreEqual("InnerClass", ic.Type);
Assert.AreEqual(1, ic.GenericTypes.Count); Assert.AreEqual(1, ic.GenericTypes.Count);
Assert.AreEqual("System.Int32", ic.GenericTypes[0].SystemType); Assert.AreEqual("System.Int32", ic.GenericTypes[0].Type);
Assert.AreEqual("MyType", ic.BaseType.Type); Assert.AreEqual("MyType", ic.BaseType.Type);
Assert.AreEqual(1, ic.BaseType.GenericTypes.Count); Assert.AreEqual(1, ic.BaseType.GenericTypes.Count);
Assert.AreEqual("System.String", ic.BaseType.GenericTypes[0].SystemType); Assert.AreEqual("System.String", ic.BaseType.GenericTypes[0].Type);
} }
[Test] [Test]
public void CSharpNullableTypeOfExpressionTest() public void CSharpNullableTypeOfExpressionTest()
{ {
TypeOfExpression toe = ParseUtilCSharp.ParseExpression<TypeOfExpression>("typeof(MyStruct?)"); TypeOfExpression toe = ParseUtilCSharp.ParseExpression<TypeOfExpression>("typeof(MyStruct?)");
Assert.AreEqual("System.Nullable", toe.TypeReference.SystemType); Assert.AreEqual("System.Nullable", toe.TypeReference.Type);
Assert.AreEqual("MyStruct", toe.TypeReference.GenericTypes[0].Type); Assert.AreEqual("MyStruct", toe.TypeReference.GenericTypes[0].Type);
} }
@ -115,14 +115,14 @@ namespace ICSharpCode.NRefactory.Tests.Ast
public void VBPrimitiveTypeOfExpressionTest() public void VBPrimitiveTypeOfExpressionTest()
{ {
TypeOfExpression toe = ParseUtilVBNet.ParseExpression<TypeOfExpression>("GetType(integer)"); TypeOfExpression toe = ParseUtilVBNet.ParseExpression<TypeOfExpression>("GetType(integer)");
Assert.AreEqual("System.Int32", toe.TypeReference.SystemType); Assert.AreEqual("System.Int32", toe.TypeReference.Type);
} }
[Test] [Test]
public void VBVoidTypeOfExpressionTest() public void VBVoidTypeOfExpressionTest()
{ {
TypeOfExpression toe = ParseUtilVBNet.ParseExpression<TypeOfExpression>("GetType(void)"); TypeOfExpression toe = ParseUtilVBNet.ParseExpression<TypeOfExpression>("GetType(void)");
Assert.AreEqual("System.Void", toe.TypeReference.SystemType); Assert.AreEqual("void", toe.TypeReference.Type);
} }
[Test] [Test]
@ -138,7 +138,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
{ {
TypeOfExpression toe = ParseUtilVBNet.ParseExpression<TypeOfExpression>("GetType(MyNamespace.N1.MyType(Of string))"); TypeOfExpression toe = ParseUtilVBNet.ParseExpression<TypeOfExpression>("GetType(MyNamespace.N1.MyType(Of string))");
Assert.AreEqual("MyNamespace.N1.MyType", toe.TypeReference.Type); Assert.AreEqual("MyNamespace.N1.MyType", toe.TypeReference.Type);
Assert.AreEqual("System.String", toe.TypeReference.GenericTypes[0].SystemType); Assert.AreEqual("System.String", toe.TypeReference.GenericTypes[0].Type);
} }
[Test] [Test]
@ -160,10 +160,10 @@ namespace ICSharpCode.NRefactory.Tests.Ast
ic = (InnerClassTypeReference)ic.BaseType; ic = (InnerClassTypeReference)ic.BaseType;
Assert.AreEqual("InnerClass", ic.Type); Assert.AreEqual("InnerClass", ic.Type);
Assert.AreEqual(1, ic.GenericTypes.Count); Assert.AreEqual(1, ic.GenericTypes.Count);
Assert.AreEqual("System.Int32", ic.GenericTypes[0].SystemType); Assert.AreEqual("System.Int32", ic.GenericTypes[0].Type);
Assert.AreEqual("MyType", ic.BaseType.Type); Assert.AreEqual("MyType", ic.BaseType.Type);
Assert.AreEqual(1, ic.BaseType.GenericTypes.Count); Assert.AreEqual(1, ic.BaseType.GenericTypes.Count);
Assert.AreEqual("System.String", ic.BaseType.GenericTypes[0].SystemType); Assert.AreEqual("System.String", ic.BaseType.GenericTypes[0].Type);
} }
#endregion #endregion
} }

10
src/Libraries/NRefactory/Test/Parser/Expressions/TypeOfIsExpressionTests.cs

@ -22,7 +22,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
{ {
TypeOfIsExpression ce = ParseUtilCSharp.ParseExpression<TypeOfIsExpression>("o is List<string>[]"); TypeOfIsExpression ce = ParseUtilCSharp.ParseExpression<TypeOfIsExpression>("o is List<string>[]");
Assert.AreEqual("List", ce.TypeReference.Type); Assert.AreEqual("List", ce.TypeReference.Type);
Assert.AreEqual("string", ce.TypeReference.GenericTypes[0].Type); Assert.AreEqual("System.String", ce.TypeReference.GenericTypes[0].Type);
Assert.AreEqual(new int[] { 0 }, ce.TypeReference.RankSpecifier); Assert.AreEqual(new int[] { 0 }, ce.TypeReference.RankSpecifier);
Assert.IsTrue(ce.Expression is IdentifierExpression); Assert.IsTrue(ce.Expression is IdentifierExpression);
} }
@ -31,8 +31,8 @@ namespace ICSharpCode.NRefactory.Tests.Ast
public void NullableIsExpression() public void NullableIsExpression()
{ {
TypeOfIsExpression ce = ParseUtilCSharp.ParseExpression<TypeOfIsExpression>("o is int?"); TypeOfIsExpression ce = ParseUtilCSharp.ParseExpression<TypeOfIsExpression>("o is int?");
Assert.AreEqual("System.Nullable", ce.TypeReference.SystemType); Assert.AreEqual("System.Nullable", ce.TypeReference.Type);
Assert.AreEqual("int", ce.TypeReference.GenericTypes[0].Type); Assert.AreEqual("System.Int32", ce.TypeReference.GenericTypes[0].Type);
Assert.IsTrue(ce.Expression is IdentifierExpression); Assert.IsTrue(ce.Expression is IdentifierExpression);
} }
@ -42,8 +42,8 @@ namespace ICSharpCode.NRefactory.Tests.Ast
BinaryOperatorExpression boe; BinaryOperatorExpression boe;
boe = ParseUtilCSharp.ParseExpression<BinaryOperatorExpression>("o is int? == true"); boe = ParseUtilCSharp.ParseExpression<BinaryOperatorExpression>("o is int? == true");
TypeOfIsExpression ce = (TypeOfIsExpression)boe.Left; TypeOfIsExpression ce = (TypeOfIsExpression)boe.Left;
Assert.AreEqual("System.Nullable", ce.TypeReference.SystemType); Assert.AreEqual("System.Nullable", ce.TypeReference.Type);
Assert.AreEqual("int", ce.TypeReference.GenericTypes[0].Type); Assert.AreEqual("System.Int32", ce.TypeReference.GenericTypes[0].Type);
Assert.IsTrue(ce.Expression is IdentifierExpression); Assert.IsTrue(ce.Expression is IdentifierExpression);
} }
#endregion #endregion

12
src/Libraries/NRefactory/Test/Parser/Expressions/TypeReferenceExpressionTests.cs

@ -47,7 +47,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
{ {
MemberReferenceExpression fre = ParseUtilCSharp.ParseExpression<MemberReferenceExpression>("int.MaxValue"); MemberReferenceExpression fre = ParseUtilCSharp.ParseExpression<MemberReferenceExpression>("int.MaxValue");
Assert.AreEqual("MaxValue", fre.MemberName); Assert.AreEqual("MaxValue", fre.MemberName);
Assert.AreEqual("System.Int32", ((TypeReferenceExpression)fre.TargetObject).TypeReference.SystemType); Assert.AreEqual("System.Int32", ((TypeReferenceExpression)fre.TargetObject).TypeReference.Type);
} }
[Test] [Test]
@ -58,7 +58,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
// on this trick. // on this trick.
MemberReferenceExpression fre = ParseUtilCSharp.ParseExpression<MemberReferenceExpression>("int", true); MemberReferenceExpression fre = ParseUtilCSharp.ParseExpression<MemberReferenceExpression>("int", true);
Assert.AreEqual("", fre.MemberName); Assert.AreEqual("", fre.MemberName);
Assert.AreEqual("System.Int32", ((TypeReferenceExpression)fre.TargetObject).TypeReference.SystemType); Assert.AreEqual("System.Int32", ((TypeReferenceExpression)fre.TargetObject).TypeReference.Type);
} }
#endregion #endregion
@ -68,7 +68,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
{ {
MemberReferenceExpression fre = ParseUtilVBNet.ParseExpression<MemberReferenceExpression>("inTeGer.MaxValue"); MemberReferenceExpression fre = ParseUtilVBNet.ParseExpression<MemberReferenceExpression>("inTeGer.MaxValue");
Assert.AreEqual("MaxValue", fre.MemberName); Assert.AreEqual("MaxValue", fre.MemberName);
Assert.AreEqual("System.Int32", ((TypeReferenceExpression)fre.TargetObject).TypeReference.SystemType); Assert.AreEqual("System.Int32", ((TypeReferenceExpression)fre.TargetObject).TypeReference.Type);
} }
[Test] [Test]
@ -79,7 +79,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
// on this trick. // on this trick.
MemberReferenceExpression fre = ParseUtilVBNet.ParseExpression<MemberReferenceExpression>("inTeGer", true); MemberReferenceExpression fre = ParseUtilVBNet.ParseExpression<MemberReferenceExpression>("inTeGer", true);
Assert.AreEqual("", fre.MemberName); Assert.AreEqual("", fre.MemberName);
Assert.AreEqual("System.Int32", ((TypeReferenceExpression)fre.TargetObject).TypeReference.SystemType); Assert.AreEqual("System.Int32", ((TypeReferenceExpression)fre.TargetObject).TypeReference.Type);
} }
[Test] [Test]
@ -87,7 +87,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
{ {
MemberReferenceExpression fre = ParseUtilVBNet.ParseExpression<MemberReferenceExpression>("Object.ReferenceEquals"); MemberReferenceExpression fre = ParseUtilVBNet.ParseExpression<MemberReferenceExpression>("Object.ReferenceEquals");
Assert.AreEqual("ReferenceEquals", fre.MemberName); Assert.AreEqual("ReferenceEquals", fre.MemberName);
Assert.AreEqual("System.Object", ((TypeReferenceExpression)fre.TargetObject).TypeReference.SystemType); Assert.AreEqual("System.Object", ((TypeReferenceExpression)fre.TargetObject).TypeReference.Type);
} }
[Test] [Test]
@ -98,7 +98,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
// on this trick. // on this trick.
MemberReferenceExpression fre = ParseUtilVBNet.ParseExpression<MemberReferenceExpression>("obJeCt", true); MemberReferenceExpression fre = ParseUtilVBNet.ParseExpression<MemberReferenceExpression>("obJeCt", true);
Assert.AreEqual("", fre.MemberName); Assert.AreEqual("", fre.MemberName);
Assert.AreEqual("System.Object", ((TypeReferenceExpression)fre.TargetObject).TypeReference.SystemType); Assert.AreEqual("System.Object", ((TypeReferenceExpression)fre.TargetObject).TypeReference.Type);
} }
#endregion #endregion
} }

8
src/Libraries/NRefactory/Test/Parser/GlobalScope/DelegateDeclarationTests.cs

@ -16,7 +16,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
{ {
void TestDelegateDeclaration(DelegateDeclaration dd) void TestDelegateDeclaration(DelegateDeclaration dd)
{ {
Assert.AreEqual("System.Void", dd.ReturnType.SystemType); Assert.AreEqual("System.Void", dd.ReturnType.Type);
Assert.AreEqual("MyDelegate", dd.Name); Assert.AreEqual("MyDelegate", dd.Name);
} }
@ -25,10 +25,10 @@ namespace ICSharpCode.NRefactory.Tests.Ast
Assert.AreEqual(3, dd.Parameters.Count); Assert.AreEqual(3, dd.Parameters.Count);
Assert.AreEqual("a", ((ParameterDeclarationExpression)dd.Parameters[0]).ParameterName); Assert.AreEqual("a", ((ParameterDeclarationExpression)dd.Parameters[0]).ParameterName);
Assert.AreEqual("System.Int32", ((ParameterDeclarationExpression)dd.Parameters[0]).TypeReference.SystemType); Assert.AreEqual("System.Int32", ((ParameterDeclarationExpression)dd.Parameters[0]).TypeReference.Type);
Assert.AreEqual("secondParam", ((ParameterDeclarationExpression)dd.Parameters[1]).ParameterName); Assert.AreEqual("secondParam", ((ParameterDeclarationExpression)dd.Parameters[1]).ParameterName);
Assert.AreEqual("System.Int32", ((ParameterDeclarationExpression)dd.Parameters[1]).TypeReference.SystemType); Assert.AreEqual("System.Int32", ((ParameterDeclarationExpression)dd.Parameters[1]).TypeReference.Type);
Assert.AreEqual("lastParam", ((ParameterDeclarationExpression)dd.Parameters[2]).ParameterName); Assert.AreEqual("lastParam", ((ParameterDeclarationExpression)dd.Parameters[2]).ParameterName);
Assert.AreEqual("MyObj", ((ParameterDeclarationExpression)dd.Parameters[2]).TypeReference.Type); Assert.AreEqual("MyObj", ((ParameterDeclarationExpression)dd.Parameters[2]).TypeReference.Type);
@ -47,7 +47,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
{ {
string program = "public delegate void(int a, int secondParam, MyObj lastParam);\n"; string program = "public delegate void(int a, int secondParam, MyObj lastParam);\n";
DelegateDeclaration dd = ParseUtilCSharp.ParseGlobal<DelegateDeclaration>(program, true); DelegateDeclaration dd = ParseUtilCSharp.ParseGlobal<DelegateDeclaration>(program, true);
Assert.AreEqual("System.Void", dd.ReturnType.SystemType); Assert.AreEqual("System.Void", dd.ReturnType.Type);
//Assert.AreEqual("?", dd.Name); //Assert.AreEqual("?", dd.Name);
TestParameters(dd); TestParameters(dd);
} }

2
src/Libraries/NRefactory/Test/Parser/GlobalScope/TypeDeclarationTests.cs

@ -205,7 +205,7 @@ public abstract class MyClass : MyBase, Interface1, My.Test.Interface2
Assert.AreEqual("TestEnum", td.Name); Assert.AreEqual("TestEnum", td.Name);
Assert.AreEqual(ClassType.Enum, td.Type); Assert.AreEqual(ClassType.Enum, td.Type);
Assert.AreEqual("Byte", td.BaseTypes[0].Type); Assert.AreEqual("System.Byte", td.BaseTypes[0].Type);
Assert.AreEqual(0, td.Children.Count); Assert.AreEqual(0, td.Children.Count);
} }

2
src/Libraries/NRefactory/Test/Parser/GlobalScope/UsingDeclarationTests.cs

@ -57,7 +57,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
Assert.IsTrue(((Using)ud.Usings[0]).IsAlias); Assert.IsTrue(((Using)ud.Usings[0]).IsAlias);
Assert.AreEqual("StringCollection", ud.Usings[0].Name); Assert.AreEqual("StringCollection", ud.Usings[0].Name);
Assert.AreEqual("System.Collections.Generic.List", ud.Usings[0].Alias.Type); Assert.AreEqual("System.Collections.Generic.List", ud.Usings[0].Alias.Type);
Assert.AreEqual("System.String", ud.Usings[0].Alias.GenericTypes[0].SystemType); Assert.AreEqual("System.String", ud.Usings[0].Alias.GenericTypes[0].Type);
} }
#region C# #region C#

58
src/Libraries/NRefactory/Test/Parser/Statements/LocalVariableDeclarationTests.cs

@ -25,7 +25,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
Assert.AreEqual(1, lvd.Variables.Count); Assert.AreEqual(1, lvd.Variables.Count);
Assert.AreEqual("a", ((VariableDeclaration)lvd.Variables[0]).Name); Assert.AreEqual("a", ((VariableDeclaration)lvd.Variables[0]).Name);
TypeReference type = lvd.GetTypeForVariable(0); TypeReference type = lvd.GetTypeForVariable(0);
Assert.AreEqual("int", type.Type); Assert.AreEqual("System.Int32", type.Type);
Assert.AreEqual(5, ((PrimitiveExpression)lvd.Variables[0].Initializer).Value); Assert.AreEqual(5, ((PrimitiveExpression)lvd.Variables[0].Initializer).Value);
} }
@ -36,7 +36,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
Assert.AreEqual(1, lvd.Variables.Count); Assert.AreEqual(1, lvd.Variables.Count);
Assert.AreEqual("a", ((VariableDeclaration)lvd.Variables[0]).Name); Assert.AreEqual("a", ((VariableDeclaration)lvd.Variables[0]).Name);
TypeReference type = lvd.GetTypeForVariable(0); TypeReference type = lvd.GetTypeForVariable(0);
Assert.AreEqual("void", type.Type); Assert.AreEqual("System.Void", type.Type);
Assert.AreEqual(1, type.PointerNestingLevel); Assert.AreEqual(1, type.PointerNestingLevel);
} }
@ -69,10 +69,10 @@ namespace ICSharpCode.NRefactory.Tests.Ast
ic = (InnerClassTypeReference)ic.BaseType; ic = (InnerClassTypeReference)ic.BaseType;
Assert.AreEqual("InnerClass", ic.Type); Assert.AreEqual("InnerClass", ic.Type);
Assert.AreEqual(1, ic.GenericTypes.Count); Assert.AreEqual(1, ic.GenericTypes.Count);
Assert.AreEqual("System.Int32", ic.GenericTypes[0].SystemType); Assert.AreEqual("System.Int32", ic.GenericTypes[0].Type);
Assert.AreEqual("MyType", ic.BaseType.Type); Assert.AreEqual("MyType", ic.BaseType.Type);
Assert.AreEqual(1, ic.BaseType.GenericTypes.Count); Assert.AreEqual(1, ic.BaseType.GenericTypes.Count);
Assert.AreEqual("System.String", ic.BaseType.GenericTypes[0].SystemType); Assert.AreEqual("System.String", ic.BaseType.GenericTypes[0].Type);
} }
[Test] [Test]
@ -83,7 +83,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
TypeReference type = lvd.GetTypeForVariable(0); TypeReference type = lvd.GetTypeForVariable(0);
Assert.AreEqual("G", type.Type); Assert.AreEqual("G", type.Type);
Assert.AreEqual(1, type.GenericTypes.Count); Assert.AreEqual(1, type.GenericTypes.Count);
Assert.AreEqual("int", type.GenericTypes[0].Type); Assert.AreEqual("System.Int32", type.GenericTypes[0].Type);
Assert.AreEqual(0, type.GenericTypes[0].GenericTypes.Count); Assert.AreEqual(0, type.GenericTypes[0].GenericTypes.Count);
Assert.IsFalse(type.GenericTypes[0].IsArrayType); Assert.IsFalse(type.GenericTypes[0].IsArrayType);
Assert.AreEqual(new int[] {0}, type.RankSpecifier); Assert.AreEqual(new int[] {0}, type.RankSpecifier);
@ -97,7 +97,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
TypeReference type = lvd.GetTypeForVariable(0); TypeReference type = lvd.GetTypeForVariable(0);
Assert.AreEqual("G", type.Type); Assert.AreEqual("G", type.Type);
Assert.AreEqual(1, type.GenericTypes.Count); Assert.AreEqual(1, type.GenericTypes.Count);
Assert.AreEqual("int", type.GenericTypes[0].Type); Assert.AreEqual("System.Int32", type.GenericTypes[0].Type);
Assert.AreEqual(0, type.GenericTypes[0].GenericTypes.Count); Assert.AreEqual(0, type.GenericTypes[0].GenericTypes.Count);
Assert.IsFalse(type.IsArrayType); Assert.IsFalse(type.IsArrayType);
Assert.AreEqual(new int[] {0}, type.GenericTypes[0].RankSpecifier); Assert.AreEqual(new int[] {0}, type.GenericTypes[0].RankSpecifier);
@ -113,7 +113,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
Assert.AreEqual(1, type.GenericTypes.Count); Assert.AreEqual(1, type.GenericTypes.Count);
Assert.AreEqual("G", type.GenericTypes[0].Type); Assert.AreEqual("G", type.GenericTypes[0].Type);
Assert.AreEqual(1, type.GenericTypes[0].GenericTypes.Count); Assert.AreEqual(1, type.GenericTypes[0].GenericTypes.Count);
Assert.AreEqual("int", type.GenericTypes[0].GenericTypes[0].Type); Assert.AreEqual("System.Int32", type.GenericTypes[0].GenericTypes[0].Type);
} }
[Test] [Test]
@ -126,7 +126,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
Assert.AreEqual(1, type.GenericTypes.Count); Assert.AreEqual(1, type.GenericTypes.Count);
Assert.AreEqual("G", type.GenericTypes[0].Type); Assert.AreEqual("G", type.GenericTypes[0].Type);
Assert.AreEqual(1, type.GenericTypes[0].GenericTypes.Count); Assert.AreEqual(1, type.GenericTypes[0].GenericTypes.Count);
Assert.AreEqual("int", type.GenericTypes[0].GenericTypes[0].Type); Assert.AreEqual("System.Int32", type.GenericTypes[0].GenericTypes[0].Type);
} }
[Test] [Test]
@ -137,7 +137,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
TypeReference type = lvd.GetTypeForVariable(0); TypeReference type = lvd.GetTypeForVariable(0);
Assert.AreEqual("G", type.Type); Assert.AreEqual("G", type.Type);
Assert.AreEqual(1, type.GenericTypes.Count); Assert.AreEqual(1, type.GenericTypes.Count);
Assert.AreEqual("int", type.GenericTypes[0].Type); Assert.AreEqual("System.Int32", type.GenericTypes[0].Type);
} }
[Test] [Test]
@ -169,8 +169,8 @@ namespace ICSharpCode.NRefactory.Tests.Ast
Assert.AreEqual(1, lvd.Variables.Count); Assert.AreEqual(1, lvd.Variables.Count);
Assert.AreEqual("a", ((VariableDeclaration)lvd.Variables[0]).Name); Assert.AreEqual("a", ((VariableDeclaration)lvd.Variables[0]).Name);
TypeReference type = lvd.GetTypeForVariable(0); TypeReference type = lvd.GetTypeForVariable(0);
Assert.AreEqual("System.Nullable", type.SystemType); Assert.AreEqual("System.Nullable", type.Type);
Assert.AreEqual("System.Int32", type.GenericTypes[0].SystemType); Assert.AreEqual("System.Int32", type.GenericTypes[0].Type);
} }
[Test] [Test]
@ -180,7 +180,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
Assert.AreEqual(1, lvd.Variables.Count); Assert.AreEqual(1, lvd.Variables.Count);
Assert.AreEqual("a", ((VariableDeclaration)lvd.Variables[0]).Name); Assert.AreEqual("a", ((VariableDeclaration)lvd.Variables[0]).Name);
TypeReference type = lvd.GetTypeForVariable(0); TypeReference type = lvd.GetTypeForVariable(0);
Assert.AreEqual("System.Nullable", type.SystemType); Assert.AreEqual("System.Nullable", type.Type);
Assert.AreEqual("DateTime", type.GenericTypes[0].Type); Assert.AreEqual("DateTime", type.GenericTypes[0].Type);
} }
@ -192,7 +192,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
Assert.AreEqual("a", ((VariableDeclaration)lvd.Variables[0]).Name); Assert.AreEqual("a", ((VariableDeclaration)lvd.Variables[0]).Name);
TypeReference type = lvd.GetTypeForVariable(0); TypeReference type = lvd.GetTypeForVariable(0);
Assert.IsTrue(type.IsArrayType); Assert.IsTrue(type.IsArrayType);
Assert.AreEqual("System.Nullable", type.SystemType); Assert.AreEqual("System.Nullable", type.Type);
Assert.AreEqual("DateTime", type.GenericTypes[0].Type); Assert.AreEqual("DateTime", type.GenericTypes[0].Type);
} }
@ -203,10 +203,10 @@ namespace ICSharpCode.NRefactory.Tests.Ast
Assert.AreEqual(1, lvd.Variables.Count); Assert.AreEqual(1, lvd.Variables.Count);
Assert.AreEqual("a", ((VariableDeclaration)lvd.Variables[0]).Name); Assert.AreEqual("a", ((VariableDeclaration)lvd.Variables[0]).Name);
TypeReference type = lvd.GetTypeForVariable(0); TypeReference type = lvd.GetTypeForVariable(0);
Assert.AreEqual("System.Nullable", type.SystemType); Assert.AreEqual("System.Nullable", type.Type);
Assert.AreEqual("SomeStruct", type.GenericTypes[0].Type); Assert.AreEqual("SomeStruct", type.GenericTypes[0].Type);
Assert.AreEqual("System.Nullable", type.GenericTypes[0].GenericTypes[0].SystemType); Assert.AreEqual("System.Nullable", type.GenericTypes[0].GenericTypes[0].Type);
Assert.AreEqual("System.Int32", type.GenericTypes[0].GenericTypes[0].GenericTypes[0].SystemType); Assert.AreEqual("System.Int32", type.GenericTypes[0].GenericTypes[0].GenericTypes[0].Type);
} }
#endregion #endregion
@ -218,7 +218,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
Assert.AreEqual(1, lvd.Variables.Count); Assert.AreEqual(1, lvd.Variables.Count);
Assert.AreEqual("a", lvd.Variables[0].Name); Assert.AreEqual("a", lvd.Variables[0].Name);
TypeReference type = lvd.GetTypeForVariable(0); TypeReference type = lvd.GetTypeForVariable(0);
Assert.AreEqual("Integer", type.Type); Assert.AreEqual("System.Int32", type.Type);
Assert.AreEqual(5, ((PrimitiveExpression)lvd.Variables[0].Initializer).Value); Assert.AreEqual(5, ((PrimitiveExpression)lvd.Variables[0].Initializer).Value);
} }
@ -229,7 +229,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
Assert.AreEqual(1, lvd.Variables.Count); Assert.AreEqual(1, lvd.Variables.Count);
Assert.AreEqual("override", lvd.Variables[0].Name); Assert.AreEqual("override", lvd.Variables[0].Name);
TypeReference type = lvd.GetTypeForVariable(0); TypeReference type = lvd.GetTypeForVariable(0);
Assert.AreEqual("Integer", type.Type); Assert.AreEqual("System.Int32", type.Type);
Assert.AreEqual(5, ((PrimitiveExpression)lvd.Variables[0].Initializer).Value); Assert.AreEqual(5, ((PrimitiveExpression)lvd.Variables[0].Initializer).Value);
} }
@ -240,7 +240,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
Assert.AreEqual(1, lvd.Variables.Count); Assert.AreEqual(1, lvd.Variables.Count);
Assert.AreEqual("a", lvd.Variables[0].Name); Assert.AreEqual("a", lvd.Variables[0].Name);
TypeReference type = lvd.GetTypeForVariable(0); TypeReference type = lvd.GetTypeForVariable(0);
Assert.AreEqual("Integer", type.Type); Assert.AreEqual("System.Int32", type.Type);
Assert.AreEqual(new int[] { 0 } , type.RankSpecifier); Assert.AreEqual(new int[] { 0 } , type.RankSpecifier);
ArrayCreateExpression ace = (ArrayCreateExpression)lvd.Variables[0].Initializer; ArrayCreateExpression ace = (ArrayCreateExpression)lvd.Variables[0].Initializer;
Assert.AreEqual(new int[] { 0 } , ace.CreateType.RankSpecifier); Assert.AreEqual(new int[] { 0 } , ace.CreateType.RankSpecifier);
@ -256,7 +256,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
Assert.AreEqual(1, lvd.Variables.Count); Assert.AreEqual(1, lvd.Variables.Count);
Assert.AreEqual("a", lvd.Variables[0].Name); Assert.AreEqual("a", lvd.Variables[0].Name);
TypeReference type = lvd.GetTypeForVariable(0); TypeReference type = lvd.GetTypeForVariable(0);
Assert.AreEqual("Integer", type.Type); Assert.AreEqual("System.Int32", type.Type);
Assert.AreEqual(new int[] { 0 } , type.RankSpecifier); Assert.AreEqual(new int[] { 0 } , type.RankSpecifier);
ArrayCreateExpression ace = (ArrayCreateExpression)lvd.Variables[0].Initializer; ArrayCreateExpression ace = (ArrayCreateExpression)lvd.Variables[0].Initializer;
Assert.AreEqual(new int[] { 0 } , ace.CreateType.RankSpecifier); Assert.AreEqual(new int[] { 0 } , ace.CreateType.RankSpecifier);
@ -271,7 +271,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
Assert.AreEqual(1, lvd.Variables.Count); Assert.AreEqual(1, lvd.Variables.Count);
Assert.AreEqual("a", lvd.Variables[0].Name); Assert.AreEqual("a", lvd.Variables[0].Name);
TypeReference type = lvd.GetTypeForVariable(0); TypeReference type = lvd.GetTypeForVariable(0);
Assert.AreEqual("Integer", type.Type); Assert.AreEqual("System.Int32", type.Type);
Assert.AreEqual(new int[] { 0 } , type.RankSpecifier); Assert.AreEqual(new int[] { 0 } , type.RankSpecifier);
} }
@ -282,7 +282,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
Assert.AreEqual(1, lvd.Variables.Count); Assert.AreEqual(1, lvd.Variables.Count);
Assert.AreEqual("a", lvd.Variables[0].Name); Assert.AreEqual("a", lvd.Variables[0].Name);
TypeReference type = lvd.GetTypeForVariable(0); TypeReference type = lvd.GetTypeForVariable(0);
Assert.AreEqual("Integer", type.Type); Assert.AreEqual("System.Int32", type.Type);
Assert.AreEqual(new int[] { 0, 0 } , type.RankSpecifier); Assert.AreEqual(new int[] { 0, 0 } , type.RankSpecifier);
ArrayCreateExpression ace = (ArrayCreateExpression)lvd.Variables[0].Initializer; ArrayCreateExpression ace = (ArrayCreateExpression)lvd.Variables[0].Initializer;
Assert.AreEqual(new int[] {0, 0}, ace.CreateType.RankSpecifier); Assert.AreEqual(new int[] {0, 0}, ace.CreateType.RankSpecifier);
@ -314,7 +314,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
TypeReference type = lvd.GetTypeForVariable(0); TypeReference type = lvd.GetTypeForVariable(0);
Assert.AreEqual("G", type.Type); Assert.AreEqual("G", type.Type);
Assert.AreEqual(1, type.GenericTypes.Count); Assert.AreEqual(1, type.GenericTypes.Count);
Assert.AreEqual("Integer", type.GenericTypes[0].Type); Assert.AreEqual("System.Int32", type.GenericTypes[0].Type);
Assert.AreEqual(0, type.GenericTypes[0].GenericTypes.Count); Assert.AreEqual(0, type.GenericTypes[0].GenericTypes.Count);
Assert.IsFalse(type.GenericTypes[0].IsArrayType); Assert.IsFalse(type.GenericTypes[0].IsArrayType);
Assert.AreEqual(new int[] { 0 }, type.RankSpecifier); Assert.AreEqual(new int[] { 0 }, type.RankSpecifier);
@ -328,7 +328,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
TypeReference type = lvd.GetTypeForVariable(0); TypeReference type = lvd.GetTypeForVariable(0);
Assert.AreEqual("G", type.Type); Assert.AreEqual("G", type.Type);
Assert.AreEqual(1, type.GenericTypes.Count); Assert.AreEqual(1, type.GenericTypes.Count);
Assert.AreEqual("Integer", type.GenericTypes[0].Type); Assert.AreEqual("System.Int32", type.GenericTypes[0].Type);
Assert.AreEqual(0, type.GenericTypes[0].GenericTypes.Count); Assert.AreEqual(0, type.GenericTypes[0].GenericTypes.Count);
Assert.IsFalse(type.IsArrayType); Assert.IsFalse(type.IsArrayType);
Assert.AreEqual(1, type.GenericTypes[0].RankSpecifier.Length); Assert.AreEqual(1, type.GenericTypes[0].RankSpecifier.Length);
@ -345,7 +345,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
Assert.AreEqual(1, type.GenericTypes.Count); Assert.AreEqual(1, type.GenericTypes.Count);
Assert.AreEqual("G", type.GenericTypes[0].Type); Assert.AreEqual("G", type.GenericTypes[0].Type);
Assert.AreEqual(1, type.GenericTypes[0].GenericTypes.Count); Assert.AreEqual(1, type.GenericTypes[0].GenericTypes.Count);
Assert.AreEqual("Integer", type.GenericTypes[0].GenericTypes[0].Type); Assert.AreEqual("System.Int32", type.GenericTypes[0].GenericTypes[0].Type);
} }
[Test] [Test]
@ -356,7 +356,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
TypeReference type = lvd.GetTypeForVariable(0); TypeReference type = lvd.GetTypeForVariable(0);
Assert.AreEqual("G", type.Type); Assert.AreEqual("G", type.Type);
Assert.AreEqual(1, type.GenericTypes.Count); Assert.AreEqual(1, type.GenericTypes.Count);
Assert.AreEqual("Integer", type.GenericTypes[0].Type); Assert.AreEqual("System.Int32", type.GenericTypes[0].Type);
} }
[Test] [Test]
@ -367,7 +367,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
TypeReference type = lvd.GetTypeForVariable(0); TypeReference type = lvd.GetTypeForVariable(0);
Assert.AreEqual("G", type.Type); Assert.AreEqual("G", type.Type);
Assert.AreEqual(1, type.GenericTypes.Count); Assert.AreEqual(1, type.GenericTypes.Count);
Assert.AreEqual("Integer", type.GenericTypes[0].Type); Assert.AreEqual("System.Int32", type.GenericTypes[0].Type);
// TODO: Check initializer // TODO: Check initializer
} }
@ -382,10 +382,10 @@ namespace ICSharpCode.NRefactory.Tests.Ast
ic = (InnerClassTypeReference)ic.BaseType; ic = (InnerClassTypeReference)ic.BaseType;
Assert.AreEqual("InnerClass", ic.Type); Assert.AreEqual("InnerClass", ic.Type);
Assert.AreEqual(1, ic.GenericTypes.Count); Assert.AreEqual(1, ic.GenericTypes.Count);
Assert.AreEqual("System.Int32", ic.GenericTypes[0].SystemType); Assert.AreEqual("System.Int32", ic.GenericTypes[0].Type);
Assert.AreEqual("MyType", ic.BaseType.Type); Assert.AreEqual("MyType", ic.BaseType.Type);
Assert.AreEqual(1, ic.BaseType.GenericTypes.Count); Assert.AreEqual(1, ic.BaseType.GenericTypes.Count);
Assert.AreEqual("System.String", ic.BaseType.GenericTypes[0].SystemType); Assert.AreEqual("System.String", ic.BaseType.GenericTypes[0].Type);
} }
#endregion #endregion
} }

4
src/Libraries/NRefactory/Test/Parser/TypeLevel/ConstructorDeclarationTests.cs

@ -70,8 +70,8 @@ namespace ICSharpCode.NRefactory.Tests.Ast
{ {
ConstructorDeclaration cd = ParseUtilVBNet.ParseTypeMember<ConstructorDeclaration>("Sub New(x As Integer, Optional y As String) \nEnd Sub"); ConstructorDeclaration cd = ParseUtilVBNet.ParseTypeMember<ConstructorDeclaration>("Sub New(x As Integer, Optional y As String) \nEnd Sub");
Assert.AreEqual(2, cd.Parameters.Count); Assert.AreEqual(2, cd.Parameters.Count);
Assert.AreEqual("Integer", cd.Parameters[0].TypeReference.Type); Assert.AreEqual("System.Int32", cd.Parameters[0].TypeReference.Type);
Assert.AreEqual("String", cd.Parameters[1].TypeReference.Type); Assert.AreEqual("System.String", cd.Parameters[1].TypeReference.Type);
Assert.AreEqual(ParameterModifiers.Optional, cd.Parameters[1].ParamModifier & ParameterModifiers.Optional); Assert.AreEqual(ParameterModifiers.Optional, cd.Parameters[1].ParamModifier & ParameterModifiers.Optional);
} }
#endregion #endregion

2
src/Libraries/NRefactory/Test/Parser/TypeLevel/DeclareDeclarationTests.cs

@ -24,7 +24,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
{ {
string program = "Declare Ansi Function GetUserName Lib \"advapi32.dll\" Alias \"GetUserNameA\" (ByVal lpBuffer As String, ByRef nSize As Integer) As Integer\n"; string program = "Declare Ansi Function GetUserName Lib \"advapi32.dll\" Alias \"GetUserNameA\" (ByVal lpBuffer As String, ByRef nSize As Integer) As Integer\n";
DeclareDeclaration dd = ParseUtilVBNet.ParseTypeMember<DeclareDeclaration>(program); DeclareDeclaration dd = ParseUtilVBNet.ParseTypeMember<DeclareDeclaration>(program);
Assert.AreEqual("System.Int32", dd.TypeReference.SystemType); Assert.AreEqual("System.Int32", dd.TypeReference.Type);
Assert.AreEqual("GetUserName", dd.Name); Assert.AreEqual("GetUserName", dd.Name);
Assert.AreEqual("advapi32.dll", dd.Library); Assert.AreEqual("advapi32.dll", dd.Library);
Assert.AreEqual("GetUserNameA", dd.Alias); Assert.AreEqual("GetUserNameA", dd.Alias);

2
src/Libraries/NRefactory/Test/Parser/TypeLevel/EventDeclarationTests.cs

@ -53,7 +53,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
Assert.IsFalse(ed.HasRemoveRegion); Assert.IsFalse(ed.HasRemoveRegion);
Assert.AreEqual("MyInterface", ed.InterfaceImplementations[0].InterfaceType.Type); Assert.AreEqual("MyInterface", ed.InterfaceImplementations[0].InterfaceType.Type);
Assert.AreEqual("System.String", ed.InterfaceImplementations[0].InterfaceType.GenericTypes[0].SystemType); Assert.AreEqual("System.String", ed.InterfaceImplementations[0].InterfaceType.GenericTypes[0].Type);
Assert.AreEqual("MyEvent", ed.InterfaceImplementations[0].MemberName); Assert.AreEqual("MyEvent", ed.InterfaceImplementations[0].MemberName);
} }

18
src/Libraries/NRefactory/Test/Parser/TypeLevel/FieldDeclarationTests.cs

@ -19,7 +19,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
public void CSharpSimpleFieldDeclarationTest() public void CSharpSimpleFieldDeclarationTest()
{ {
FieldDeclaration fd = ParseUtilCSharp.ParseTypeMember<FieldDeclaration>("int[,,,] myField;"); FieldDeclaration fd = ParseUtilCSharp.ParseTypeMember<FieldDeclaration>("int[,,,] myField;");
Assert.AreEqual("int", fd.TypeReference.Type); Assert.AreEqual("System.Int32", fd.TypeReference.Type);
Assert.AreEqual(new int[] { 3 } , fd.TypeReference.RankSpecifier); Assert.AreEqual(new int[] { 3 } , fd.TypeReference.RankSpecifier);
Assert.AreEqual(1, fd.Fields.Count); Assert.AreEqual(1, fd.Fields.Count);
@ -34,8 +34,8 @@ namespace ICSharpCode.NRefactory.Tests.Ast
FieldDeclaration fd = ParseUtilVBNet.ParseTypeMember<FieldDeclaration>("myField As Integer(,,,)"); FieldDeclaration fd = ParseUtilVBNet.ParseTypeMember<FieldDeclaration>("myField As Integer(,,,)");
Assert.AreEqual(1, fd.Fields.Count); Assert.AreEqual(1, fd.Fields.Count);
Assert.AreEqual("Integer", ((VariableDeclaration)fd.Fields[0]).TypeReference.Type); Assert.AreEqual("System.Int32", ((VariableDeclaration)fd.Fields[0]).TypeReference.Type);
Assert.AreEqual("System.Int32", ((VariableDeclaration)fd.Fields[0]).TypeReference.SystemType); Assert.AreEqual("System.Int32", ((VariableDeclaration)fd.Fields[0]).TypeReference.Type);
Assert.AreEqual("myField", ((VariableDeclaration)fd.Fields[0]).Name); Assert.AreEqual("myField", ((VariableDeclaration)fd.Fields[0]).Name);
Assert.AreEqual(new int[] { 3 } , ((VariableDeclaration)fd.Fields[0]).TypeReference.RankSpecifier); Assert.AreEqual(new int[] { 3 } , ((VariableDeclaration)fd.Fields[0]).TypeReference.RankSpecifier);
} }
@ -46,9 +46,9 @@ namespace ICSharpCode.NRefactory.Tests.Ast
FieldDeclaration fd = ParseUtilVBNet.ParseTypeMember<FieldDeclaration>("a, b As String"); FieldDeclaration fd = ParseUtilVBNet.ParseTypeMember<FieldDeclaration>("a, b As String");
Assert.AreEqual(2, fd.Fields.Count); Assert.AreEqual(2, fd.Fields.Count);
Assert.AreEqual("String", ((VariableDeclaration)fd.Fields[0]).TypeReference.Type); Assert.AreEqual("System.String", ((VariableDeclaration)fd.Fields[0]).TypeReference.Type);
Assert.IsFalse(((VariableDeclaration)fd.Fields[0]).TypeReference.IsArrayType); Assert.IsFalse(((VariableDeclaration)fd.Fields[0]).TypeReference.IsArrayType);
Assert.AreEqual("String", ((VariableDeclaration)fd.Fields[1]).TypeReference.Type); Assert.AreEqual("System.String", ((VariableDeclaration)fd.Fields[1]).TypeReference.Type);
Assert.IsFalse(((VariableDeclaration)fd.Fields[1]).TypeReference.IsArrayType); Assert.IsFalse(((VariableDeclaration)fd.Fields[1]).TypeReference.IsArrayType);
} }
@ -69,8 +69,8 @@ namespace ICSharpCode.NRefactory.Tests.Ast
FieldDeclaration fd = ParseUtilVBNet.ParseTypeMember<FieldDeclaration>("Dim a, b() As String"); FieldDeclaration fd = ParseUtilVBNet.ParseTypeMember<FieldDeclaration>("Dim a, b() As String");
Assert.AreEqual(2, fd.Fields.Count); Assert.AreEqual(2, fd.Fields.Count);
Assert.AreEqual("String", ((VariableDeclaration)fd.Fields[0]).TypeReference.Type); Assert.AreEqual("System.String", ((VariableDeclaration)fd.Fields[0]).TypeReference.Type);
Assert.AreEqual("String", ((VariableDeclaration)fd.Fields[1]).TypeReference.Type); Assert.AreEqual("System.String", ((VariableDeclaration)fd.Fields[1]).TypeReference.Type);
Assert.IsFalse(((VariableDeclaration)fd.Fields[0]).TypeReference.IsArrayType); Assert.IsFalse(((VariableDeclaration)fd.Fields[0]).TypeReference.IsArrayType);
Assert.IsTrue(((VariableDeclaration)fd.Fields[1]).TypeReference.IsArrayType); Assert.IsTrue(((VariableDeclaration)fd.Fields[1]).TypeReference.IsArrayType);
} }
@ -81,8 +81,8 @@ namespace ICSharpCode.NRefactory.Tests.Ast
FieldDeclaration fd = ParseUtilVBNet.ParseTypeMember<FieldDeclaration>("Dim a(), b As String"); FieldDeclaration fd = ParseUtilVBNet.ParseTypeMember<FieldDeclaration>("Dim a(), b As String");
Assert.AreEqual(2, fd.Fields.Count); Assert.AreEqual(2, fd.Fields.Count);
Assert.AreEqual("String", ((VariableDeclaration)fd.Fields[0]).TypeReference.Type); Assert.AreEqual("System.String", ((VariableDeclaration)fd.Fields[0]).TypeReference.Type);
Assert.AreEqual("String", ((VariableDeclaration)fd.Fields[1]).TypeReference.Type); Assert.AreEqual("System.String", ((VariableDeclaration)fd.Fields[1]).TypeReference.Type);
Assert.IsTrue(((VariableDeclaration)fd.Fields[0]).TypeReference.IsArrayType); Assert.IsTrue(((VariableDeclaration)fd.Fields[0]).TypeReference.IsArrayType);
Assert.IsFalse(((VariableDeclaration)fd.Fields[1]).TypeReference.IsArrayType); Assert.IsFalse(((VariableDeclaration)fd.Fields[1]).TypeReference.IsArrayType);
} }

2
src/Libraries/NRefactory/Test/Parser/TypeLevel/IndexerDeclarationTests.cs

@ -44,7 +44,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
Assert.IsTrue(id.HasSetRegion, "No set region found!"); Assert.IsTrue(id.HasSetRegion, "No set region found!");
Assert.AreEqual("MyInterface", id.InterfaceImplementations[0].InterfaceType.Type); Assert.AreEqual("MyInterface", id.InterfaceImplementations[0].InterfaceType.Type);
Assert.AreEqual("System.String", id.InterfaceImplementations[0].InterfaceType.GenericTypes[0].SystemType); Assert.AreEqual("System.String", id.InterfaceImplementations[0].InterfaceType.GenericTypes[0].Type);
} }
#endregion #endregion

38
src/Libraries/NRefactory/Test/Parser/TypeLevel/MethodDeclarationTests.cs

@ -19,7 +19,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
public void CSharpSimpleMethodDeclarationTest() public void CSharpSimpleMethodDeclarationTest()
{ {
MethodDeclaration md = ParseUtilCSharp.ParseTypeMember<MethodDeclaration>("void MyMethod() {} "); MethodDeclaration md = ParseUtilCSharp.ParseTypeMember<MethodDeclaration>("void MyMethod() {} ");
Assert.AreEqual("void", md.TypeReference.Type); Assert.AreEqual("System.Void", md.TypeReference.Type);
Assert.AreEqual(0, md.Parameters.Count); Assert.AreEqual(0, md.Parameters.Count);
Assert.IsFalse(md.IsExtensionMethod); Assert.IsFalse(md.IsExtensionMethod);
} }
@ -28,7 +28,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
public void CSharpAbstractMethodDeclarationTest() public void CSharpAbstractMethodDeclarationTest()
{ {
MethodDeclaration md = ParseUtilCSharp.ParseTypeMember<MethodDeclaration>("abstract void MyMethod();"); MethodDeclaration md = ParseUtilCSharp.ParseTypeMember<MethodDeclaration>("abstract void MyMethod();");
Assert.AreEqual("void", md.TypeReference.Type); Assert.AreEqual("System.Void", md.TypeReference.Type);
Assert.AreEqual(0, md.Parameters.Count); Assert.AreEqual(0, md.Parameters.Count);
Assert.IsFalse(md.IsExtensionMethod); Assert.IsFalse(md.IsExtensionMethod);
Assert.IsTrue(md.Body.IsNull); Assert.IsTrue(md.Body.IsNull);
@ -39,7 +39,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
public void CSharpDefiningPartialMethodDeclarationTest() public void CSharpDefiningPartialMethodDeclarationTest()
{ {
MethodDeclaration md = ParseUtilCSharp.ParseTypeMember<MethodDeclaration>("partial void MyMethod();"); MethodDeclaration md = ParseUtilCSharp.ParseTypeMember<MethodDeclaration>("partial void MyMethod();");
Assert.AreEqual("void", md.TypeReference.Type); Assert.AreEqual("System.Void", md.TypeReference.Type);
Assert.AreEqual(0, md.Parameters.Count); Assert.AreEqual(0, md.Parameters.Count);
Assert.IsFalse(md.IsExtensionMethod); Assert.IsFalse(md.IsExtensionMethod);
Assert.IsTrue(md.Body.IsNull); Assert.IsTrue(md.Body.IsNull);
@ -50,7 +50,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
public void CSharpImplementingPartialMethodDeclarationTest() public void CSharpImplementingPartialMethodDeclarationTest()
{ {
MethodDeclaration md = ParseUtilCSharp.ParseTypeMember<MethodDeclaration>("partial void MyMethod() { }"); MethodDeclaration md = ParseUtilCSharp.ParseTypeMember<MethodDeclaration>("partial void MyMethod() { }");
Assert.AreEqual("void", md.TypeReference.Type); Assert.AreEqual("System.Void", md.TypeReference.Type);
Assert.AreEqual(0, md.Parameters.Count); Assert.AreEqual(0, md.Parameters.Count);
Assert.IsFalse(md.IsExtensionMethod); Assert.IsFalse(md.IsExtensionMethod);
Assert.IsFalse(md.Body.IsNull); Assert.IsFalse(md.Body.IsNull);
@ -94,7 +94,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
public void CSharpMethodWithUnnamedParameterDeclarationTest() public void CSharpMethodWithUnnamedParameterDeclarationTest()
{ {
MethodDeclaration md = ParseUtilCSharp.ParseTypeMember<MethodDeclaration>("void MyMethod(int) {} ", true); MethodDeclaration md = ParseUtilCSharp.ParseTypeMember<MethodDeclaration>("void MyMethod(int) {} ", true);
Assert.AreEqual("void", md.TypeReference.Type); Assert.AreEqual("System.Void", md.TypeReference.Type);
Assert.AreEqual(1, md.Parameters.Count); Assert.AreEqual(1, md.Parameters.Count);
//Assert.AreEqual("?", ((ParameterDeclarationExpression)md.Parameters[0]).ParameterName); //Assert.AreEqual("?", ((ParameterDeclarationExpression)md.Parameters[0]).ParameterName);
} }
@ -103,7 +103,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
public void CSharpGenericVoidMethodDeclarationTest() public void CSharpGenericVoidMethodDeclarationTest()
{ {
MethodDeclaration md = ParseUtilCSharp.ParseTypeMember<MethodDeclaration>("void MyMethod<T>(T a) {} "); MethodDeclaration md = ParseUtilCSharp.ParseTypeMember<MethodDeclaration>("void MyMethod<T>(T a) {} ");
Assert.AreEqual("void", md.TypeReference.Type); Assert.AreEqual("System.Void", md.TypeReference.Type);
Assert.AreEqual(1, md.Parameters.Count); Assert.AreEqual(1, md.Parameters.Count);
Assert.AreEqual("T", ((ParameterDeclarationExpression)md.Parameters[0]).TypeReference.Type); Assert.AreEqual("T", ((ParameterDeclarationExpression)md.Parameters[0]).TypeReference.Type);
Assert.AreEqual("a", ((ParameterDeclarationExpression)md.Parameters[0]).ParameterName); Assert.AreEqual("a", ((ParameterDeclarationExpression)md.Parameters[0]).ParameterName);
@ -170,7 +170,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
"; ";
TypeDeclaration td = ParseUtilCSharp.ParseGlobal<TypeDeclaration>(program); TypeDeclaration td = ParseUtilCSharp.ParseGlobal<TypeDeclaration>(program);
MethodDeclaration md = (MethodDeclaration)td.Children[0]; MethodDeclaration md = (MethodDeclaration)td.Children[0];
Assert.AreEqual("void", md.TypeReference.Type); Assert.AreEqual("System.Void", md.TypeReference.Type);
Assert.AreEqual(1, md.Parameters.Count); Assert.AreEqual(1, md.Parameters.Count);
Assert.AreEqual("T", ((ParameterDeclarationExpression)md.Parameters[0]).TypeReference.Type); Assert.AreEqual("T", ((ParameterDeclarationExpression)md.Parameters[0]).TypeReference.Type);
Assert.AreEqual("a", ((ParameterDeclarationExpression)md.Parameters[0]).ParameterName); Assert.AreEqual("a", ((ParameterDeclarationExpression)md.Parameters[0]).ParameterName);
@ -190,7 +190,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
"; ";
TypeDeclaration td = ParseUtilCSharp.ParseGlobal<TypeDeclaration>(program); TypeDeclaration td = ParseUtilCSharp.ParseGlobal<TypeDeclaration>(program);
MethodDeclaration md = (MethodDeclaration)td.Children[0]; MethodDeclaration md = (MethodDeclaration)td.Children[0];
Assert.AreEqual("void", md.TypeReference.Type); Assert.AreEqual("System.Void", md.TypeReference.Type);
Assert.AreEqual(0, md.Parameters.Count); Assert.AreEqual(0, md.Parameters.Count);
Assert.AreEqual(Modifiers.New, md.Modifier); Assert.AreEqual(Modifiers.New, md.Modifier);
} }
@ -199,7 +199,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
public void CSharpMethodImplementingInterfaceTest() public void CSharpMethodImplementingInterfaceTest()
{ {
MethodDeclaration md = ParseUtilCSharp.ParseTypeMember<MethodDeclaration>("int MyInterface.MyMethod() {} "); MethodDeclaration md = ParseUtilCSharp.ParseTypeMember<MethodDeclaration>("int MyInterface.MyMethod() {} ");
Assert.AreEqual("int", md.TypeReference.Type); Assert.AreEqual("System.Int32", md.TypeReference.Type);
Assert.AreEqual("MyInterface", md.InterfaceImplementations[0].InterfaceType.Type); Assert.AreEqual("MyInterface", md.InterfaceImplementations[0].InterfaceType.Type);
} }
@ -208,17 +208,17 @@ namespace ICSharpCode.NRefactory.Tests.Ast
public void CSharpMethodImplementingGenericInterfaceTest() public void CSharpMethodImplementingGenericInterfaceTest()
{ {
MethodDeclaration md = ParseUtilCSharp.ParseTypeMember<MethodDeclaration>("int MyInterface<string>.MyMethod() {} "); MethodDeclaration md = ParseUtilCSharp.ParseTypeMember<MethodDeclaration>("int MyInterface<string>.MyMethod() {} ");
Assert.AreEqual("int", md.TypeReference.Type); Assert.AreEqual("System.Int32", md.TypeReference.Type);
Assert.AreEqual("MyInterface", md.InterfaceImplementations[0].InterfaceType.Type); Assert.AreEqual("MyInterface", md.InterfaceImplementations[0].InterfaceType.Type);
Assert.AreEqual("System.String", md.InterfaceImplementations[0].InterfaceType.GenericTypes[0].SystemType); Assert.AreEqual("System.String", md.InterfaceImplementations[0].InterfaceType.GenericTypes[0].Type);
} }
[Test] [Test]
public void CSharpVoidMethodImplementingInterfaceTest() public void CSharpVoidMethodImplementingInterfaceTest()
{ {
MethodDeclaration md = ParseUtilCSharp.ParseTypeMember<MethodDeclaration>("void MyInterface.MyMethod() {} "); MethodDeclaration md = ParseUtilCSharp.ParseTypeMember<MethodDeclaration>("void MyInterface.MyMethod() {} ");
Assert.AreEqual("void", md.TypeReference.Type); Assert.AreEqual("System.Void", md.TypeReference.Type);
Assert.AreEqual("MyInterface", md.InterfaceImplementations[0].InterfaceType.Type); Assert.AreEqual("MyInterface", md.InterfaceImplementations[0].InterfaceType.Type);
} }
@ -227,10 +227,10 @@ namespace ICSharpCode.NRefactory.Tests.Ast
public void CSharpVoidMethodImplementingGenericInterfaceTest() public void CSharpVoidMethodImplementingGenericInterfaceTest()
{ {
MethodDeclaration md = ParseUtilCSharp.ParseTypeMember<MethodDeclaration>("void MyInterface<string>.MyMethod() {} "); MethodDeclaration md = ParseUtilCSharp.ParseTypeMember<MethodDeclaration>("void MyInterface<string>.MyMethod() {} ");
Assert.AreEqual("void", md.TypeReference.Type); Assert.AreEqual("System.Void", md.TypeReference.Type);
Assert.AreEqual("MyInterface", md.InterfaceImplementations[0].InterfaceType.Type); Assert.AreEqual("MyInterface", md.InterfaceImplementations[0].InterfaceType.Type);
Assert.AreEqual("System.String", md.InterfaceImplementations[0].InterfaceType.GenericTypes[0].SystemType); Assert.AreEqual("System.String", md.InterfaceImplementations[0].InterfaceType.GenericTypes[0].Type);
} }
[Test] [Test]
@ -254,7 +254,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
Assert.AreEqual("ToInt32", md.Name); Assert.AreEqual("ToInt32", md.Name);
Assert.IsTrue(md.IsExtensionMethod); Assert.IsTrue(md.IsExtensionMethod);
Assert.AreEqual("s", md.Parameters[0].ParameterName); Assert.AreEqual("s", md.Parameters[0].ParameterName);
Assert.AreEqual("string", md.Parameters[0].TypeReference.Type); Assert.AreEqual("System.String", md.Parameters[0].TypeReference.Type);
} }
[Test] [Test]
@ -266,7 +266,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
Assert.AreEqual("Print", md.Name); Assert.AreEqual("Print", md.Name);
Assert.IsTrue(md.IsExtensionMethod); Assert.IsTrue(md.IsExtensionMethod);
Assert.AreEqual("s", md.Parameters[0].ParameterName); Assert.AreEqual("s", md.Parameters[0].ParameterName);
Assert.AreEqual("string", md.Parameters[0].TypeReference.Type); Assert.AreEqual("System.String", md.Parameters[0].TypeReference.Type);
} }
[Test] [Test]
@ -316,7 +316,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
public void VBNetGenericFunctionMethodDeclarationTest() public void VBNetGenericFunctionMethodDeclarationTest()
{ {
MethodDeclaration md = ParseUtilVBNet.ParseTypeMember<MethodDeclaration>("function MyMethod(Of T)(a As T) As Double\nEnd Function"); MethodDeclaration md = ParseUtilVBNet.ParseTypeMember<MethodDeclaration>("function MyMethod(Of T)(a As T) As Double\nEnd Function");
Assert.AreEqual("Double", md.TypeReference.Type); Assert.AreEqual("System.Double", md.TypeReference.Type);
Assert.AreEqual(1, md.Parameters.Count); Assert.AreEqual(1, md.Parameters.Count);
Assert.AreEqual("T", ((ParameterDeclarationExpression)md.Parameters[0]).TypeReference.Type); Assert.AreEqual("T", ((ParameterDeclarationExpression)md.Parameters[0]).TypeReference.Type);
Assert.AreEqual("a", ((ParameterDeclarationExpression)md.Parameters[0]).ParameterName); Assert.AreEqual("a", ((ParameterDeclarationExpression)md.Parameters[0]).ParameterName);
@ -369,7 +369,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
// Assert.IsTrue(md.IsExtensionMethod); // Assert.IsTrue(md.IsExtensionMethod);
Assert.AreEqual("s", md.Parameters[0].ParameterName); Assert.AreEqual("s", md.Parameters[0].ParameterName);
Assert.AreEqual("String", md.Parameters[0].TypeReference.Type); Assert.AreEqual("System.String", md.Parameters[0].TypeReference.Type);
} }
[Test] [Test]
@ -400,7 +400,7 @@ End Interface
"; ";
TypeDeclaration td = ParseUtilVBNet.ParseGlobal<TypeDeclaration>(program); TypeDeclaration td = ParseUtilVBNet.ParseGlobal<TypeDeclaration>(program);
MethodDeclaration md = (MethodDeclaration)td.Children[0]; MethodDeclaration md = (MethodDeclaration)td.Children[0];
Assert.AreEqual("", md.TypeReference.Type); Assert.AreEqual("System.Void", md.TypeReference.Type);
Assert.AreEqual(1, md.Parameters.Count); Assert.AreEqual(1, md.Parameters.Count);
Assert.AreEqual("T", ((ParameterDeclarationExpression)md.Parameters[0]).TypeReference.Type); Assert.AreEqual("T", ((ParameterDeclarationExpression)md.Parameters[0]).TypeReference.Type);
Assert.AreEqual("a", ((ParameterDeclarationExpression)md.Parameters[0]).ParameterName); Assert.AreEqual("a", ((ParameterDeclarationExpression)md.Parameters[0]).ParameterName);

4
src/Libraries/NRefactory/Test/Parser/TypeLevel/OperatorDeclarationTests.cs

@ -22,7 +22,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
Assert.IsTrue(od.IsConversionOperator); Assert.IsTrue(od.IsConversionOperator);
Assert.AreEqual(1, od.Parameters.Count); Assert.AreEqual(1, od.Parameters.Count);
Assert.AreEqual(ConversionType.Implicit, od.ConversionType); Assert.AreEqual(ConversionType.Implicit, od.ConversionType);
Assert.AreEqual("double", od.TypeReference.Type); Assert.AreEqual("System.Double", od.TypeReference.Type);
} }
[Test] [Test]
@ -32,7 +32,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
Assert.IsTrue(od.IsConversionOperator); Assert.IsTrue(od.IsConversionOperator);
Assert.AreEqual(1, od.Parameters.Count); Assert.AreEqual(1, od.Parameters.Count);
Assert.AreEqual(ConversionType.Explicit, od.ConversionType); Assert.AreEqual(ConversionType.Explicit, od.ConversionType);
Assert.AreEqual("double", od.TypeReference.Type); Assert.AreEqual("System.Double", od.TypeReference.Type);
} }
[Test] [Test]

2
src/Libraries/NRefactory/Test/Parser/TypeLevel/PropertyDeclarationTests.cs

@ -103,7 +103,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast
Assert.IsTrue(!pd.HasSetRegion); Assert.IsTrue(!pd.HasSetRegion);
Assert.AreEqual("MyInterface", pd.InterfaceImplementations[0].InterfaceType.Type); Assert.AreEqual("MyInterface", pd.InterfaceImplementations[0].InterfaceType.Type);
Assert.AreEqual("System.String", pd.InterfaceImplementations[0].InterfaceType.GenericTypes[0].SystemType); Assert.AreEqual("System.String", pd.InterfaceImplementations[0].InterfaceType.GenericTypes[0].Type);
} }
#endregion #endregion

3
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/CSharpToVBNetConvertVisitor.cs

@ -484,7 +484,8 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
public override object VisitTypeReference(TypeReference typeReference, object data) public override object VisitTypeReference(TypeReference typeReference, object data)
{ {
while (typeReference.PointerNestingLevel > 0) { while (typeReference.PointerNestingLevel > 0) {
TypeReference tr = new TypeReference(typeReference.Type, typeReference.SystemType) { TypeReference tr = new TypeReference(typeReference.Type) {
IsKeyword = typeReference.IsKeyword,
IsGlobal = typeReference.IsGlobal, IsGlobal = typeReference.IsGlobal,
}; };
tr.GenericTypes.AddRange(typeReference.GenericTypes); tr.GenericTypes.AddRange(typeReference.GenericTypes);

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

@ -355,7 +355,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
return ((NamespaceResolveResult)rr).Name + "." + fieldReferenceExpression.MemberName; return ((NamespaceResolveResult)rr).Name + "." + fieldReferenceExpression.MemberName;
} }
} else if (expr is TypeReferenceExpression) { } else if (expr is TypeReferenceExpression) {
return (expr as TypeReferenceExpression).TypeReference.SystemType; return (expr as TypeReferenceExpression).TypeReference.Type;
} }
return null; return null;
} }

2
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/ResolveVisitor.cs

@ -527,7 +527,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
return null; return null;
PointerReturnType type = targetRR.ResolvedType.CastToDecoratingReturnType<PointerReturnType>(); PointerReturnType type = targetRR.ResolvedType.CastToDecoratingReturnType<PointerReturnType>();
if (type != null) { if (type != null) {
return resolver.ResolveMember(type.BaseType, pointerReferenceExpression.Identifier, return resolver.ResolveMember(type.BaseType, pointerReferenceExpression.MemberName,
pointerReferenceExpression.TypeArguments, pointerReferenceExpression.TypeArguments,
NRefactoryResolver.IsInvoked(pointerReferenceExpression), NRefactoryResolver.IsInvoked(pointerReferenceExpression),
true, null true, null

22
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/TypeVisitor.cs

@ -42,14 +42,14 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
IReturnType t = null; IReturnType t = null;
if (callingClass != null && !reference.IsGlobal) { if (callingClass != null && !reference.IsGlobal) {
foreach (ITypeParameter tp in callingClass.TypeParameters) { foreach (ITypeParameter tp in callingClass.TypeParameters) {
if (languageProperties.NameComparer.Equals(tp.Name, reference.SystemType)) { if (languageProperties.NameComparer.Equals(tp.Name, reference.Type)) {
t = new GenericReturnType(tp); t = new GenericReturnType(tp);
break; break;
} }
} }
if (t == null && callingMember is IMethod && (callingMember as IMethod).TypeParameters != null) { if (t == null && callingMember is IMethod && (callingMember as IMethod).TypeParameters != null) {
foreach (ITypeParameter tp in (callingMember as IMethod).TypeParameters) { foreach (ITypeParameter tp in (callingMember as IMethod).TypeParameters) {
if (languageProperties.NameComparer.Equals(tp.Name, reference.SystemType)) { if (languageProperties.NameComparer.Equals(tp.Name, reference.Type)) {
t = new GenericReturnType(tp); t = new GenericReturnType(tp);
break; break;
} }
@ -57,27 +57,27 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
} }
} }
if (t == null) { if (t == null) {
if (reference.Type != reference.SystemType) { if (reference.Type != reference.Type) {
// keyword-type like void, int, string etc. // keyword-type like void, int, string etc.
IClass c = projectContent.GetClass(reference.SystemType, 0); IClass c = projectContent.GetClass(reference.Type, 0);
if (c != null) if (c != null)
t = c.DefaultReturnType; t = c.DefaultReturnType;
else else
t = new GetClassReturnType(projectContent, reference.SystemType, 0); t = new GetClassReturnType(projectContent, reference.Type, 0);
} else { } else {
int typeParameterCount = reference.GenericTypes.Count; int typeParameterCount = reference.GenericTypes.Count;
if (useLazyReturnType) { if (useLazyReturnType) {
if (reference.IsGlobal) if (reference.IsGlobal || reference.IsKeyword)
t = new GetClassReturnType(projectContent, reference.SystemType, typeParameterCount); t = new GetClassReturnType(projectContent, reference.Type, typeParameterCount);
else if (callingClass != null) else if (callingClass != null)
t = new SearchClassReturnType(projectContent, callingClass, caretLine, caretColumn, reference.SystemType, typeParameterCount); t = new SearchClassReturnType(projectContent, callingClass, caretLine, caretColumn, reference.Type, typeParameterCount);
} else { } else {
IClass c; IClass c;
if (reference.IsGlobal) { if (reference.IsGlobal || reference.IsKeyword) {
c = projectContent.GetClass(reference.SystemType, typeParameterCount); c = projectContent.GetClass(reference.Type, typeParameterCount);
t = (c != null) ? c.DefaultReturnType : null; t = (c != null) ? c.DefaultReturnType : null;
} else if (callingClass != null) { } else if (callingClass != null) {
t = projectContent.SearchType(new SearchTypeRequest(reference.SystemType, typeParameterCount, callingClass, caretLine, caretColumn)).Result; t = projectContent.SearchType(new SearchTypeRequest(reference.Type, typeParameterCount, callingClass, caretLine, caretColumn)).Result;
} }
if (t == null) { if (t == null) {
return null; return null;

2
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/VBNetToCSharpConvertVisitor.cs

@ -602,7 +602,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
{ {
if (resolver.CompilationUnit == null) return null; if (resolver.CompilationUnit == null) return null;
if (tr.IsNull) return null; if (tr.IsNull) return null;
IReturnType rt = resolver.SearchType(tr.SystemType, tr.GenericTypes.Count, loc); IReturnType rt = resolver.SearchType(tr.Type, tr.GenericTypes.Count, loc);
if (rt != null) { if (rt != null) {
IClass c = rt.GetUnderlyingClass(); IClass c = rt.GetUnderlyingClass();
if (c != null) { if (c != null) {

30
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Refactoring/CodeGenerator.cs

@ -44,7 +44,9 @@ namespace ICSharpCode.SharpDevelop.Dom.Refactoring
if (returnType is NullReturnType) return TypeReference.Null; if (returnType is NullReturnType) return TypeReference.Null;
TypeReference typeRef; TypeReference typeRef;
if (context != null && CanUseShortTypeName(returnType, context)) if (IsPrimitiveType(returnType))
typeRef = new TypeReference(returnType.FullyQualifiedName, true);
else if (context != null && CanUseShortTypeName(returnType, context))
typeRef = new TypeReference(returnType.Name); typeRef = new TypeReference(returnType.Name);
else else
typeRef = new TypeReference(returnType.FullyQualifiedName); typeRef = new TypeReference(returnType.FullyQualifiedName);
@ -63,6 +65,11 @@ namespace ICSharpCode.SharpDevelop.Dom.Refactoring
return typeRef; return typeRef;
} }
static bool IsPrimitiveType(IReturnType returnType)
{
return TypeReference.PrimitiveTypesCSharpReverse.ContainsKey(returnType.FullyQualifiedName);
}
/// <summary> /// <summary>
/// Returns true if the short name of a type is valid in the given context. /// Returns true if the short name of a type is valid in the given context.
/// Returns false for primitive types because they should be passed around using their /// Returns false for primitive types because they should be passed around using their
@ -71,25 +78,6 @@ namespace ICSharpCode.SharpDevelop.Dom.Refactoring
/// </summary> /// </summary>
public static bool CanUseShortTypeName(IReturnType returnType, ClassFinder context) public static bool CanUseShortTypeName(IReturnType returnType, ClassFinder context)
{ {
switch (returnType.FullyQualifiedName) {
case "System.Void":
case "System.String":
case "System.Char":
case "System.Boolean":
case "System.Single":
case "System.Double":
case "System.Decimal":
case "System.Byte":
case "System.SByte":
case "System.Int16":
case "System.Int32":
case "System.Int64":
case "System.UInt16":
case "System.UInt32":
case "System.UInt64":
// don't use short name -> output visitor will use the instrinsic name
return false;
}
int typeArgumentCount = (returnType.IsConstructedReturnType) ? returnType.CastToConstructedReturnType().TypeArguments.Count : 0; int typeArgumentCount = (returnType.IsConstructedReturnType) ? returnType.CastToConstructedReturnType().TypeArguments.Count : 0;
IReturnType typeInTargetContext = context.SearchType(returnType.Name, typeArgumentCount); IReturnType typeInTargetContext = context.SearchType(returnType.Name, typeArgumentCount);
return typeInTargetContext != null && typeInTargetContext.FullyQualifiedName == returnType.FullyQualifiedName; return typeInTargetContext != null && typeInTargetContext.FullyQualifiedName == returnType.FullyQualifiedName;
@ -611,7 +599,7 @@ namespace ICSharpCode.SharpDevelop.Dom.Refactoring
MethodDeclaration method = node as MethodDeclaration; MethodDeclaration method = node as MethodDeclaration;
if (method != null) { if (method != null) {
method.Body.Children.Clear(); method.Body.Children.Clear();
if (method.TypeReference.SystemType == "System.Void") { if (method.TypeReference.Type == "System.Void") {
method.Body.AddChild(new ExpressionStatement(CreateForwardingMethodCall(method))); method.Body.AddChild(new ExpressionStatement(CreateForwardingMethodCall(method)));
} else { } else {
method.Body.AddChild(new ReturnStatement(CreateForwardingMethodCall(method))); method.Body.AddChild(new ReturnStatement(CreateForwardingMethodCall(method)));

2
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Refactoring/NRefactoryRefactoringProvider.cs

@ -368,7 +368,7 @@ namespace ICSharpCode.SharpDevelop.Dom.Refactoring
public PossibleTypeReference(TypeReference tr) public PossibleTypeReference(TypeReference tr)
{ {
this.Name = tr.SystemType; this.Name = tr.Type;
this.TypeParameterCount = tr.GenericTypes.Count; this.TypeParameterCount = tr.GenericTypes.Count;
} }

Loading…
Cancel
Save