diff --git a/src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConvertVisitor.cs b/src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConvertVisitor.cs index beeebfe303..9db8e25a6a 100644 --- a/src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConvertVisitor.cs +++ b/src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConvertVisitor.cs @@ -227,12 +227,12 @@ namespace NRefactoryToBooConverter return null; B.TypeReference r; 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) { ((B.GenericTypeReference)r).GenericArguments.Add(ConvertTypeReference(ta)); } } else { - r = new B.SimpleTypeReference(GetLexicalInfo(t), GetIntrinsicTypeName(t.SystemType)); + r = new B.SimpleTypeReference(GetLexicalInfo(t), GetIntrinsicTypeName(t.Type)); } if (t.IsArrayType) { for (int i = t.RankSpecifier.Length - 1; i >= 0; --i) { diff --git a/src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConvertVisitorExpressions.cs b/src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConvertVisitorExpressions.cs index d18a47d675..ed4ba79957 100644 --- a/src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConvertVisitorExpressions.cs +++ b/src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConvertVisitorExpressions.cs @@ -364,7 +364,7 @@ namespace NRefactoryToBooConverter throw new ApplicationException("ObjectCreateExpression cannot be called with an ArrayType"); } // 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]); B.MethodInvocationExpression mie = new B.MethodInvocationExpression(GetLexicalInfo(objectCreateExpression), MakeReferenceExpression(t)); diff --git a/src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConvertVisitorTypeMembers.cs b/src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConvertVisitorTypeMembers.cs index 9959498d5e..c7038dbc62 100644 --- a/src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConvertVisitorTypeMembers.cs +++ b/src/AddIns/BackendBindings/Boo/NRefactoryToBooConverter/Project/ConvertVisitorTypeMembers.cs @@ -105,7 +105,7 @@ namespace NRefactoryToBooConverter m.ReturnType = ConvertTypeReference(methodDeclaration.TypeReference); m.Body = ConvertMethodBlock(methodDeclaration.Body); 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; } diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/NRefactoryToPythonConverter.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/NRefactoryToPythonConverter.cs index f2827054ae..c7f359e760 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/NRefactoryToPythonConverter.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/NRefactoryToPythonConverter.cs @@ -729,7 +729,7 @@ namespace ICSharpCode.PythonBinding { // Create variable declaration. VariableDeclaration variableDeclaration = localVariableDeclaration.Variables[0]; - string variableType = localVariableDeclaration.TypeReference.SystemType; + string variableType = localVariableDeclaration.TypeReference.Type; string variableName = variableDeclaration.Name; CodeVariableDeclarationStatement codeVariableDeclarationStatement = new CodeVariableDeclarationStatement(variableType, variableName); diff --git a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerLoader/NRefactoryDesignerLoader.cs b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerLoader/NRefactoryDesignerLoader.cs index 5011fbc33a..50e5018bc2 100644 --- a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerLoader/NRefactoryDesignerLoader.cs +++ b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerLoader/NRefactoryDesignerLoader.cs @@ -255,7 +255,7 @@ namespace ICSharpCode.FormsDesigner { if (type == null) return; - if (type.SystemType != type.Type) + if (type.Type != type.Type) return; foreach (TypeReference tref in type.GenericTypes) { FixTypeReference(tref, location, domCu); diff --git a/src/Libraries/NRefactory/NRefactoryASTGenerator/AST/Expressions.cs b/src/Libraries/NRefactory/NRefactoryASTGenerator/AST/Expressions.cs index ae2e5ab5c5..9665d7ae13 100644 --- a/src/Libraries/NRefactory/NRefactoryASTGenerator/AST/Expressions.cs +++ b/src/Libraries/NRefactory/NRefactoryASTGenerator/AST/Expressions.cs @@ -114,12 +114,13 @@ namespace NRefactoryASTGenerator.Ast public MemberReferenceExpression(Expression targetObject, string memberName) {} } + [IncludeMember("[Obsolete] public string Identifier { get { return MemberName; } set { MemberName = value; } }")] class PointerReferenceExpression : Expression { Expression targetObject; - string identifier; + string memberName; List typeArguments; - public PointerReferenceExpression(Expression targetObject, string identifier) {} + public PointerReferenceExpression(Expression targetObject, string memberName) {} } class IdentifierExpression : Expression { @@ -151,7 +152,7 @@ namespace NRefactoryASTGenerator.Ast 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 { TypeReference typeReference; diff --git a/src/Libraries/NRefactory/Project/Src/Ast/Generated.cs b/src/Libraries/NRefactory/Project/Src/Ast/Generated.cs index de4523cb76..02db5f41e1 100644 --- a/src/Libraries/NRefactory/Project/Src/Ast/Generated.cs +++ b/src/Libraries/NRefactory/Project/Src/Ast/Generated.cs @@ -2299,12 +2299,11 @@ namespace ICSharpCode.NRefactory.Ast { elseIfSections = new List(); } - - public IfElseStatement(Expression condition, Statement trueStatement) - : this(condition) { - this.trueStatement.Add(Statement.CheckNull(trueStatement)); - if (trueStatement != null) trueStatement.Parent = this; + public bool HasElseIfSections { + get { + return elseIfSections.Count > 0; } + } public bool HasElseStatements { get { @@ -2312,11 +2311,12 @@ namespace ICSharpCode.NRefactory.Ast { } } - public bool HasElseIfSections { - get { - return elseIfSections.Count > 0; + + public IfElseStatement(Expression condition, Statement trueStatement) + : this(condition) { + this.trueStatement.Add(Statement.CheckNull(trueStatement)); + if (trueStatement != null) trueStatement.Parent = this; } - } public IfElseStatement(Expression condition, Statement trueStatement, Statement falseStatement) @@ -3256,7 +3256,7 @@ public Location ExtendedEndLocation { get; set; } Expression targetObject; - string identifier; + string memberName; List typeArguments; @@ -3270,12 +3270,12 @@ public Location ExtendedEndLocation { get; set; } } } - public string Identifier { + public string MemberName { get { - return identifier; + return memberName; } 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; - Identifier = identifier; + MemberName = memberName; typeArguments = new List(); } +[Obsolete] public string Identifier { get { return MemberName; } set { MemberName = value; } } + public override object AcceptVisitor(IAstVisitor visitor, object data) { return visitor.VisitPointerReferenceExpression(this, data); } 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; } -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) { return visitor.VisitTypeReferenceExpression(this, data); diff --git a/src/Libraries/NRefactory/Project/Src/Ast/TypeReference.cs b/src/Libraries/NRefactory/Project/Src/Ast/TypeReference.cs index 3f1f3ac854..f304146241 100644 --- a/src/Libraries/NRefactory/Project/Src/Ast/TypeReference.cs +++ b/src/Libraries/NRefactory/Project/Src/Ast/TypeReference.cs @@ -9,6 +9,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; +using System.Runtime.InteropServices; using System.Text; namespace ICSharpCode.NRefactory.Ast @@ -20,11 +21,9 @@ namespace ICSharpCode.NRefactory.Ast public static readonly TypeReference NewConstraint = new TypeReference("constraint: new"); string type = ""; - string systemType = ""; int pointerNestingLevel; int[] rankSpecifier; List genericTypes = new List(); - bool isGlobal; #region Static primitive type list static Dictionary types = new Dictionary(); @@ -129,7 +128,7 @@ namespace ICSharpCode.NRefactory.Ast public virtual TypeReference Clone() { - TypeReference c = new TypeReference(type, systemType); + TypeReference c = new TypeReference(type); CopyFields(this, c); return c; } @@ -150,7 +149,8 @@ namespace ICSharpCode.NRefactory.Ast foreach (TypeReference r in from.genericTypes) { to.genericTypes.Add(r.Clone()); } - to.isGlobal = from.isGlobal; + to.IsGlobal = from.IsGlobal; + to.IsKeyword = from.IsKeyword; } public string Type { @@ -159,8 +159,7 @@ namespace ICSharpCode.NRefactory.Ast } set { Debug.Assert(value != null); - type = value; - systemType = GetSystemType(type); + type = value ?? "?"; } } @@ -186,9 +185,10 @@ namespace ICSharpCode.NRefactory.Ast } } + [Obsolete("Use 'Type' instead - it now contains the SystemType for primitive types.")] public string SystemType { get { - return systemType; + return this.Type; } } @@ -251,12 +251,14 @@ namespace ICSharpCode.NRefactory.Ast /// Gets/Sets if the type reference had a "global::" prefix. /// public bool IsGlobal { - get { - return isGlobal; - } - set { - isGlobal = value; - } + get; set; + } + + /// + /// Gets/Sets if the type reference was using a language keyword. + /// + public bool IsKeyword { + get; set; } public TypeReference(string type) @@ -264,10 +266,17 @@ namespace ICSharpCode.NRefactory.Ast 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) { - this.type = type; - this.systemType = systemType; + this.Type = systemType; + this.IsKeyword = type != systemType; + } + + public TypeReference(string type, bool isKeyword) + { + this.Type = type; + this.IsKeyword = isKeyword; } public TypeReference(string type, List genericTypes) : this(type) @@ -289,7 +298,6 @@ namespace ICSharpCode.NRefactory.Ast { Debug.Assert(type != null); this.type = type; - this.systemType = GetSystemType(type); this.pointerNestingLevel = pointerNestingLevel; this.rankSpecifier = rankSpecifier; if (genericTypes != null) { @@ -338,7 +346,9 @@ namespace ICSharpCode.NRefactory.Ast if (a == null || b == null) return false; if (a is InnerClassTypeReference) a = ((InnerClassTypeReference)a).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.IsArrayType != b.IsArrayType) return false; if (a.IsArrayType) { diff --git a/src/Libraries/NRefactory/Project/Src/AstBuilder/ExpressionBuilder.cs b/src/Libraries/NRefactory/Project/Src/AstBuilder/ExpressionBuilder.cs index 59856ff762..4c0be34acd 100644 --- a/src/Libraries/NRefactory/Project/Src/AstBuilder/ExpressionBuilder.cs +++ b/src/Libraries/NRefactory/Project/Src/AstBuilder/ExpressionBuilder.cs @@ -57,7 +57,7 @@ namespace ICSharpCode.NRefactory.AstBuilder public static Expression CreateDefaultValueForType(TypeReference type) { if (type != null && !type.IsArrayType) { - switch (type.SystemType) { + switch (type.Type) { case "System.SByte": case "System.Byte": case "System.Int16": diff --git a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs index 7206fc809e..6210e5ebf3 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs @@ -234,13 +234,13 @@ out type, false); out name); #line 591 "cs.ATG" - type = new TypeReference(name); + type = new TypeReference(name, true); } else if (la.kind == 123) { lexer.NextToken(); Expect(6); #line 592 "cs.ATG" - pointer = 1; type = new TypeReference("void"); + pointer = 1; type = new TypeReference("System.Void", true); } else SynErr(147); if (la.kind == 12) { NullableQuestionMark( @@ -849,7 +849,7 @@ templates); out name); #line 436 "cs.ATG" - newType.BaseTypes.Add(new TypeReference(name)); + newType.BaseTypes.Add(new TypeReference(name, true)); } #line 438 "cs.ATG" @@ -877,7 +877,7 @@ NotVoidPointer()) { Expect(123); #line 448 "cs.ATG" - delegateDeclr.ReturnType = new TypeReference("void", 0, null); + delegateDeclr.ReturnType = new TypeReference("System.Void", true); } else if (StartOf(10)) { Type( #line 449 "cs.ATG" @@ -1159,63 +1159,63 @@ out string name) { lexer.NextToken(); #line 694 "cs.ATG" - name = "sbyte"; + name = "System.SByte"; break; } case 54: { lexer.NextToken(); #line 695 "cs.ATG" - name = "byte"; + name = "System.Byte"; break; } case 104: { lexer.NextToken(); #line 696 "cs.ATG" - name = "short"; + name = "System.Int16"; break; } case 120: { lexer.NextToken(); #line 697 "cs.ATG" - name = "ushort"; + name = "System.UInt16"; break; } case 82: { lexer.NextToken(); #line 698 "cs.ATG" - name = "int"; + name = "System.Int32"; break; } case 116: { lexer.NextToken(); #line 699 "cs.ATG" - name = "uint"; + name = "System.UInt32"; break; } case 87: { lexer.NextToken(); #line 700 "cs.ATG" - name = "long"; + name = "System.Int64"; break; } case 117: { lexer.NextToken(); #line 701 "cs.ATG" - name = "ulong"; + name = "System.UInt64"; break; } case 57: { lexer.NextToken(); #line 702 "cs.ATG" - name = "char"; + name = "System.Char"; break; } default: SynErr(156); break; @@ -1343,12 +1343,12 @@ out r, canBeUnbound); lexer.NextToken(); #line 688 "cs.ATG" - typeRef = new TypeReference("object"); + typeRef = new TypeReference("System.Object", true); } else if (la.kind == 108) { lexer.NextToken(); #line 689 "cs.ATG" - typeRef = new TypeReference("string"); + typeRef = new TypeReference("System.String", true); } else SynErr(159); } @@ -1683,7 +1683,7 @@ p); MethodDeclaration methodDeclaration = new MethodDeclaration { Name = qualident, Modifier = m.Modifier, - TypeReference = new TypeReference("void"), + TypeReference = new TypeReference("System.Void", true), Parameters = p, Attributes = attributes, StartLocation = m.GetDeclarationLocation(startPos), @@ -2269,7 +2269,7 @@ templates); #line 1073 "cs.ATG" 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, StartLocation = startLocation, EndLocation = t.EndLocation }; @@ -2437,13 +2437,13 @@ out type, canBeUnbound); out name); #line 564 "cs.ATG" - type = new TypeReference(name); + type = new TypeReference(name, true); } else if (la.kind == 123) { lexer.NextToken(); Expect(6); #line 565 "cs.ATG" - pointer = 1; type = new TypeReference("void"); + pointer = 1; type = new TypeReference("System.Void", true); } else SynErr(178); #line 566 "cs.ATG" @@ -2503,22 +2503,22 @@ out name); lexer.NextToken(); #line 607 "cs.ATG" - name = "float"; + name = "System.Single"; } else if (la.kind == 66) { lexer.NextToken(); #line 608 "cs.ATG" - name = "double"; + name = "System.Double"; } else if (la.kind == 62) { lexer.NextToken(); #line 609 "cs.ATG" - name = "decimal"; + name = "System.Decimal"; } else if (la.kind == 52) { lexer.NextToken(); #line 610 "cs.ATG" - name = "bool"; + name = "System.Boolean"; } else SynErr(180); } @@ -2532,7 +2532,7 @@ ref TypeReference typeRef) { #line 2283 "cs.ATG" 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(); #line 1856 "cs.ATG" - val = "bool"; + val = "System.Boolean"; break; } case 54: { lexer.NextToken(); #line 1857 "cs.ATG" - val = "byte"; + val = "System.Byte"; break; } case 57: { lexer.NextToken(); #line 1858 "cs.ATG" - val = "char"; + val = "System.Char"; break; } case 62: { lexer.NextToken(); #line 1859 "cs.ATG" - val = "decimal"; + val = "System.Decimal"; break; } case 66: { lexer.NextToken(); #line 1860 "cs.ATG" - val = "double"; + val = "System.Double"; break; } case 75: { lexer.NextToken(); #line 1861 "cs.ATG" - val = "float"; + val = "System.Single"; break; } case 82: { lexer.NextToken(); #line 1862 "cs.ATG" - val = "int"; + val = "System.Int32"; break; } case 87: { lexer.NextToken(); #line 1863 "cs.ATG" - val = "long"; + val = "System.Int64"; break; } case 91: { lexer.NextToken(); #line 1864 "cs.ATG" - val = "object"; + val = "System.Object"; break; } case 102: { lexer.NextToken(); #line 1865 "cs.ATG" - val = "sbyte"; + val = "System.SByte"; break; } case 104: { lexer.NextToken(); #line 1866 "cs.ATG" - val = "short"; + val = "System.Int16"; break; } case 108: { lexer.NextToken(); #line 1867 "cs.ATG" - val = "string"; + val = "System.String"; break; } case 116: { lexer.NextToken(); #line 1868 "cs.ATG" - val = "uint"; + val = "System.UInt32"; break; } case 117: { lexer.NextToken(); #line 1869 "cs.ATG" - val = "ulong"; + val = "System.UInt64"; break; } case 120: { lexer.NextToken(); #line 1870 "cs.ATG" - val = "ushort"; + val = "System.UInt16"; break; } case 123: { lexer.NextToken(); #line 1871 "cs.ATG" - val = "void"; + val = "System.Void"; break; } } MemberAccess( #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) { lexer.NextToken(); @@ -4554,7 +4554,7 @@ NotVoidPointer()) { Expect(123); #line 1885 "cs.ATG" - type = new TypeReference("void"); + type = new TypeReference("System.Void", true); } else if (StartOf(10)) { TypeWithRestriction( #line 1886 "cs.ATG" diff --git a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG index d1cda481a7..b469fde990 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG +++ b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG @@ -433,7 +433,7 @@ TypeDecl attributes> newType.Type = Types.Enum; .) Identifier (. newType.Name = t.val; .) - [ ":" IntegralType (. newType.BaseTypes.Add(new TypeReference(name)); .) + [ ":" IntegralType (. newType.BaseTypes.Add(new TypeReference(name, true)); .) ] (. newType.BodyStartLocation = t.EndLocation; .) EnumBody @@ -445,7 +445,7 @@ TypeDecl attributes> templates = delegateDeclr.Templates; 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 (. delegateDeclr.ReturnType = type; .) ) Identifier (. delegateDeclr.Name = t.val; .) @@ -561,8 +561,8 @@ TypeWithRestriction - | SimpleType (. type = new TypeReference(name); .) - | "void" "*" (. pointer = 1; type = new TypeReference("void"); .) + | SimpleType (. type = new TypeReference(name, true); .) + | "void" "*" (. pointer = 1; type = new TypeReference("System.Void", true); .) ) (. List r = new List(); .) [ IF (allowNullable && la.kind == Tokens.Question) NullableQuestionMark ] @@ -588,8 +588,8 @@ NonArrayType .) = ( ClassType - | SimpleType (. type = new TypeReference(name); .) - | "void" "*" (. pointer = 1; type = new TypeReference("void"); .) + | SimpleType (. type = new TypeReference(name, true); .) + | "void" "*" (. pointer = 1; type = new TypeReference("System.Void", true); .) ) [ NullableQuestionMark ] @@ -604,10 +604,10 @@ SimpleType (. name = String.Empty; .) = IntegralType - | "float" (. name = "float"; .) - | "double" (. name = "double"; .) - | "decimal" (. name = "decimal"; .) - | "bool" (. name = "bool"; .) + | "float" (. name = "System.Single"; .) + | "double" (. name = "System.Double"; .) + | "decimal" (. name = "System.Decimal"; .) + | "bool" (. name = "System.Boolean"; .) . @@ -685,21 +685,21 @@ ClassType (. TypeReference r; typeRef = null; .) = TypeName (. typeRef = r; .) - | "object" (. typeRef = new TypeReference("object"); .) - | "string" (. typeRef = new TypeReference("string"); .) + | "object" (. typeRef = new TypeReference("System.Object", true); .) + | "string" (. typeRef = new TypeReference("System.String", true); .) . IntegralType (. name = ""; .) = - "sbyte" (. name = "sbyte"; .) - | "byte" (. name = "byte"; .) - | "short" (. name = "short"; .) - | "ushort" (. name = "ushort"; .) - | "int" (. name = "int"; .) - | "uint" (. name = "uint"; .) - | "long" (. name = "long"; .) - | "ulong" (. name = "ulong"; .) - | "char" (. name = "char"; .) + "sbyte" (. name = "System.SByte"; .) + | "byte" (. name = "System.Byte"; .) + | "short" (. name = "System.Int16"; .) + | "ushort" (. name = "System.UInt16"; .) + | "int" (. name = "System.Int32"; .) + | "uint" (. name = "System.UInt32"; .) + | "long" (. name = "System.Int64"; .) + | "ulong" (. name = "System.UInt64"; .) + | "char" (. name = "System.Char"; .) . MemberModifiers @@ -770,7 +770,7 @@ StructMemberDecl attributes> (. MethodDeclaration methodDeclaration = new MethodDeclaration { Name = qualident, Modifier = m.Modifier, - TypeReference = new TypeReference("void"), + TypeReference = new TypeReference("System.Void", true), Parameters = p, Attributes = attributes, StartLocation = m.GetDeclarationLocation(startPos), @@ -1071,7 +1071,7 @@ InterfaceMemberDecl { TypeParameterConstraintsClause } ";" (. 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, StartLocation = startLocation, EndLocation = t.EndLocation }; @@ -1853,24 +1853,24 @@ PrimaryExpr | /*--- predefined type member access: */ (. string val = null; .) - ( "bool" (. val = "bool"; .) - | "byte" (. val = "byte"; .) - | "char" (. val = "char"; .) - | "decimal" (. val = "decimal"; .) - | "double" (. val = "double"; .) - | "float" (. val = "float"; .) - | "int" (. val = "int"; .) - | "long" (. val = "long"; .) - | "object" (. val = "object"; .) - | "sbyte" (. val = "sbyte"; .) - | "short" (. val = "short"; .) - | "string" (. val = "string"; .) - | "uint" (. val = "uint"; .) - | "ulong" (. val = "ulong"; .) - | "ushort" (. val = "ushort"; .) - | "void" (. val = "void"; .) + ( "bool" (. val = "System.Boolean"; .) + | "byte" (. val = "System.Byte"; .) + | "char" (. val = "System.Char"; .) + | "decimal" (. val = "System.Decimal"; .) + | "double" (. val = "System.Double"; .) + | "float" (. val = "System.Single"; .) + | "int" (. val = "System.Int32"; .) + | "long" (. val = "System.Int64"; .) + | "object" (. val = "System.Object"; .) + | "sbyte" (. val = "System.SByte"; .) + | "short" (. val = "System.Int16"; .) + | "string" (. val = "System.String"; .) + | "uint" (. val = "System.UInt32"; .) + | "ulong" (. val = "System.UInt64"; .) + | "ushort" (. val = "System.UInt16"; .) + | "void" (. val = "System.Void"; .) ) - MemberAccess + MemberAccess /*--- this access: */ | "this" (. pexpr = new ThisReferenceExpression(); .) @@ -1882,7 +1882,7 @@ PrimaryExpr | "typeof" "(" ( - IF (NotVoidPointer()) "void" (. type = new TypeReference("void"); .) + IF (NotVoidPointer()) "void" (. type = new TypeReference("System.Void", true); .) | TypeWithRestriction ) ")" (. pexpr = new TypeOfExpression(type); .) @@ -2281,7 +2281,7 @@ NullableQuestionMark "?" (. if (typeRef != null) typeArguments.Add(typeRef); - typeRef = new TypeReference("System.Nullable", typeArguments); + typeRef = new TypeReference("System.Nullable", typeArguments) { IsKeyword = true }; .) . diff --git a/src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs b/src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs index 9ff7b39410..2d640ea5fb 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs +++ b/src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs @@ -755,7 +755,7 @@ newType); #line 526 "VBNET.ATG" m.Check(Modifiers.VBDelegates); 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); List p = new List(); @@ -1151,14 +1151,14 @@ out nestedTypeRef, canBeUnbound); lexer.NextToken(); #line 2448 "VBNET.ATG" - typeref = new TypeReference("System.Object"); + typeref = new TypeReference("System.Object", true); if (la.kind == 21) { lexer.NextToken(); #line 2452 "VBNET.ATG" List typeArguments = new List(1); if (typeref != null) typeArguments.Add(typeref); - typeref = new TypeReference("System.Nullable", typeArguments); + typeref = new TypeReference("System.Nullable", typeArguments) { IsKeyword = true }; } } else if (StartOf(11)) { @@ -1167,14 +1167,14 @@ out nestedTypeRef, canBeUnbound); out name); #line 2458 "VBNET.ATG" - typeref = new TypeReference(name); + typeref = new TypeReference(name, true); if (la.kind == 21) { lexer.NextToken(); #line 2462 "VBNET.ATG" List typeArguments = new List(1); if (typeref != null) typeArguments.Add(typeref); - typeref = new TypeReference("System.Nullable", typeArguments); + typeref = new TypeReference("System.Nullable", typeArguments) { IsKeyword = true }; } } else SynErr(236); @@ -1501,7 +1501,7 @@ IsMustOverride(m)) { methodDeclaration = new MethodDeclaration { Name = name, Modifier = m.Modifier, Parameters = p, Attributes = attributes, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endLocation, - TypeReference = new TypeReference("", "System.Void"), + TypeReference = new TypeReference("System.Void", true), Templates = templates, HandlesClause = handlesClause, InterfaceImplementations = implementsClause @@ -1515,7 +1515,7 @@ IsMustOverride(m)) { methodDeclaration = new MethodDeclaration { Name = name, Modifier = m.Modifier, Parameters = p, Attributes = attributes, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endLocation, - TypeReference = new TypeReference("", "System.Void"), + TypeReference = new TypeReference("System.Void", true), Templates = templates, HandlesClause = handlesClause, InterfaceImplementations = implementsClause @@ -1635,7 +1635,7 @@ out type); #line 896 "VBNET.ATG" if(type == null) { - type = new TypeReference("System.Object"); + type = new TypeReference("System.Object", true); } if (la.kind == 121 || la.kind == 123) { @@ -1952,7 +1952,7 @@ out type); #line 1073 "VBNET.ATG" if(type == null) { - type = new TypeReference("System.Object"); + type = new TypeReference("System.Object", true); } if (la.kind == 123) { @@ -2335,7 +2335,7 @@ p); Modifier = mod.Modifier, Parameters = p, Attributes = attributes, - TypeReference = new TypeReference("", "System.Void"), + TypeReference = new TypeReference("System.Void", true), StartLocation = startLocation, EndLocation = t.EndLocation, Templates = templates @@ -2379,7 +2379,7 @@ out type); #line 699 "VBNET.ATG" if(type == null) { - type = new TypeReference("System.Object"); + type = new TypeReference("System.Object", true); } MethodDeclaration md = new MethodDeclaration { Name = name, Modifier = mod.Modifier, @@ -2424,7 +2424,7 @@ out type); #line 726 "VBNET.ATG" if(type == null) { - type = new TypeReference("System.Object"); + type = new TypeReference("System.Object", true); } EndOfStmt(); @@ -3874,7 +3874,7 @@ out val); lexer.NextToken(); #line 1678 "VBNET.ATG" - val = "Object"; + val = "System.Object"; } else SynErr(257); Expect(16); @@ -3883,7 +3883,7 @@ out val); Identifier(); #line 1679 "VBNET.ATG" - pexpr = new MemberReferenceExpression(new TypeReferenceExpression(val), t.val); + pexpr = new MemberReferenceExpression(new TypeReferenceExpression(new TypeReference(val, true)), t.val); break; } case 139: { @@ -4099,105 +4099,105 @@ out string type) { lexer.NextToken(); #line 3363 "VBNET.ATG" - type = "Boolean"; + type = "System.Boolean"; break; } case 86: { lexer.NextToken(); #line 3364 "VBNET.ATG" - type = "Date"; + type = "System.DateTime"; break; } case 69: { lexer.NextToken(); #line 3365 "VBNET.ATG" - type = "Char"; + type = "System.Char"; break; } case 193: { lexer.NextToken(); #line 3366 "VBNET.ATG" - type = "String"; + type = "System.String"; break; } case 87: { lexer.NextToken(); #line 3367 "VBNET.ATG" - type = "Decimal"; + type = "System.Decimal"; break; } case 58: { lexer.NextToken(); #line 3368 "VBNET.ATG" - type = "Byte"; + type = "System.Byte"; break; } case 186: { lexer.NextToken(); #line 3369 "VBNET.ATG" - type = "Short"; + type = "System.Int16"; break; } case 128: { lexer.NextToken(); #line 3370 "VBNET.ATG" - type = "Integer"; + type = "System.Int32"; break; } case 137: { lexer.NextToken(); #line 3371 "VBNET.ATG" - type = "Long"; + type = "System.Int64"; break; } case 187: { lexer.NextToken(); #line 3372 "VBNET.ATG" - type = "Single"; + type = "System.Single"; break; } case 96: { lexer.NextToken(); #line 3373 "VBNET.ATG" - type = "Double"; + type = "System.Double"; break; } case 206: { lexer.NextToken(); #line 3374 "VBNET.ATG" - type = "UInteger"; + type = "System.UInt32"; break; } case 207: { lexer.NextToken(); #line 3375 "VBNET.ATG" - type = "ULong"; + type = "System.UInt64"; break; } case 210: { lexer.NextToken(); #line 3376 "VBNET.ATG" - type = "UShort"; + type = "System.UInt16"; break; } case 181: { lexer.NextToken(); #line 3377 "VBNET.ATG" - type = "SByte"; + type = "System.SByte"; break; } default: SynErr(261); break; @@ -4216,112 +4216,112 @@ out TypeReference type) { lexer.NextToken(); #line 1765 "VBNET.ATG" - type = new TypeReference("System.Boolean"); + type = new TypeReference("System.Boolean", true); break; } case 64: { lexer.NextToken(); #line 1766 "VBNET.ATG" - type = new TypeReference("System.Byte"); + type = new TypeReference("System.Byte", true); break; } case 77: { lexer.NextToken(); #line 1767 "VBNET.ATG" - type = new TypeReference("System.SByte"); + type = new TypeReference("System.SByte", true); break; } case 65: { lexer.NextToken(); #line 1768 "VBNET.ATG" - type = new TypeReference("System.Char"); + type = new TypeReference("System.Char", true); break; } case 66: { lexer.NextToken(); #line 1769 "VBNET.ATG" - type = new TypeReference("System.DateTime"); + type = new TypeReference("System.DateTime", true); break; } case 68: { lexer.NextToken(); #line 1770 "VBNET.ATG" - type = new TypeReference("System.Decimal"); + type = new TypeReference("System.Decimal", true); break; } case 67: { lexer.NextToken(); #line 1771 "VBNET.ATG" - type = new TypeReference("System.Double"); + type = new TypeReference("System.Double", true); break; } case 78: { lexer.NextToken(); #line 1772 "VBNET.ATG" - type = new TypeReference("System.Int16"); + type = new TypeReference("System.Int16", true); break; } case 70: { lexer.NextToken(); #line 1773 "VBNET.ATG" - type = new TypeReference("System.Int32"); + type = new TypeReference("System.Int32", true); break; } case 72: { lexer.NextToken(); #line 1774 "VBNET.ATG" - type = new TypeReference("System.Int64"); + type = new TypeReference("System.Int64", true); break; } case 84: { lexer.NextToken(); #line 1775 "VBNET.ATG" - type = new TypeReference("System.UInt16"); + type = new TypeReference("System.UInt16", true); break; } case 82: { lexer.NextToken(); #line 1776 "VBNET.ATG" - type = new TypeReference("System.UInt32"); + type = new TypeReference("System.UInt32", true); break; } case 83: { lexer.NextToken(); #line 1777 "VBNET.ATG" - type = new TypeReference("System.UInt64"); + type = new TypeReference("System.UInt64", true); break; } case 73: { lexer.NextToken(); #line 1778 "VBNET.ATG" - type = new TypeReference("System.Object"); + type = new TypeReference("System.Object", true); break; } case 79: { lexer.NextToken(); #line 1779 "VBNET.ATG" - type = new TypeReference("System.Single"); + type = new TypeReference("System.Single", true); break; } case 80: { lexer.NextToken(); #line 1780 "VBNET.ATG" - type = new TypeReference("System.String"); + type = new TypeReference("System.String", true); break; } default: SynErr(262); break; diff --git a/src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG b/src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG index 2817716885..20efe40893 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG +++ b/src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG @@ -525,7 +525,7 @@ NonModuleDeclaration attributes> (. m.Check(Modifiers.VBDelegates); 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); List p = new List(); .) @@ -678,7 +678,7 @@ InterfaceMemberDecl Modifier = mod.Modifier, Parameters = p, Attributes = attributes, - TypeReference = new TypeReference("", "System.Void"), + TypeReference = new TypeReference("System.Void", true), StartLocation = startLocation, EndLocation = t.EndLocation, Templates = templates @@ -697,7 +697,7 @@ InterfaceMemberDecl [ "As" { AttributeSection } TypeName ] (. if(type == null) { - type = new TypeReference("System.Object"); + type = new TypeReference("System.Object", true); } MethodDeclaration md = new MethodDeclaration { Name = name, Modifier = mod.Modifier, @@ -724,7 +724,7 @@ InterfaceMemberDecl [ "As" TypeName ] (. if(type == null) { - type = new TypeReference("System.Object"); + type = new TypeReference("System.Object", true); } .) EndOfStmt @@ -817,7 +817,7 @@ StructureMemberDecl attributes> methodDeclaration = new MethodDeclaration { Name = name, Modifier = m.Modifier, Parameters = p, Attributes = attributes, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endLocation, - TypeReference = new TypeReference("", "System.Void"), + TypeReference = new TypeReference("System.Void", true), Templates = templates, HandlesClause = handlesClause, InterfaceImplementations = implementsClause @@ -830,7 +830,7 @@ StructureMemberDecl attributes> methodDeclaration = new MethodDeclaration { Name = name, Modifier = m.Modifier, Parameters = p, Attributes = attributes, StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endLocation, - TypeReference = new TypeReference("", "System.Void"), + TypeReference = new TypeReference("System.Void", true), Templates = templates, HandlesClause = handlesClause, InterfaceImplementations = implementsClause @@ -894,7 +894,7 @@ StructureMemberDecl attributes> ["As" { AttributeSection } TypeName ] (. if(type == null) { - type = new TypeReference("System.Object"); + type = new TypeReference("System.Object", true); } .) [ @@ -1071,7 +1071,7 @@ StructureMemberDecl attributes> [ "As" TypeName ] (. if(type == null) { - type = new TypeReference("System.Object"); + type = new TypeReference("System.Object", true); } .) [ ImplementsClause ] @@ -1675,8 +1675,8 @@ SimpleNonInvocationExpression "(" "Of" TypeArgumentList<((IdentifierExpression)pexpr).TypeArguments> ")" ] | (. string val = String.Empty; .) - ( PrimitiveTypeName | "Object" (. val = "Object"; .) ) - "." (. t.val = ""; .) Identifier (. pexpr = new MemberReferenceExpression(new TypeReferenceExpression(val), t.val); .) + ( PrimitiveTypeName | "Object" (. val = "System.Object"; .) ) + "." (. t.val = ""; .) Identifier (. pexpr = new MemberReferenceExpression(new TypeReferenceExpression(new TypeReference(val, true)), t.val); .) | "Me" (. pexpr = new ThisReferenceExpression(); .) | (. Expression retExpr = null; .) ( "MyBase" (. retExpr = new BaseReferenceExpression(); .) @@ -1762,22 +1762,22 @@ CastTarget (. type = null; .) = - "CBool" (. type = new TypeReference("System.Boolean"); .) - | "CByte" (. type = new TypeReference("System.Byte"); .) - | "CSByte" (. type = new TypeReference("System.SByte"); .) - | "CChar" (. type = new TypeReference("System.Char"); .) - | "CDate" (. type = new TypeReference("System.DateTime"); .) - | "CDec" (. type = new TypeReference("System.Decimal"); .) - | "CDbl" (. type = new TypeReference("System.Double"); .) - | "CShort" (. type = new TypeReference("System.Int16"); .) - | "CInt" (. type = new TypeReference("System.Int32"); .) - | "CLng" (. type = new TypeReference("System.Int64"); .) - | "CUShort" (. type = new TypeReference("System.UInt16"); .) - | "CUInt" (. type = new TypeReference("System.UInt32"); .) - | "CULng" (. type = new TypeReference("System.UInt64"); .) - | "CObj" (. type = new TypeReference("System.Object"); .) - | "CSng" (. type = new TypeReference("System.Single"); .) - | "CStr" (. type = new TypeReference("System.String"); .) + "CBool" (. type = new TypeReference("System.Boolean", true); .) + | "CByte" (. type = new TypeReference("System.Byte", true); .) + | "CSByte" (. type = new TypeReference("System.SByte", true); .) + | "CChar" (. type = new TypeReference("System.Char", true); .) + | "CDate" (. type = new TypeReference("System.DateTime", true); .) + | "CDec" (. type = new TypeReference("System.Decimal", true); .) + | "CDbl" (. type = new TypeReference("System.Double", true); .) + | "CShort" (. type = new TypeReference("System.Int16", true); .) + | "CInt" (. type = new TypeReference("System.Int32", true); .) + | "CLng" (. type = new TypeReference("System.Int64", true); .) + | "CUShort" (. type = new TypeReference("System.UInt16", true); .) + | "CUInt" (. type = new TypeReference("System.UInt32", true); .) + | "CULng" (. type = new TypeReference("System.UInt64", true); .) + | "CObj" (. type = new TypeReference("System.Object", true); .) + | "CSng" (. type = new TypeReference("System.Single", true); .) + | "CStr" (. type = new TypeReference("System.String", true); .) . DisjunctionExpr @@ -2445,23 +2445,23 @@ NonArrayTypeName (. typeref = new InnerClassTypeReference(typeref, nestedTypeRef.Type, nestedTypeRef.GenericTypes); .) } ) - | "Object" (. typeref = new TypeReference("System.Object"); .) + | "Object" (. typeref = new TypeReference("System.Object", true); .) [ "?" (. List typeArguments = new List(1); if (typeref != null) typeArguments.Add(typeref); - typeref = new TypeReference("System.Nullable", typeArguments); + typeref = new TypeReference("System.Nullable", typeArguments) { IsKeyword = true }; .) ] - | PrimitiveTypeName (. typeref = new TypeReference(name); .) + | PrimitiveTypeName (. typeref = new TypeReference(name, true); .) [ "?" (. List typeArguments = new List(1); 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 /* 7.3 */ PrimitiveTypeName (. type = String.Empty; .) = - "Boolean" (. type = "Boolean"; .) - | "Date" (. type = "Date"; .) - | "Char" (. type = "Char"; .) - | "String" (. type = "String"; .) - | "Decimal" (. type = "Decimal"; .) - | "Byte" (. type = "Byte"; .) - | "Short" (. type = "Short"; .) - | "Integer" (. type = "Integer"; .) - | "Long" (. type = "Long"; .) - | "Single" (. type = "Single"; .) - | "Double" (. type = "Double"; .) - | "UInteger" (. type = "UInteger"; .) - | "ULong" (. type = "ULong"; .) - | "UShort" (. type = "UShort"; .) - | "SByte" (. type = "SByte"; .) + "Boolean" (. type = "System.Boolean"; .) + | "Date" (. type = "System.DateTime"; .) + | "Char" (. type = "System.Char"; .) + | "String" (. type = "System.String"; .) + | "Decimal" (. type = "System.Decimal"; .) + | "Byte" (. type = "System.Byte"; .) + | "Short" (. type = "System.Int16"; .) + | "Integer" (. type = "System.Int32"; .) + | "Long" (. type = "System.Int64"; .) + | "Single" (. type = "System.Single"; .) + | "Double" (. type = "System.Double"; .) + | "UInteger" (. type = "System.UInt32"; .) + | "ULong" (. type = "System.UInt64"; .) + | "UShort" (. type = "System.UInt16"; .) + | "SByte" (. type = "System.SByte"; .) . ParameterModifier diff --git a/src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs b/src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs index a2753d0a5d..242dbb0793 100644 --- a/src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs +++ b/src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs @@ -24,7 +24,6 @@ namespace ICSharpCode.NRefactory.PrettyPrinter Errors errors = new Errors(); CSharpOutputFormatter outputFormatter; PrettyPrintOptions prettyPrintOptions = new PrettyPrintOptions(); - bool printFullSystemType; public string Text { get { @@ -96,7 +95,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter } /// - /// 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. /// static string ConvertTypeString(string typeString) @@ -160,28 +159,25 @@ namespace ICSharpCode.NRefactory.PrettyPrinter if (typeReference.IsGlobal) { outputFormatter.PrintText("global::"); } - if (typeReference.Type == null || typeReference.Type.Length == 0) { - outputFormatter.PrintText("void"); - } else if (typeReference.SystemType == "System.Nullable" && typeReference.GenericTypes != null - && typeReference.GenericTypes.Count == 1 && !typeReference.IsGlobal) - { - TrackVisit(typeReference.GenericTypes[0], null); - outputFormatter.PrintText("?"); - } else { - if (typeReference.SystemType.Length > 0) { - if (printFullSystemType || typeReference.IsGlobal) { - outputFormatter.PrintIdentifier(typeReference.SystemType); - } else { - outputFormatter.PrintText(ConvertTypeString(typeReference.SystemType)); - } + bool printGenerics = true; + if (typeReference.IsKeyword) { + if (typeReference.Type == "System.Nullable" + && typeReference.GenericTypes != null + && typeReference.GenericTypes.Count == 1) + { + TrackVisit(typeReference.GenericTypes[0], null); + outputFormatter.PrintText("?"); + printGenerics = false; } else { - outputFormatter.PrintText(typeReference.Type); - } - if (typeReference.GenericTypes != null && typeReference.GenericTypes.Count > 0) { - outputFormatter.PrintToken(Tokens.LessThan); - AppendCommaSeparatedList(typeReference.GenericTypes); - outputFormatter.PrintToken(Tokens.GreaterThan); + outputFormatter.PrintText(ConvertTypeString(typeReference.Type)); } + } 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) { outputFormatter.PrintToken(Tokens.Times); @@ -286,9 +282,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter outputFormatter.Space(); outputFormatter.PrintToken(Tokens.Assign); outputFormatter.Space(); - printFullSystemType = true; TrackVisit(@using.Alias, data); - printFullSystemType = false; } outputFormatter.PrintToken(Tokens.Semicolon); @@ -1095,7 +1089,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter } // all variables have the same type OutputModifier(localVariableDeclaration.Modifier); - TrackVisit(type ?? new TypeReference("object"), data); + TrackVisit(type ?? new TypeReference("System.Object", true), data); outputFormatter.Space(); AppendCommaSeparatedList(localVariableDeclaration.Variables); outputFormatter.PrintToken(Tokens.Semicolon); @@ -1111,7 +1105,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter outputFormatter.Indent(); } OutputModifier(localVariableDeclaration.Modifier); - TrackVisit(localVariableDeclaration.GetTypeForVariable(i) ?? new TypeReference("object"), data); + TrackVisit(localVariableDeclaration.GetTypeForVariable(i) ?? new TypeReference("System.Object", true), data); outputFormatter.Space(); TrackVisit(v, data); outputFormatter.PrintToken(Tokens.Semicolon); @@ -2318,9 +2312,19 @@ namespace ICSharpCode.NRefactory.PrettyPrinter 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.PrintIdentifier(pointerReferenceExpression.Identifier); + outputFormatter.PrintIdentifier(pointerReferenceExpression.MemberName); + PrintTypeArgumentList(pointerReferenceExpression.TypeArguments); + return null; } diff --git a/src/Libraries/NRefactory/Project/Src/PrettyPrinter/VBNet/VBNetOutputVisitor.cs b/src/Libraries/NRefactory/Project/Src/PrettyPrinter/VBNet/VBNetOutputVisitor.cs index edb3a912a3..cefc1dc841 100644 --- a/src/Libraries/NRefactory/Project/Src/PrettyPrinter/VBNet/VBNetOutputVisitor.cs +++ b/src/Libraries/NRefactory/Project/Src/PrettyPrinter/VBNet/VBNetOutputVisitor.cs @@ -25,7 +25,6 @@ namespace ICSharpCode.NRefactory.PrettyPrinter VBNetOutputFormatter outputFormatter; VBNetPrettyPrintOptions prettyPrintOptions = new VBNetPrettyPrintOptions(); TypeDeclaration currentType; - bool printFullSystemType; Stack exitTokenStack = new Stack(); @@ -103,14 +102,16 @@ namespace ICSharpCode.NRefactory.PrettyPrinter } /// - /// 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. /// static string ConvertTypeString(string typeString) { string primitiveType; - TypeReference.PrimitiveTypesVBReverse.TryGetValue(typeString, out primitiveType); - return primitiveType; + if (TypeReference.PrimitiveTypesVBReverse.TryGetValue(typeString, out primitiveType)) + return primitiveType; + else + return typeString; } public override object TrackedVisitTypeReference(TypeReference typeReference, object data) @@ -136,19 +137,13 @@ namespace ICSharpCode.NRefactory.PrettyPrinter outputFormatter.PrintToken(Tokens.Global); outputFormatter.PrintToken(Tokens.Dot); } - if (typeReference.Type == null || typeReference.Type.Length ==0) { - outputFormatter.PrintText("Void"); - } else if (printFullSystemType || typeReference.IsGlobal) { - outputFormatter.PrintIdentifier(typeReference.SystemType); + bool printGenerics = true; + if (typeReference.IsKeyword) { + outputFormatter.PrintText(ConvertTypeString(typeReference.Type)); } else { - string shortTypeName = ConvertTypeString(typeReference.SystemType); - if (shortTypeName != null) { - outputFormatter.PrintText(shortTypeName); - } else { - outputFormatter.PrintIdentifier(typeReference.Type); - } + 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.Of); outputFormatter.Space(); @@ -256,9 +251,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter outputFormatter.Space(); outputFormatter.PrintToken(Tokens.Assign); outputFormatter.Space(); - printFullSystemType = true; TrackedVisit(((Using)usingDeclaration.Usings[i]).Alias, data); - printFullSystemType = false; } if (i + 1 < usingDeclaration.Usings.Count) { outputFormatter.PrintToken(Tokens.Comma); @@ -430,7 +423,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter outputFormatter.PrintToken(Tokens.Delegate); outputFormatter.Space(); - bool isFunction = (delegateDeclaration.ReturnType.Type != "void"); + bool isFunction = (delegateDeclaration.ReturnType.Type != "System.Void"); if (isFunction) { outputFormatter.PrintToken(Tokens.Function); outputFormatter.Space(); @@ -832,7 +825,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter OutputModifier(methodDeclaration.Modifier); bool isSub = methodDeclaration.TypeReference.IsNull || - methodDeclaration.TypeReference.SystemType == "System.Void"; + methodDeclaration.TypeReference.Type == "System.Void"; if (isSub) { outputFormatter.PrintToken(Tokens.Sub); @@ -1209,7 +1202,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter break; } - bool isVoid = declareDeclaration.TypeReference.IsNull || declareDeclaration.TypeReference.SystemType == "System.Void"; + bool isVoid = declareDeclaration.TypeReference.IsNull || declareDeclaration.TypeReference.Type == "System.Void"; if (isVoid) { outputFormatter.PrintToken(Tokens.Sub); } else { @@ -2489,7 +2482,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter if (castExpression.CastType == CastType.Cast || castExpression.CastTo.IsArrayType) { return PrintCast(Tokens.DirectCast, castExpression); } - switch (castExpression.CastTo.SystemType) { + switch (castExpression.CastTo.Type) { case "System.Boolean": outputFormatter.PrintToken(Tokens.CBool); break; diff --git a/src/Libraries/NRefactory/Project/Src/Visitors/CSharpConstructsConvertVisitor.cs b/src/Libraries/NRefactory/Project/Src/Visitors/CSharpConstructsConvertVisitor.cs index 6cb574c437..0238e41599 100644 --- a/src/Libraries/NRefactory/Project/Src/Visitors/CSharpConstructsConvertVisitor.cs +++ b/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 // the DOM-aware CSharpToVBNetConvertVisitor 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") { // type is value type castExpression.CastType = CastType.Conversion; diff --git a/src/Libraries/NRefactory/Project/Src/Visitors/CodeDOMOutputVisitor.cs b/src/Libraries/NRefactory/Project/Src/Visitors/CodeDOMOutputVisitor.cs index 7ade2c5709..ea4e0d1765 100644 --- a/src/Libraries/NRefactory/Project/Src/Visitors/CodeDOMOutputVisitor.cs +++ b/src/Libraries/NRefactory/Project/Src/Visitors/CodeDOMOutputVisitor.cs @@ -84,11 +84,11 @@ namespace ICSharpCode.NRefactory.Visitors if (type == null) { throw new ArgumentNullException("type"); } - if (string.IsNullOrEmpty(type.SystemType)) { + if (string.IsNullOrEmpty(type.Type)) { throw new InvalidOperationException("empty type"); } - CodeTypeReference t = new CodeTypeReference(type.SystemType); + CodeTypeReference t = new CodeTypeReference(type.Type); foreach (TypeReference gt in type.GenericTypes) { t.TypeArguments.Add(ConvType(gt)); } @@ -457,7 +457,7 @@ namespace ICSharpCode.NRefactory.Visitors CodeVariableDeclarationStatement declStmt = null; 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]; if (!var.Initializer.IsNull) { declStmt = new CodeVariableDeclarationStatement(type, @@ -1654,7 +1654,7 @@ namespace ICSharpCode.NRefactory.Visitors } return new CodeTypeReferenceExpression(type.ToString()); } 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()); } else { return null; diff --git a/src/Libraries/NRefactory/Project/Src/Visitors/ToCSharpConvertVisitor.cs b/src/Libraries/NRefactory/Project/Src/Visitors/ToCSharpConvertVisitor.cs index f8430f6a98..06ba21807f 100644 --- a/src/Libraries/NRefactory/Project/Src/Visitors/ToCSharpConvertVisitor.cs +++ b/src/Libraries/NRefactory/Project/Src/Visitors/ToCSharpConvertVisitor.cs @@ -53,7 +53,7 @@ namespace ICSharpCode.NRefactory.Visitors DelegateDeclaration dd = new DelegateDeclaration(eventDeclaration.Modifier, null); dd.Name = eventDeclaration.Name + "EventHandler"; dd.Parameters = eventDeclaration.Parameters; - dd.ReturnType = new TypeReference("System.Void"); + dd.ReturnType = new TypeReference("System.Void", true); dd.Parent = eventDeclaration.Parent; eventDeclaration.Parameters = null; InsertAfterSibling(eventDeclaration, dd); @@ -88,7 +88,7 @@ namespace ICSharpCode.NRefactory.Visitors foreach (ParameterDeclarationExpression decl in member.Parameters) { 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)); } else { newMember.Body.AddChild(new ReturnStatement(callExpression)); diff --git a/src/Libraries/NRefactory/Project/Src/Visitors/VBNetConstructsConvertVisitor.cs b/src/Libraries/NRefactory/Project/Src/Visitors/VBNetConstructsConvertVisitor.cs index 257960c7c3..e45bffd686 100644 --- a/src/Libraries/NRefactory/Project/Src/Visitors/VBNetConstructsConvertVisitor.cs +++ b/src/Libraries/NRefactory/Project/Src/Visitors/VBNetConstructsConvertVisitor.cs @@ -148,7 +148,7 @@ namespace ICSharpCode.NRefactory.Visitors method.Modifier |= Modifiers.Extern | Modifiers.Static; if (method.TypeReference.IsNull) { - method.TypeReference = new TypeReference("System.Void"); + method.TypeReference = new TypeReference("System.Void", true); } 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)) { ReturnStatement rs = new ReturnStatement(GetAssignmentFromStatement(methodDeclaration.Body.Children[methodDeclaration.Body.Children.Count - 1]).Right); @@ -465,7 +465,7 @@ namespace ICSharpCode.NRefactory.Visitors List arguments = new List(); arguments.Add(stringVariable); return new InvocationExpression( - new MemberReferenceExpression(new TypeReferenceExpression("System.String"), "IsNullOrEmpty"), + new MemberReferenceExpression(new TypeReferenceExpression(new TypeReference("System.String", true)), "IsNullOrEmpty"), arguments); } diff --git a/src/Libraries/NRefactory/Test/Output/VBNet/CSharpToVBNetConverterTest.cs b/src/Libraries/NRefactory/Test/Output/VBNet/CSharpToVBNetConverterTest.cs index 2e73dc4f2a..9aadc9ab56 100644 --- a/src/Libraries/NRefactory/Test/Output/VBNet/CSharpToVBNetConverterTest.cs +++ b/src/Libraries/NRefactory/Test/Output/VBNet/CSharpToVBNetConverterTest.cs @@ -530,14 +530,14 @@ End Class [Test] public void CSharpLinefeedToVBString() { - TestStatement(@"String Test = ""My Test\n"";", + TestStatement(@"string Test = ""My Test\n"";", @"Dim Test As String = ""My Test"" & vbLf"); } [Test] public void CSharpTabToVBString() { - TestStatement(@"String Test = ""\t\a"";", + TestStatement(@"string Test = ""\t\a"";", @"Dim Test As String = vbTab & ChrW(7)"); } } diff --git a/src/Libraries/NRefactory/Test/Parser/Expressions/ArrayCreateExpressionTests.cs b/src/Libraries/NRefactory/Test/Parser/Expressions/ArrayCreateExpressionTests.cs index dc7fc78087..5096c9cdf6 100644 --- a/src/Libraries/NRefactory/Test/Parser/Expressions/ArrayCreateExpressionTests.cs +++ b/src/Libraries/NRefactory/Test/Parser/Expressions/ArrayCreateExpressionTests.cs @@ -21,7 +21,8 @@ namespace ICSharpCode.NRefactory.Tests.Ast public void CSharpArrayCreateExpressionTest1() { ArrayCreateExpression ace = ParseUtilCSharp.ParseExpression("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(new int[] {0}, ace.CreateType.RankSpecifier); } @@ -43,7 +44,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast { ArrayCreateExpression ace = ParseUtilVBNet.ParseExpression("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(new int[] {0}, ace.CreateType.RankSpecifier); } @@ -53,7 +54,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast { ArrayCreateExpression ace = ParseUtilVBNet.ParseExpression("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(5, (ace.Arguments[0] as PrimitiveExpression).Value); Assert.AreEqual(new int[] {0}, ace.CreateType.RankSpecifier); diff --git a/src/Libraries/NRefactory/Test/Parser/Expressions/CastExpressionTests.cs b/src/Libraries/NRefactory/Test/Parser/Expressions/CastExpressionTests.cs index d51c8c0e50..acbb6ac0a0 100644 --- a/src/Libraries/NRefactory/Test/Parser/Expressions/CastExpressionTests.cs +++ b/src/Libraries/NRefactory/Test/Parser/Expressions/CastExpressionTests.cs @@ -40,8 +40,8 @@ namespace ICSharpCode.NRefactory.Tests.Ast public void NullablePrimitiveCastExpression() { CastExpression ce = ParseUtilCSharp.ParseExpression("(int?)o"); - Assert.AreEqual("System.Nullable", ce.CastTo.SystemType); - Assert.AreEqual("int", ce.CastTo.GenericTypes[0].Type); + Assert.AreEqual("System.Nullable", ce.CastTo.Type); + Assert.AreEqual("System.Int32", ce.CastTo.GenericTypes[0].Type); Assert.IsTrue(ce.Expression is IdentifierExpression); Assert.AreEqual(CastType.Cast, ce.CastType); } @@ -50,7 +50,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast public void NullableCastExpression() { CastExpression ce = ParseUtilCSharp.ParseExpression("(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.IsTrue(ce.Expression is IdentifierExpression); Assert.AreEqual(CastType.Cast, ce.CastType); @@ -60,8 +60,9 @@ namespace ICSharpCode.NRefactory.Tests.Ast public void NullableTryCastExpression() { CastExpression ce = ParseUtilCSharp.ParseExpression("o as int?"); - Assert.AreEqual("System.Nullable", ce.CastTo.SystemType); - Assert.AreEqual("int", ce.CastTo.GenericTypes[0].Type); + Assert.AreEqual("System.Nullable", ce.CastTo.Type); + Assert.IsTrue(ce.CastTo.IsKeyword); + Assert.AreEqual("System.Int32", ce.CastTo.GenericTypes[0].Type); Assert.IsTrue(ce.Expression is IdentifierExpression); Assert.AreEqual(CastType.TryCast, ce.CastType); } @@ -71,7 +72,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast { CastExpression ce = ParseUtilCSharp.ParseExpression("(List)o"); 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.AreEqual(CastType.Cast, ce.CastType); } @@ -81,7 +82,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast { CastExpression ce = ParseUtilCSharp.ParseExpression("(List[])o"); 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.IsTrue(ce.Expression is IdentifierExpression); Assert.AreEqual(CastType.Cast, ce.CastType); @@ -92,7 +93,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast { CastExpression ce = ParseUtilCSharp.ParseExpression("o as List[]"); 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.IsTrue(ce.Expression is IdentifierExpression); Assert.AreEqual(CastType.TryCast, ce.CastType); @@ -112,7 +113,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast public void CSharpTryCastParenthesizedExpression() { CastExpression ce = ParseUtilCSharp.ParseExpression("(o) as string"); - Assert.AreEqual("string", ce.CastTo.ToString()); + Assert.AreEqual("System.String", ce.CastTo.ToString()); Assert.IsTrue(ce.Expression is ParenthesizedExpression); Assert.AreEqual(CastType.TryCast, ce.CastType); } @@ -121,7 +122,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast public void CSharpCastNegation() { CastExpression ce = ParseUtilCSharp.ParseExpression("(uint)-negativeValue"); - Assert.AreEqual("uint", ce.CastTo.ToString()); + Assert.AreEqual("System.UInt32", ce.CastTo.ToString()); Assert.IsTrue(ce.Expression is UnaryOperatorExpression); Assert.AreEqual(CastType.Cast, ce.CastType); } diff --git a/src/Libraries/NRefactory/Test/Parser/Expressions/DefaultValueExpressionTests.cs b/src/Libraries/NRefactory/Test/Parser/Expressions/DefaultValueExpressionTests.cs index faa83c4814..e9bd952b31 100644 --- a/src/Libraries/NRefactory/Test/Parser/Expressions/DefaultValueExpressionTests.cs +++ b/src/Libraries/NRefactory/Test/Parser/Expressions/DefaultValueExpressionTests.cs @@ -36,7 +36,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast { DefaultValueExpression toe = ParseUtilCSharp.ParseExpression("default(MyNamespace.N1.MyType)"); 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] diff --git a/src/Libraries/NRefactory/Test/Parser/Expressions/InvocationExpressionTests.cs b/src/Libraries/NRefactory/Test/Parser/Expressions/InvocationExpressionTests.cs index b7e13ab41a..1fbfe6fce5 100644 --- a/src/Libraries/NRefactory/Test/Parser/Expressions/InvocationExpressionTests.cs +++ b/src/Libraries/NRefactory/Test/Parser/Expressions/InvocationExpressionTests.cs @@ -30,7 +30,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast IdentifierExpression ident = (IdentifierExpression)expr.TargetObject; Assert.AreEqual("myMethod", ident.Identifier); 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) @@ -40,8 +40,10 @@ namespace ICSharpCode.NRefactory.Tests.Ast IdentifierExpression ident = (IdentifierExpression)expr.TargetObject; Assert.AreEqual("myMethod", ident.Identifier); Assert.AreEqual(2, ident.TypeArguments.Count); - Assert.AreEqual("T", ident.TypeArguments[0].SystemType); - Assert.AreEqual("System.Boolean", ident.TypeArguments[1].SystemType); + Assert.AreEqual("T", ident.TypeArguments[0].Type); + Assert.IsFalse(ident.TypeArguments[0].IsKeyword); + Assert.AreEqual("System.Boolean", ident.TypeArguments[1].Type); + Assert.IsTrue(ident.TypeArguments[1].IsKeyword); } diff --git a/src/Libraries/NRefactory/Test/Parser/Expressions/LambdaExpressionTests.cs b/src/Libraries/NRefactory/Test/Parser/Expressions/LambdaExpressionTests.cs index 3ee228b9e8..552109a6bc 100644 --- a/src/Libraries/NRefactory/Test/Parser/Expressions/LambdaExpressionTests.cs +++ b/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; }"); 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); } @@ -91,7 +91,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast LambdaExpression e = ParseVBNet("Function(x As Boolean) x Or True"); Assert.AreEqual(1, e.Parameters.Count); 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); } diff --git a/src/Libraries/NRefactory/Test/Parser/Expressions/MemberReferenceExpressionTests.cs b/src/Libraries/NRefactory/Test/Parser/Expressions/MemberReferenceExpressionTests.cs index e9abbd45a7..b59f7da786 100644 --- a/src/Libraries/NRefactory/Test/Parser/Expressions/MemberReferenceExpressionTests.cs +++ b/src/Libraries/NRefactory/Test/Parser/Expressions/MemberReferenceExpressionTests.cs @@ -35,7 +35,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast TypeReference tr = ((TypeReferenceExpression)fre.TargetObject).TypeReference; Assert.AreEqual("SomeClass", tr.Type); Assert.AreEqual(1, tr.GenericTypes.Count); - Assert.AreEqual("System.String", tr.GenericTypes[0].SystemType); + Assert.AreEqual("System.String", tr.GenericTypes[0].Type); } [Test] @@ -47,7 +47,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast TypeReference tr = ((TypeReferenceExpression)fre.TargetObject).TypeReference; Assert.AreEqual("Namespace.Subnamespace.SomeClass", tr.Type); Assert.AreEqual(1, tr.GenericTypes.Count); - Assert.AreEqual("System.String", tr.GenericTypes[0].SystemType); + Assert.AreEqual("System.String", tr.GenericTypes[0].Type); } [Test] @@ -60,7 +60,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast Assert.IsFalse(tr is InnerClassTypeReference); Assert.AreEqual("Namespace.Subnamespace.SomeClass", tr.Type); 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); } @@ -73,10 +73,10 @@ namespace ICSharpCode.NRefactory.Tests.Ast InnerClassTypeReference ic = (InnerClassTypeReference)((TypeReferenceExpression)fre.TargetObject).TypeReference; Assert.AreEqual("InnerClass", ic.Type); 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(1, ic.BaseType.GenericTypes.Count); - Assert.AreEqual("System.String", ic.BaseType.GenericTypes[0].SystemType); + Assert.AreEqual("System.String", ic.BaseType.GenericTypes[0].Type); } #endregion @@ -105,7 +105,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast Assert.AreEqual("myField", fre.MemberName); Assert.IsInstanceOfType(typeof(IdentifierExpression), fre.TargetObject); TypeReference tr = ((IdentifierExpression)fre.TargetObject).TypeArguments[0]; - Assert.AreEqual("String", tr.Type); + Assert.AreEqual("System.String", tr.Type); } [Test] @@ -118,7 +118,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast MemberReferenceExpression inner = (MemberReferenceExpression)fre.TargetObject; Assert.AreEqual("SomeClass", inner.MemberName); Assert.AreEqual(1, inner.TypeArguments.Count); - Assert.AreEqual("System.String", inner.TypeArguments[0].SystemType); + Assert.AreEqual("System.String", inner.TypeArguments[0].Type); } [Test] @@ -131,7 +131,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast Assert.AreEqual("SomeClass", inner.MemberName); Assert.AreEqual(1, inner.TypeArguments.Count); - Assert.AreEqual("System.String", inner.TypeArguments[0].SystemType); + Assert.AreEqual("System.String", inner.TypeArguments[0].Type); } [Test] diff --git a/src/Libraries/NRefactory/Test/Parser/Expressions/ObjectCreateExpressionTests.cs b/src/Libraries/NRefactory/Test/Parser/Expressions/ObjectCreateExpressionTests.cs index 6a84720c40..6d740034af 100644 --- a/src/Libraries/NRefactory/Test/Parser/Expressions/ObjectCreateExpressionTests.cs +++ b/src/Libraries/NRefactory/Test/Parser/Expressions/ObjectCreateExpressionTests.cs @@ -38,7 +38,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast public void CSharpNullableObjectCreateExpressionTest() { ObjectCreateExpression oce = ParseUtilCSharp.ParseExpression("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("IntPtr", oce.CreateType.GenericTypes[0].Type); } @@ -72,7 +72,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast TypeReference typeRef = ((ObjectCreateExpression)expr.Arguments[0]).CreateType; Assert.AreEqual("SomeGenericType", typeRef.Type); 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) @@ -225,7 +225,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast TypeReference typeRef = ((ObjectCreateExpression)expr.Arguments[0]).CreateType; Assert.AreEqual("SomeGenericType", typeRef.Type); Assert.AreEqual(1, typeRef.GenericTypes.Count); - Assert.AreEqual("Integer", typeRef.GenericTypes[0].Type); + Assert.AreEqual("System.Int32", typeRef.GenericTypes[0].Type); } [Test] @@ -245,18 +245,18 @@ namespace ICSharpCode.NRefactory.Tests.Ast public void VBNetNullableObjectCreateExpressionTest() { ObjectCreateExpression oce = ParseUtilVBNet.ParseExpression("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("Integer", oce.CreateType.GenericTypes[0].Type); + Assert.AreEqual("System.Int32", oce.CreateType.GenericTypes[0].Type); } [Test] public void VBNetNullableObjectArrayCreateExpressionTest() { ObjectCreateExpression oce = ParseUtilVBNet.ParseExpression("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("Integer", oce.CreateType.GenericTypes[0].Type); + Assert.AreEqual("System.Int32", oce.CreateType.GenericTypes[0].Type); } #endregion diff --git a/src/Libraries/NRefactory/Test/Parser/Expressions/PointerReferenceExpressionTests.cs b/src/Libraries/NRefactory/Test/Parser/Expressions/PointerReferenceExpressionTests.cs index 9e536cff84..b8f6d407d9 100644 --- a/src/Libraries/NRefactory/Test/Parser/Expressions/PointerReferenceExpressionTests.cs +++ b/src/Libraries/NRefactory/Test/Parser/Expressions/PointerReferenceExpressionTests.cs @@ -22,7 +22,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast { PointerReferenceExpression pre = ParseUtilCSharp.ParseExpression("myObj.field->b"); Assert.IsTrue(pre.TargetObject is MemberReferenceExpression); - Assert.AreEqual("b", pre.Identifier); + Assert.AreEqual("b", pre.MemberName); } #endregion diff --git a/src/Libraries/NRefactory/Test/Parser/Expressions/QueryExpressionTests.cs b/src/Libraries/NRefactory/Test/Parser/Expressions/QueryExpressionTests.cs index 5995591d34..08244da604 100644 --- a/src/Libraries/NRefactory/Test/Parser/Expressions/QueryExpressionTests.cs +++ b/src/Libraries/NRefactory/Test/Parser/Expressions/QueryExpressionTests.cs @@ -50,7 +50,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast "from int c in customers select c" ); 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.IsInstanceOfType(typeof(QueryExpressionSelectClause), qe.SelectOrGroupClause); } @@ -63,7 +63,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast "from S? c in customers select c" ); Assert.AreEqual("c", qe.FromClause.Identifier); - Assert.AreEqual("System.Nullable>", qe.FromClause.Type.ToString()); + Assert.AreEqual("System.Nullable>", qe.FromClause.Type.ToString()); Assert.AreEqual("customers", ((IdentifierExpression)qe.FromClause.InExpression).Identifier); Assert.IsInstanceOfType(typeof(QueryExpressionSelectClause), qe.SelectOrGroupClause); } diff --git a/src/Libraries/NRefactory/Test/Parser/Expressions/TypeOfExpressionTests.cs b/src/Libraries/NRefactory/Test/Parser/Expressions/TypeOfExpressionTests.cs index 927c1e1c4e..fa9ef2a3a9 100644 --- a/src/Libraries/NRefactory/Test/Parser/Expressions/TypeOfExpressionTests.cs +++ b/src/Libraries/NRefactory/Test/Parser/Expressions/TypeOfExpressionTests.cs @@ -35,14 +35,14 @@ namespace ICSharpCode.NRefactory.Tests.Ast public void CSharpPrimitiveTypeOfExpressionTest() { TypeOfExpression toe = ParseUtilCSharp.ParseExpression("typeof(int)"); - Assert.AreEqual("System.Int32", toe.TypeReference.SystemType); + Assert.AreEqual("System.Int32", toe.TypeReference.Type); } [Test] public void CSharpVoidTypeOfExpressionTest() { TypeOfExpression toe = ParseUtilCSharp.ParseExpression("typeof(void)"); - Assert.AreEqual("System.Void", toe.TypeReference.SystemType); + Assert.AreEqual("System.Void", toe.TypeReference.Type); } [Test] @@ -58,7 +58,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast { TypeOfExpression toe = ParseUtilCSharp.ParseExpression("typeof(MyNamespace.N1.MyType)"); 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] @@ -71,17 +71,17 @@ namespace ICSharpCode.NRefactory.Tests.Ast ic = (InnerClassTypeReference)ic.BaseType; Assert.AreEqual("InnerClass", ic.Type); 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(1, ic.BaseType.GenericTypes.Count); - Assert.AreEqual("System.String", ic.BaseType.GenericTypes[0].SystemType); + Assert.AreEqual("System.String", ic.BaseType.GenericTypes[0].Type); } [Test] public void CSharpNullableTypeOfExpressionTest() { TypeOfExpression toe = ParseUtilCSharp.ParseExpression("typeof(MyStruct?)"); - Assert.AreEqual("System.Nullable", toe.TypeReference.SystemType); + Assert.AreEqual("System.Nullable", toe.TypeReference.Type); Assert.AreEqual("MyStruct", toe.TypeReference.GenericTypes[0].Type); } @@ -115,14 +115,14 @@ namespace ICSharpCode.NRefactory.Tests.Ast public void VBPrimitiveTypeOfExpressionTest() { TypeOfExpression toe = ParseUtilVBNet.ParseExpression("GetType(integer)"); - Assert.AreEqual("System.Int32", toe.TypeReference.SystemType); + Assert.AreEqual("System.Int32", toe.TypeReference.Type); } [Test] public void VBVoidTypeOfExpressionTest() { TypeOfExpression toe = ParseUtilVBNet.ParseExpression("GetType(void)"); - Assert.AreEqual("System.Void", toe.TypeReference.SystemType); + Assert.AreEqual("void", toe.TypeReference.Type); } [Test] @@ -138,7 +138,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast { TypeOfExpression toe = ParseUtilVBNet.ParseExpression("GetType(MyNamespace.N1.MyType(Of string))"); 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] @@ -160,10 +160,10 @@ namespace ICSharpCode.NRefactory.Tests.Ast ic = (InnerClassTypeReference)ic.BaseType; Assert.AreEqual("InnerClass", ic.Type); 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(1, ic.BaseType.GenericTypes.Count); - Assert.AreEqual("System.String", ic.BaseType.GenericTypes[0].SystemType); + Assert.AreEqual("System.String", ic.BaseType.GenericTypes[0].Type); } #endregion } diff --git a/src/Libraries/NRefactory/Test/Parser/Expressions/TypeOfIsExpressionTests.cs b/src/Libraries/NRefactory/Test/Parser/Expressions/TypeOfIsExpressionTests.cs index 14a4d9ca37..60ded6492e 100644 --- a/src/Libraries/NRefactory/Test/Parser/Expressions/TypeOfIsExpressionTests.cs +++ b/src/Libraries/NRefactory/Test/Parser/Expressions/TypeOfIsExpressionTests.cs @@ -22,7 +22,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast { TypeOfIsExpression ce = ParseUtilCSharp.ParseExpression("o is List[]"); 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.IsTrue(ce.Expression is IdentifierExpression); } @@ -31,8 +31,8 @@ namespace ICSharpCode.NRefactory.Tests.Ast public void NullableIsExpression() { TypeOfIsExpression ce = ParseUtilCSharp.ParseExpression("o is int?"); - Assert.AreEqual("System.Nullable", ce.TypeReference.SystemType); - Assert.AreEqual("int", ce.TypeReference.GenericTypes[0].Type); + Assert.AreEqual("System.Nullable", ce.TypeReference.Type); + Assert.AreEqual("System.Int32", ce.TypeReference.GenericTypes[0].Type); Assert.IsTrue(ce.Expression is IdentifierExpression); } @@ -42,8 +42,8 @@ namespace ICSharpCode.NRefactory.Tests.Ast BinaryOperatorExpression boe; boe = ParseUtilCSharp.ParseExpression("o is int? == true"); TypeOfIsExpression ce = (TypeOfIsExpression)boe.Left; - Assert.AreEqual("System.Nullable", ce.TypeReference.SystemType); - Assert.AreEqual("int", ce.TypeReference.GenericTypes[0].Type); + Assert.AreEqual("System.Nullable", ce.TypeReference.Type); + Assert.AreEqual("System.Int32", ce.TypeReference.GenericTypes[0].Type); Assert.IsTrue(ce.Expression is IdentifierExpression); } #endregion diff --git a/src/Libraries/NRefactory/Test/Parser/Expressions/TypeReferenceExpressionTests.cs b/src/Libraries/NRefactory/Test/Parser/Expressions/TypeReferenceExpressionTests.cs index d3beecc342..bc62269805 100644 --- a/src/Libraries/NRefactory/Test/Parser/Expressions/TypeReferenceExpressionTests.cs +++ b/src/Libraries/NRefactory/Test/Parser/Expressions/TypeReferenceExpressionTests.cs @@ -47,7 +47,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast { MemberReferenceExpression fre = ParseUtilCSharp.ParseExpression("int.MaxValue"); Assert.AreEqual("MaxValue", fre.MemberName); - Assert.AreEqual("System.Int32", ((TypeReferenceExpression)fre.TargetObject).TypeReference.SystemType); + Assert.AreEqual("System.Int32", ((TypeReferenceExpression)fre.TargetObject).TypeReference.Type); } [Test] @@ -58,7 +58,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast // on this trick. MemberReferenceExpression fre = ParseUtilCSharp.ParseExpression("int", true); Assert.AreEqual("", fre.MemberName); - Assert.AreEqual("System.Int32", ((TypeReferenceExpression)fre.TargetObject).TypeReference.SystemType); + Assert.AreEqual("System.Int32", ((TypeReferenceExpression)fre.TargetObject).TypeReference.Type); } #endregion @@ -68,7 +68,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast { MemberReferenceExpression fre = ParseUtilVBNet.ParseExpression("inTeGer.MaxValue"); Assert.AreEqual("MaxValue", fre.MemberName); - Assert.AreEqual("System.Int32", ((TypeReferenceExpression)fre.TargetObject).TypeReference.SystemType); + Assert.AreEqual("System.Int32", ((TypeReferenceExpression)fre.TargetObject).TypeReference.Type); } [Test] @@ -79,7 +79,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast // on this trick. MemberReferenceExpression fre = ParseUtilVBNet.ParseExpression("inTeGer", true); Assert.AreEqual("", fre.MemberName); - Assert.AreEqual("System.Int32", ((TypeReferenceExpression)fre.TargetObject).TypeReference.SystemType); + Assert.AreEqual("System.Int32", ((TypeReferenceExpression)fre.TargetObject).TypeReference.Type); } [Test] @@ -87,7 +87,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast { MemberReferenceExpression fre = ParseUtilVBNet.ParseExpression("Object.ReferenceEquals"); Assert.AreEqual("ReferenceEquals", fre.MemberName); - Assert.AreEqual("System.Object", ((TypeReferenceExpression)fre.TargetObject).TypeReference.SystemType); + Assert.AreEqual("System.Object", ((TypeReferenceExpression)fre.TargetObject).TypeReference.Type); } [Test] @@ -98,7 +98,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast // on this trick. MemberReferenceExpression fre = ParseUtilVBNet.ParseExpression("obJeCt", true); Assert.AreEqual("", fre.MemberName); - Assert.AreEqual("System.Object", ((TypeReferenceExpression)fre.TargetObject).TypeReference.SystemType); + Assert.AreEqual("System.Object", ((TypeReferenceExpression)fre.TargetObject).TypeReference.Type); } #endregion } diff --git a/src/Libraries/NRefactory/Test/Parser/GlobalScope/DelegateDeclarationTests.cs b/src/Libraries/NRefactory/Test/Parser/GlobalScope/DelegateDeclarationTests.cs index 7cd1ca1bbf..c2cdf3d66c 100644 --- a/src/Libraries/NRefactory/Test/Parser/GlobalScope/DelegateDeclarationTests.cs +++ b/src/Libraries/NRefactory/Test/Parser/GlobalScope/DelegateDeclarationTests.cs @@ -16,7 +16,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast { void TestDelegateDeclaration(DelegateDeclaration dd) { - Assert.AreEqual("System.Void", dd.ReturnType.SystemType); + Assert.AreEqual("System.Void", dd.ReturnType.Type); Assert.AreEqual("MyDelegate", dd.Name); } @@ -25,10 +25,10 @@ namespace ICSharpCode.NRefactory.Tests.Ast Assert.AreEqual(3, dd.Parameters.Count); 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("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("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"; DelegateDeclaration dd = ParseUtilCSharp.ParseGlobal(program, true); - Assert.AreEqual("System.Void", dd.ReturnType.SystemType); + Assert.AreEqual("System.Void", dd.ReturnType.Type); //Assert.AreEqual("?", dd.Name); TestParameters(dd); } diff --git a/src/Libraries/NRefactory/Test/Parser/GlobalScope/TypeDeclarationTests.cs b/src/Libraries/NRefactory/Test/Parser/GlobalScope/TypeDeclarationTests.cs index 61f8d417a1..eef1c06779 100644 --- a/src/Libraries/NRefactory/Test/Parser/GlobalScope/TypeDeclarationTests.cs +++ b/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(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); } diff --git a/src/Libraries/NRefactory/Test/Parser/GlobalScope/UsingDeclarationTests.cs b/src/Libraries/NRefactory/Test/Parser/GlobalScope/UsingDeclarationTests.cs index 53eb25c158..3593d1f66f 100644 --- a/src/Libraries/NRefactory/Test/Parser/GlobalScope/UsingDeclarationTests.cs +++ b/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.AreEqual("StringCollection", ud.Usings[0].Name); 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# diff --git a/src/Libraries/NRefactory/Test/Parser/Statements/LocalVariableDeclarationTests.cs b/src/Libraries/NRefactory/Test/Parser/Statements/LocalVariableDeclarationTests.cs index aa4733fa08..382472becd 100644 --- a/src/Libraries/NRefactory/Test/Parser/Statements/LocalVariableDeclarationTests.cs +++ b/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("a", ((VariableDeclaration)lvd.Variables[0]).Name); 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); } @@ -36,7 +36,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast Assert.AreEqual(1, lvd.Variables.Count); Assert.AreEqual("a", ((VariableDeclaration)lvd.Variables[0]).Name); TypeReference type = lvd.GetTypeForVariable(0); - Assert.AreEqual("void", type.Type); + Assert.AreEqual("System.Void", type.Type); Assert.AreEqual(1, type.PointerNestingLevel); } @@ -69,10 +69,10 @@ namespace ICSharpCode.NRefactory.Tests.Ast ic = (InnerClassTypeReference)ic.BaseType; Assert.AreEqual("InnerClass", ic.Type); 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(1, ic.BaseType.GenericTypes.Count); - Assert.AreEqual("System.String", ic.BaseType.GenericTypes[0].SystemType); + Assert.AreEqual("System.String", ic.BaseType.GenericTypes[0].Type); } [Test] @@ -83,7 +83,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast TypeReference type = lvd.GetTypeForVariable(0); Assert.AreEqual("G", type.Type); 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.IsFalse(type.GenericTypes[0].IsArrayType); Assert.AreEqual(new int[] {0}, type.RankSpecifier); @@ -97,7 +97,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast TypeReference type = lvd.GetTypeForVariable(0); Assert.AreEqual("G", type.Type); 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.IsFalse(type.IsArrayType); 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("G", type.GenericTypes[0].Type); 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] @@ -126,7 +126,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast Assert.AreEqual(1, type.GenericTypes.Count); Assert.AreEqual("G", type.GenericTypes[0].Type); 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] @@ -137,7 +137,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast TypeReference type = lvd.GetTypeForVariable(0); Assert.AreEqual("G", type.Type); Assert.AreEqual(1, type.GenericTypes.Count); - Assert.AreEqual("int", type.GenericTypes[0].Type); + Assert.AreEqual("System.Int32", type.GenericTypes[0].Type); } [Test] @@ -169,8 +169,8 @@ namespace ICSharpCode.NRefactory.Tests.Ast Assert.AreEqual(1, lvd.Variables.Count); Assert.AreEqual("a", ((VariableDeclaration)lvd.Variables[0]).Name); TypeReference type = lvd.GetTypeForVariable(0); - Assert.AreEqual("System.Nullable", type.SystemType); - Assert.AreEqual("System.Int32", type.GenericTypes[0].SystemType); + Assert.AreEqual("System.Nullable", type.Type); + Assert.AreEqual("System.Int32", type.GenericTypes[0].Type); } [Test] @@ -180,7 +180,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast Assert.AreEqual(1, lvd.Variables.Count); Assert.AreEqual("a", ((VariableDeclaration)lvd.Variables[0]).Name); TypeReference type = lvd.GetTypeForVariable(0); - Assert.AreEqual("System.Nullable", type.SystemType); + Assert.AreEqual("System.Nullable", type.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); TypeReference type = lvd.GetTypeForVariable(0); Assert.IsTrue(type.IsArrayType); - Assert.AreEqual("System.Nullable", type.SystemType); + Assert.AreEqual("System.Nullable", type.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("a", ((VariableDeclaration)lvd.Variables[0]).Name); 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("System.Nullable", type.GenericTypes[0].GenericTypes[0].SystemType); - Assert.AreEqual("System.Int32", type.GenericTypes[0].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].Type); } #endregion @@ -218,7 +218,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast Assert.AreEqual(1, lvd.Variables.Count); Assert.AreEqual("a", lvd.Variables[0].Name); 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); } @@ -229,7 +229,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast Assert.AreEqual(1, lvd.Variables.Count); Assert.AreEqual("override", lvd.Variables[0].Name); 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); } @@ -240,7 +240,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast Assert.AreEqual(1, lvd.Variables.Count); Assert.AreEqual("a", lvd.Variables[0].Name); TypeReference type = lvd.GetTypeForVariable(0); - Assert.AreEqual("Integer", type.Type); + Assert.AreEqual("System.Int32", type.Type); Assert.AreEqual(new int[] { 0 } , type.RankSpecifier); ArrayCreateExpression ace = (ArrayCreateExpression)lvd.Variables[0].Initializer; 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("a", lvd.Variables[0].Name); TypeReference type = lvd.GetTypeForVariable(0); - Assert.AreEqual("Integer", type.Type); + Assert.AreEqual("System.Int32", type.Type); Assert.AreEqual(new int[] { 0 } , type.RankSpecifier); ArrayCreateExpression ace = (ArrayCreateExpression)lvd.Variables[0].Initializer; 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("a", lvd.Variables[0].Name); TypeReference type = lvd.GetTypeForVariable(0); - Assert.AreEqual("Integer", type.Type); + Assert.AreEqual("System.Int32", type.Type); Assert.AreEqual(new int[] { 0 } , type.RankSpecifier); } @@ -282,7 +282,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast Assert.AreEqual(1, lvd.Variables.Count); Assert.AreEqual("a", lvd.Variables[0].Name); TypeReference type = lvd.GetTypeForVariable(0); - Assert.AreEqual("Integer", type.Type); + Assert.AreEqual("System.Int32", type.Type); Assert.AreEqual(new int[] { 0, 0 } , type.RankSpecifier); ArrayCreateExpression ace = (ArrayCreateExpression)lvd.Variables[0].Initializer; Assert.AreEqual(new int[] {0, 0}, ace.CreateType.RankSpecifier); @@ -314,7 +314,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast TypeReference type = lvd.GetTypeForVariable(0); Assert.AreEqual("G", type.Type); 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.IsFalse(type.GenericTypes[0].IsArrayType); Assert.AreEqual(new int[] { 0 }, type.RankSpecifier); @@ -328,7 +328,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast TypeReference type = lvd.GetTypeForVariable(0); Assert.AreEqual("G", type.Type); 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.IsFalse(type.IsArrayType); 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("G", type.GenericTypes[0].Type); 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] @@ -356,7 +356,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast TypeReference type = lvd.GetTypeForVariable(0); Assert.AreEqual("G", type.Type); Assert.AreEqual(1, type.GenericTypes.Count); - Assert.AreEqual("Integer", type.GenericTypes[0].Type); + Assert.AreEqual("System.Int32", type.GenericTypes[0].Type); } [Test] @@ -367,7 +367,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast TypeReference type = lvd.GetTypeForVariable(0); Assert.AreEqual("G", type.Type); Assert.AreEqual(1, type.GenericTypes.Count); - Assert.AreEqual("Integer", type.GenericTypes[0].Type); + Assert.AreEqual("System.Int32", type.GenericTypes[0].Type); // TODO: Check initializer } @@ -382,10 +382,10 @@ namespace ICSharpCode.NRefactory.Tests.Ast ic = (InnerClassTypeReference)ic.BaseType; Assert.AreEqual("InnerClass", ic.Type); 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(1, ic.BaseType.GenericTypes.Count); - Assert.AreEqual("System.String", ic.BaseType.GenericTypes[0].SystemType); + Assert.AreEqual("System.String", ic.BaseType.GenericTypes[0].Type); } #endregion } diff --git a/src/Libraries/NRefactory/Test/Parser/TypeLevel/ConstructorDeclarationTests.cs b/src/Libraries/NRefactory/Test/Parser/TypeLevel/ConstructorDeclarationTests.cs index 7034841e04..d0a0199fec 100644 --- a/src/Libraries/NRefactory/Test/Parser/TypeLevel/ConstructorDeclarationTests.cs +++ b/src/Libraries/NRefactory/Test/Parser/TypeLevel/ConstructorDeclarationTests.cs @@ -70,8 +70,8 @@ namespace ICSharpCode.NRefactory.Tests.Ast { ConstructorDeclaration cd = ParseUtilVBNet.ParseTypeMember("Sub New(x As Integer, Optional y As String) \nEnd Sub"); Assert.AreEqual(2, cd.Parameters.Count); - Assert.AreEqual("Integer", cd.Parameters[0].TypeReference.Type); - Assert.AreEqual("String", cd.Parameters[1].TypeReference.Type); + Assert.AreEqual("System.Int32", cd.Parameters[0].TypeReference.Type); + Assert.AreEqual("System.String", cd.Parameters[1].TypeReference.Type); Assert.AreEqual(ParameterModifiers.Optional, cd.Parameters[1].ParamModifier & ParameterModifiers.Optional); } #endregion diff --git a/src/Libraries/NRefactory/Test/Parser/TypeLevel/DeclareDeclarationTests.cs b/src/Libraries/NRefactory/Test/Parser/TypeLevel/DeclareDeclarationTests.cs index 92d0ed3f48..bfc44ecdad 100644 --- a/src/Libraries/NRefactory/Test/Parser/TypeLevel/DeclareDeclarationTests.cs +++ b/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"; DeclareDeclaration dd = ParseUtilVBNet.ParseTypeMember(program); - Assert.AreEqual("System.Int32", dd.TypeReference.SystemType); + Assert.AreEqual("System.Int32", dd.TypeReference.Type); Assert.AreEqual("GetUserName", dd.Name); Assert.AreEqual("advapi32.dll", dd.Library); Assert.AreEqual("GetUserNameA", dd.Alias); diff --git a/src/Libraries/NRefactory/Test/Parser/TypeLevel/EventDeclarationTests.cs b/src/Libraries/NRefactory/Test/Parser/TypeLevel/EventDeclarationTests.cs index 77a25ca70b..73dba7d9b0 100644 --- a/src/Libraries/NRefactory/Test/Parser/TypeLevel/EventDeclarationTests.cs +++ b/src/Libraries/NRefactory/Test/Parser/TypeLevel/EventDeclarationTests.cs @@ -53,7 +53,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast Assert.IsFalse(ed.HasRemoveRegion); 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); } diff --git a/src/Libraries/NRefactory/Test/Parser/TypeLevel/FieldDeclarationTests.cs b/src/Libraries/NRefactory/Test/Parser/TypeLevel/FieldDeclarationTests.cs index eab75cdc60..3e9cd026ac 100644 --- a/src/Libraries/NRefactory/Test/Parser/TypeLevel/FieldDeclarationTests.cs +++ b/src/Libraries/NRefactory/Test/Parser/TypeLevel/FieldDeclarationTests.cs @@ -19,7 +19,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast public void CSharpSimpleFieldDeclarationTest() { FieldDeclaration fd = ParseUtilCSharp.ParseTypeMember("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(1, fd.Fields.Count); @@ -34,8 +34,8 @@ namespace ICSharpCode.NRefactory.Tests.Ast FieldDeclaration fd = ParseUtilVBNet.ParseTypeMember("myField As Integer(,,,)"); Assert.AreEqual(1, fd.Fields.Count); - Assert.AreEqual("Integer", ((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("System.Int32", ((VariableDeclaration)fd.Fields[0]).TypeReference.Type); Assert.AreEqual("myField", ((VariableDeclaration)fd.Fields[0]).Name); Assert.AreEqual(new int[] { 3 } , ((VariableDeclaration)fd.Fields[0]).TypeReference.RankSpecifier); } @@ -46,9 +46,9 @@ namespace ICSharpCode.NRefactory.Tests.Ast FieldDeclaration fd = ParseUtilVBNet.ParseTypeMember("a, b As String"); 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.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); } @@ -69,8 +69,8 @@ namespace ICSharpCode.NRefactory.Tests.Ast FieldDeclaration fd = ParseUtilVBNet.ParseTypeMember("Dim a, b() As String"); Assert.AreEqual(2, fd.Fields.Count); - Assert.AreEqual("String", ((VariableDeclaration)fd.Fields[0]).TypeReference.Type); - Assert.AreEqual("String", ((VariableDeclaration)fd.Fields[1]).TypeReference.Type); + Assert.AreEqual("System.String", ((VariableDeclaration)fd.Fields[0]).TypeReference.Type); + Assert.AreEqual("System.String", ((VariableDeclaration)fd.Fields[1]).TypeReference.Type); Assert.IsFalse(((VariableDeclaration)fd.Fields[0]).TypeReference.IsArrayType); Assert.IsTrue(((VariableDeclaration)fd.Fields[1]).TypeReference.IsArrayType); } @@ -81,8 +81,8 @@ namespace ICSharpCode.NRefactory.Tests.Ast FieldDeclaration fd = ParseUtilVBNet.ParseTypeMember("Dim a(), b As String"); Assert.AreEqual(2, fd.Fields.Count); - Assert.AreEqual("String", ((VariableDeclaration)fd.Fields[0]).TypeReference.Type); - Assert.AreEqual("String", ((VariableDeclaration)fd.Fields[1]).TypeReference.Type); + Assert.AreEqual("System.String", ((VariableDeclaration)fd.Fields[0]).TypeReference.Type); + Assert.AreEqual("System.String", ((VariableDeclaration)fd.Fields[1]).TypeReference.Type); Assert.IsTrue(((VariableDeclaration)fd.Fields[0]).TypeReference.IsArrayType); Assert.IsFalse(((VariableDeclaration)fd.Fields[1]).TypeReference.IsArrayType); } diff --git a/src/Libraries/NRefactory/Test/Parser/TypeLevel/IndexerDeclarationTests.cs b/src/Libraries/NRefactory/Test/Parser/TypeLevel/IndexerDeclarationTests.cs index a3269e8da5..a2e6dd17d7 100644 --- a/src/Libraries/NRefactory/Test/Parser/TypeLevel/IndexerDeclarationTests.cs +++ b/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.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 diff --git a/src/Libraries/NRefactory/Test/Parser/TypeLevel/MethodDeclarationTests.cs b/src/Libraries/NRefactory/Test/Parser/TypeLevel/MethodDeclarationTests.cs index 052ee0bd2e..393b10c8de 100644 --- a/src/Libraries/NRefactory/Test/Parser/TypeLevel/MethodDeclarationTests.cs +++ b/src/Libraries/NRefactory/Test/Parser/TypeLevel/MethodDeclarationTests.cs @@ -19,7 +19,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast public void CSharpSimpleMethodDeclarationTest() { MethodDeclaration md = ParseUtilCSharp.ParseTypeMember("void MyMethod() {} "); - Assert.AreEqual("void", md.TypeReference.Type); + Assert.AreEqual("System.Void", md.TypeReference.Type); Assert.AreEqual(0, md.Parameters.Count); Assert.IsFalse(md.IsExtensionMethod); } @@ -28,7 +28,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast public void CSharpAbstractMethodDeclarationTest() { MethodDeclaration md = ParseUtilCSharp.ParseTypeMember("abstract void MyMethod();"); - Assert.AreEqual("void", md.TypeReference.Type); + Assert.AreEqual("System.Void", md.TypeReference.Type); Assert.AreEqual(0, md.Parameters.Count); Assert.IsFalse(md.IsExtensionMethod); Assert.IsTrue(md.Body.IsNull); @@ -39,7 +39,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast public void CSharpDefiningPartialMethodDeclarationTest() { MethodDeclaration md = ParseUtilCSharp.ParseTypeMember("partial void MyMethod();"); - Assert.AreEqual("void", md.TypeReference.Type); + Assert.AreEqual("System.Void", md.TypeReference.Type); Assert.AreEqual(0, md.Parameters.Count); Assert.IsFalse(md.IsExtensionMethod); Assert.IsTrue(md.Body.IsNull); @@ -50,7 +50,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast public void CSharpImplementingPartialMethodDeclarationTest() { MethodDeclaration md = ParseUtilCSharp.ParseTypeMember("partial void MyMethod() { }"); - Assert.AreEqual("void", md.TypeReference.Type); + Assert.AreEqual("System.Void", md.TypeReference.Type); Assert.AreEqual(0, md.Parameters.Count); Assert.IsFalse(md.IsExtensionMethod); Assert.IsFalse(md.Body.IsNull); @@ -94,7 +94,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast public void CSharpMethodWithUnnamedParameterDeclarationTest() { MethodDeclaration md = ParseUtilCSharp.ParseTypeMember("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("?", ((ParameterDeclarationExpression)md.Parameters[0]).ParameterName); } @@ -103,7 +103,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast public void CSharpGenericVoidMethodDeclarationTest() { MethodDeclaration md = ParseUtilCSharp.ParseTypeMember("void MyMethod(T a) {} "); - Assert.AreEqual("void", md.TypeReference.Type); + Assert.AreEqual("System.Void", md.TypeReference.Type); Assert.AreEqual(1, md.Parameters.Count); Assert.AreEqual("T", ((ParameterDeclarationExpression)md.Parameters[0]).TypeReference.Type); Assert.AreEqual("a", ((ParameterDeclarationExpression)md.Parameters[0]).ParameterName); @@ -170,7 +170,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast "; TypeDeclaration td = ParseUtilCSharp.ParseGlobal(program); 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("T", ((ParameterDeclarationExpression)md.Parameters[0]).TypeReference.Type); Assert.AreEqual("a", ((ParameterDeclarationExpression)md.Parameters[0]).ParameterName); @@ -190,7 +190,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast "; TypeDeclaration td = ParseUtilCSharp.ParseGlobal(program); 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(Modifiers.New, md.Modifier); } @@ -199,7 +199,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast public void CSharpMethodImplementingInterfaceTest() { MethodDeclaration md = ParseUtilCSharp.ParseTypeMember("int MyInterface.MyMethod() {} "); - Assert.AreEqual("int", md.TypeReference.Type); + Assert.AreEqual("System.Int32", md.TypeReference.Type); Assert.AreEqual("MyInterface", md.InterfaceImplementations[0].InterfaceType.Type); } @@ -208,17 +208,17 @@ namespace ICSharpCode.NRefactory.Tests.Ast public void CSharpMethodImplementingGenericInterfaceTest() { MethodDeclaration md = ParseUtilCSharp.ParseTypeMember("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("System.String", md.InterfaceImplementations[0].InterfaceType.GenericTypes[0].SystemType); + Assert.AreEqual("System.String", md.InterfaceImplementations[0].InterfaceType.GenericTypes[0].Type); } [Test] public void CSharpVoidMethodImplementingInterfaceTest() { MethodDeclaration md = ParseUtilCSharp.ParseTypeMember("void MyInterface.MyMethod() {} "); - Assert.AreEqual("void", md.TypeReference.Type); + Assert.AreEqual("System.Void", md.TypeReference.Type); Assert.AreEqual("MyInterface", md.InterfaceImplementations[0].InterfaceType.Type); } @@ -227,10 +227,10 @@ namespace ICSharpCode.NRefactory.Tests.Ast public void CSharpVoidMethodImplementingGenericInterfaceTest() { MethodDeclaration md = ParseUtilCSharp.ParseTypeMember("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("System.String", md.InterfaceImplementations[0].InterfaceType.GenericTypes[0].SystemType); + Assert.AreEqual("System.String", md.InterfaceImplementations[0].InterfaceType.GenericTypes[0].Type); } [Test] @@ -254,7 +254,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast Assert.AreEqual("ToInt32", md.Name); Assert.IsTrue(md.IsExtensionMethod); 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] @@ -266,7 +266,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast Assert.AreEqual("Print", md.Name); Assert.IsTrue(md.IsExtensionMethod); 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] @@ -316,7 +316,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast public void VBNetGenericFunctionMethodDeclarationTest() { MethodDeclaration md = ParseUtilVBNet.ParseTypeMember("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("T", ((ParameterDeclarationExpression)md.Parameters[0]).TypeReference.Type); Assert.AreEqual("a", ((ParameterDeclarationExpression)md.Parameters[0]).ParameterName); @@ -369,7 +369,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast // Assert.IsTrue(md.IsExtensionMethod); 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] @@ -400,7 +400,7 @@ End Interface "; TypeDeclaration td = ParseUtilVBNet.ParseGlobal(program); 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("T", ((ParameterDeclarationExpression)md.Parameters[0]).TypeReference.Type); Assert.AreEqual("a", ((ParameterDeclarationExpression)md.Parameters[0]).ParameterName); diff --git a/src/Libraries/NRefactory/Test/Parser/TypeLevel/OperatorDeclarationTests.cs b/src/Libraries/NRefactory/Test/Parser/TypeLevel/OperatorDeclarationTests.cs index 7d69352214..219f5731d0 100644 --- a/src/Libraries/NRefactory/Test/Parser/TypeLevel/OperatorDeclarationTests.cs +++ b/src/Libraries/NRefactory/Test/Parser/TypeLevel/OperatorDeclarationTests.cs @@ -22,7 +22,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast Assert.IsTrue(od.IsConversionOperator); Assert.AreEqual(1, od.Parameters.Count); Assert.AreEqual(ConversionType.Implicit, od.ConversionType); - Assert.AreEqual("double", od.TypeReference.Type); + Assert.AreEqual("System.Double", od.TypeReference.Type); } [Test] @@ -32,7 +32,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast Assert.IsTrue(od.IsConversionOperator); Assert.AreEqual(1, od.Parameters.Count); Assert.AreEqual(ConversionType.Explicit, od.ConversionType); - Assert.AreEqual("double", od.TypeReference.Type); + Assert.AreEqual("System.Double", od.TypeReference.Type); } [Test] diff --git a/src/Libraries/NRefactory/Test/Parser/TypeLevel/PropertyDeclarationTests.cs b/src/Libraries/NRefactory/Test/Parser/TypeLevel/PropertyDeclarationTests.cs index 56d125ea90..4d8d07786a 100644 --- a/src/Libraries/NRefactory/Test/Parser/TypeLevel/PropertyDeclarationTests.cs +++ b/src/Libraries/NRefactory/Test/Parser/TypeLevel/PropertyDeclarationTests.cs @@ -103,7 +103,7 @@ namespace ICSharpCode.NRefactory.Tests.Ast Assert.IsTrue(!pd.HasSetRegion); 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 diff --git a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/CSharpToVBNetConvertVisitor.cs b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/CSharpToVBNetConvertVisitor.cs index 97d6585363..a41889d0f1 100644 --- a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/CSharpToVBNetConvertVisitor.cs +++ b/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) { while (typeReference.PointerNestingLevel > 0) { - TypeReference tr = new TypeReference(typeReference.Type, typeReference.SystemType) { + TypeReference tr = new TypeReference(typeReference.Type) { + IsKeyword = typeReference.IsKeyword, IsGlobal = typeReference.IsGlobal, }; tr.GenericTypes.AddRange(typeReference.GenericTypes); diff --git a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/NRefactoryResolver.cs b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/NRefactoryResolver.cs index 04345dc944..4d4744c509 100644 --- a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/NRefactoryResolver.cs +++ b/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; } } else if (expr is TypeReferenceExpression) { - return (expr as TypeReferenceExpression).TypeReference.SystemType; + return (expr as TypeReferenceExpression).TypeReference.Type; } return null; } diff --git a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/ResolveVisitor.cs b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/ResolveVisitor.cs index f75644f8f6..2b99d041cd 100644 --- a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/ResolveVisitor.cs +++ b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/ResolveVisitor.cs @@ -527,7 +527,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver return null; PointerReturnType type = targetRR.ResolvedType.CastToDecoratingReturnType(); if (type != null) { - return resolver.ResolveMember(type.BaseType, pointerReferenceExpression.Identifier, + return resolver.ResolveMember(type.BaseType, pointerReferenceExpression.MemberName, pointerReferenceExpression.TypeArguments, NRefactoryResolver.IsInvoked(pointerReferenceExpression), true, null diff --git a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/TypeVisitor.cs b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/TypeVisitor.cs index 69a17d7ab2..aefb823405 100644 --- a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/TypeVisitor.cs +++ b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/TypeVisitor.cs @@ -42,14 +42,14 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver IReturnType t = null; if (callingClass != null && !reference.IsGlobal) { 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); break; } } if (t == null && callingMember is IMethod && (callingMember as IMethod).TypeParameters != null) { 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); break; } @@ -57,27 +57,27 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver } } if (t == null) { - if (reference.Type != reference.SystemType) { + if (reference.Type != reference.Type) { // keyword-type like void, int, string etc. - IClass c = projectContent.GetClass(reference.SystemType, 0); + IClass c = projectContent.GetClass(reference.Type, 0); if (c != null) t = c.DefaultReturnType; else - t = new GetClassReturnType(projectContent, reference.SystemType, 0); + t = new GetClassReturnType(projectContent, reference.Type, 0); } else { int typeParameterCount = reference.GenericTypes.Count; if (useLazyReturnType) { - if (reference.IsGlobal) - t = new GetClassReturnType(projectContent, reference.SystemType, typeParameterCount); + if (reference.IsGlobal || reference.IsKeyword) + t = new GetClassReturnType(projectContent, reference.Type, typeParameterCount); 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 { IClass c; - if (reference.IsGlobal) { - c = projectContent.GetClass(reference.SystemType, typeParameterCount); + if (reference.IsGlobal || reference.IsKeyword) { + c = projectContent.GetClass(reference.Type, typeParameterCount); t = (c != null) ? c.DefaultReturnType : 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) { return null; diff --git a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/VBNetToCSharpConvertVisitor.cs b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/VBNetToCSharpConvertVisitor.cs index 465d5af1c6..88de5283b0 100644 --- a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/VBNetToCSharpConvertVisitor.cs +++ b/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 (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) { IClass c = rt.GetUnderlyingClass(); if (c != null) { diff --git a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Refactoring/CodeGenerator.cs b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Refactoring/CodeGenerator.cs index 95cc86ee3a..084198fc29 100644 --- a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Refactoring/CodeGenerator.cs +++ b/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; 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); else typeRef = new TypeReference(returnType.FullyQualifiedName); @@ -63,6 +65,11 @@ namespace ICSharpCode.SharpDevelop.Dom.Refactoring return typeRef; } + static bool IsPrimitiveType(IReturnType returnType) + { + return TypeReference.PrimitiveTypesCSharpReverse.ContainsKey(returnType.FullyQualifiedName); + } + /// /// 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 @@ -71,25 +78,6 @@ namespace ICSharpCode.SharpDevelop.Dom.Refactoring /// 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; IReturnType typeInTargetContext = context.SearchType(returnType.Name, typeArgumentCount); return typeInTargetContext != null && typeInTargetContext.FullyQualifiedName == returnType.FullyQualifiedName; @@ -611,7 +599,7 @@ namespace ICSharpCode.SharpDevelop.Dom.Refactoring MethodDeclaration method = node as MethodDeclaration; if (method != null) { method.Body.Children.Clear(); - if (method.TypeReference.SystemType == "System.Void") { + if (method.TypeReference.Type == "System.Void") { method.Body.AddChild(new ExpressionStatement(CreateForwardingMethodCall(method))); } else { method.Body.AddChild(new ReturnStatement(CreateForwardingMethodCall(method))); diff --git a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Refactoring/NRefactoryRefactoringProvider.cs b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Refactoring/NRefactoryRefactoringProvider.cs index 41e47ff202..bd76590c25 100644 --- a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Refactoring/NRefactoryRefactoringProvider.cs +++ b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Refactoring/NRefactoryRefactoringProvider.cs @@ -368,7 +368,7 @@ namespace ICSharpCode.SharpDevelop.Dom.Refactoring public PossibleTypeReference(TypeReference tr) { - this.Name = tr.SystemType; + this.Name = tr.Type; this.TypeParameterCount = tr.GenericTypes.Count; }