From f6a93c81ab035b5f4389791397a3b8e5e38c8e58 Mon Sep 17 00:00:00 2001 From: Fabrice Foray Date: Tue, 29 Dec 2020 23:17:51 +0100 Subject: [PATCH] First ILSpy 6 Version --- .../ILSpy.XSharpLanguage.xsproj | 12 ++-- .../XSharpHighlightingTokenWriter.prg | 6 +- ILSpy.XSharpLanguage/XSharpLanguage.prg | 6 +- ILSpy.XSharpLanguage/XSharpLocalVisitor.prg | 8 ++- ILSpy.XSharpLanguage/XSharpOutputVisitor.prg | 63 ++++++++++--------- 5 files changed, 52 insertions(+), 43 deletions(-) diff --git a/ILSpy.XSharpLanguage/ILSpy.XSharpLanguage.xsproj b/ILSpy.XSharpLanguage/ILSpy.XSharpLanguage.xsproj index 043ba4b..ea2f2fc 100644 --- a/ILSpy.XSharpLanguage/ILSpy.XSharpLanguage.xsproj +++ b/ILSpy.XSharpLanguage/ILSpy.XSharpLanguage.xsproj @@ -74,12 +74,12 @@ True ..\ILSpy6\ILSpy.exe - + Microsoft.VisualStudio.Composition Microsoft.VisualStudio.Composition.dll False True - ..\packages\Microsoft.VisualStudio.Composition.15.5.23\lib\net45\Microsoft.VisualStudio.Composition.dll + ..\ILSpy6\Microsoft.VisualStudio.Composition.dll Microsoft.VisualStudio.Validation @@ -157,19 +157,19 @@ - + System.Reflection.Metadata System.Reflection.Metadata.dll False True - ..\ILSpy4\System.Reflection.Metadata.dll + ..\ILSpy6\System.Reflection.Metadata.dll - + System.Threading.Tasks.Dataflow System.Threading.Tasks.Dataflow.dll False True - ..\packages\System.Threading.Tasks.Dataflow.4.5.24\lib\portable-net45+win8+wpa81\System.Threading.Tasks.Dataflow.dll + ..\ILSpy6\System.Threading.Tasks.Dataflow.dll System.Xaml diff --git a/ILSpy.XSharpLanguage/XSharpHighlightingTokenWriter.prg b/ILSpy.XSharpLanguage/XSharpHighlightingTokenWriter.prg index db1e049..b450b85 100644 --- a/ILSpy.XSharpLanguage/XSharpHighlightingTokenWriter.prg +++ b/ILSpy.XSharpLanguage/XSharpHighlightingTokenWriter.prg @@ -550,7 +550,7 @@ BEGIN NAMESPACE ILSpy.XSharpLanguage SELF:textOutput:EndSpan() ENDIF - VIRTUAL METHOD WritePrimitiveValue(VALUE AS OBJECT, literalValue := NULL AS STRING) AS VOID + VIRTUAL METHOD WritePrimitiveValue(VALUE AS OBJECT, format := LiteralFormat.None AS LiteralFormat ) AS VOID LOCAL color AS HighlightingColor // color := NULL @@ -568,9 +568,9 @@ BEGIN NAMESPACE ILSpy.XSharpLanguage ENDIF // Indicate to XSharp to keep the String as it is IF ( VALUE IS STRING ) - SUPER:WritePrimitiveValue( NULL, "e" ) + SUPER:WritePrimitiveValue( "e" ) ENDIF - SUPER:WritePrimitiveValue(VALUE, literalValue) + SUPER:WritePrimitiveValue(VALUE ) IF (color != NULL) // SELF:textOutput:EndSpan() diff --git a/ILSpy.XSharpLanguage/XSharpLanguage.prg b/ILSpy.XSharpLanguage/XSharpLanguage.prg index 75c5ddf..5207fb8 100644 --- a/ILSpy.XSharpLanguage/XSharpLanguage.prg +++ b/ILSpy.XSharpLanguage/XSharpLanguage.prg @@ -481,14 +481,12 @@ BEGIN NAMESPACE ILSpy.XSharpLanguage CLASS XSharpWholeProjectDecompiler INHERIT WholeProjectDecompiler PRIVATE INITONLY assembly AS LoadedAssembly - PRIVATE INITONLY options AS DecompilationOptions PUBLIC CONSTRUCTOR(assembly AS LoadedAssembly , options AS DecompilationOptions ) + SUPER(options:DecompilerSettings, assembly:GetAssemblyResolver(), assembly:GetDebugInfoOrNull() ) SELF:assembly := assembly SELF:options := options - SUPER:Settings := options:DecompilerSettings - SUPER:AssemblyResolver := assembly:GetAssemblyResolver() PROTECTED OVERRIDE METHOD WriteResourceToFile(fileName AS STRING , resourceName AS STRING , entryStream AS Stream ) AS IEnumerable> @@ -498,7 +496,7 @@ BEGIN NAMESPACE ILSpy.XSharpLanguage entryStream:Position := 0L fileName := Path.Combine(targetDirectory, fileName) fileName := exportedValue:WriteResourceToFile(SELF:assembly, fileName, entryStream, SELF:options) - RETURN ValueTuple{ ValueTuple.Create(exportedValue:EntryType, fileName) } + RETURN >{ ValueTuple.Create(exportedValue:EntryType, fileName) } ENDIF NEXT RETURN SUPER:WriteResourceToFile(fileName, resourceName, entryStream) diff --git a/ILSpy.XSharpLanguage/XSharpLocalVisitor.prg b/ILSpy.XSharpLanguage/XSharpLocalVisitor.prg index 6adbdfd..97a16e4 100644 --- a/ILSpy.XSharpLanguage/XSharpLocalVisitor.prg +++ b/ILSpy.XSharpLanguage/XSharpLocalVisitor.prg @@ -286,6 +286,8 @@ BEGIN NAMESPACE ILSpy.XSharpLanguage VIRTUAL METHOD VisitParameterDeclaration(parameterDeclaration AS ParameterDeclaration) AS VOID VIRTUAL METHOD VisitParenthesizedExpression(parenthesizedExpression AS ParenthesizedExpression) AS VOID + + VIRTUAL METHOD VisitParenthesizedVariableDesignation( parenthesizedVariableDesignation AS ParenthesizedVariableDesignation ) AS VOID VIRTUAL METHOD VisitPatternPlaceholder(placeholder AS AstNode, pattern AS Pattern) AS VOID @@ -325,6 +327,8 @@ BEGIN NAMESPACE ILSpy.XSharpLanguage VIRTUAL METHOD VisitSimpleType(simpleType AS SimpleType) AS VOID // SELF:WriteIdentifier(simpleType:IdentifierToken) + + VIRTUAL METHOD VisitSingleVariableDesignation( singleVariableDesignation AS SingleVariableDesignation ) AS VOID VIRTUAL METHOD VisitSizeOfExpression(sizeOfExpression AS SizeOfExpression) AS VOID @@ -332,13 +336,13 @@ BEGIN NAMESPACE ILSpy.XSharpLanguage VIRTUAL METHOD VisitSwitchExpression( switchExpression AS SwitchExpression ) AS VOID switchExpression:Expression:AcceptVisitor(SELF) - FOREACH node AS AstNode IN switchExpression.SwitchSections + FOREACH node AS AstNode IN switchExpression:SwitchSections node.AcceptVisitor(SELF) NEXT VIRTUAL METHOD VisitSwitchExpressionSection( switchExpressionSection AS SwitchExpressionSection) AS VOID switchExpressionSection:Pattern:AcceptVisitor(SELF) - switchExpressionSection.Body:AcceptVisitor(SELF) + switchExpressionSection:Body:AcceptVisitor(SELF) VIRTUAL METHOD VisitSwitchSection(switchSection AS SwitchSection) AS VOID FOREACH statement AS Statement IN switchSection:Statements diff --git a/ILSpy.XSharpLanguage/XSharpOutputVisitor.prg b/ILSpy.XSharpLanguage/XSharpOutputVisitor.prg index e9dfcb0..6bee918 100644 --- a/ILSpy.XSharpLanguage/XSharpOutputVisitor.prg +++ b/ILSpy.XSharpLanguage/XSharpOutputVisitor.prg @@ -314,10 +314,10 @@ BEGIN NAMESPACE ILSpy.XSharpLanguage LOCAL i AS LONG // nextSibling := node:NextSibling - WHILE (((nextSibling IS WhitespaceNode) .OR. (nextSibling IS NewLineNode))) - // - nextSibling := nextSibling:NextSibling - ENDDO +// WHILE (((nextSibling IS WhitespaceNode) .OR. (nextSibling IS NewLineNode))) +// // +// nextSibling := nextSibling:NextSibling +// ENDDO IF (((node IS UsingDeclaration) .OR. (node IS UsingAliasDeclaration)) .AND. (! (nextSibling IS UsingDeclaration) .AND. ! (nextSibling IS UsingAliasDeclaration))) // i := 0 @@ -1337,7 +1337,8 @@ BEGIN NAMESPACE ILSpy.XSharpLanguage SELF:StartNode(foreachStatement) SELF:WriteKeyword("FOREACH") SELF:Space() - SELF:WriteIdentifier(foreachStatement:VariableNameToken) + //SELF:WriteIdentifier(foreachStatement:VariableNameToken) + foreachStatement:VariableDesignation:AcceptVisitor(SELF) SELF:Space() SELF:WriteKeyword("AS") SELF:Space() @@ -1407,7 +1408,7 @@ BEGIN NAMESPACE ILSpy.XSharpLanguage ENDIF //SELF:WriteToken(Roles.LChevron) SELF:WriteCommaSeparatedList(; - functionPointerType:Parameters:Concat(NEW[] { functionPointerType.ReturnType })) + functionPointerType:Parameters:Concat({ functionPointerType:ReturnType })) //SELF:WriteToken(Roles.RChevron) SELF:EndNode(functionPointerType) @@ -1554,7 +1555,7 @@ BEGIN NAMESPACE ILSpy.XSharpLanguage VIRTUAL METHOD VisitInterpolatedStringText(interpolatedStringText AS InterpolatedStringText) AS VOID // SELF:StartNode(interpolatedStringText) - SELF:writer:WritePrimitiveValue("", TextWriterTokenWriter.ConvertString(interpolatedStringText:Text)) + SELF:writer:WritePrimitiveValue(TextWriterTokenWriter.ConvertString(interpolatedStringText:Text)) SELF:EndNode(interpolatedStringText) VIRTUAL METHOD VisitInterpolation(interpolation AS Interpolation) AS VOID @@ -1565,7 +1566,7 @@ BEGIN NAMESPACE ILSpy.XSharpLanguage IF (interpolation:Suffix != NULL) // SELF:writer:WriteToken(NULL, ":") - SELF:writer:WritePrimitiveValue("", interpolation:Suffix) + SELF:writer:WritePrimitiveValue( interpolation:Suffix) ENDIF SELF:writer:WriteToken(Interpolation.RBrace, "}") SELF:EndNode(interpolation) @@ -1654,17 +1655,18 @@ BEGIN NAMESPACE ILSpy.XSharpLanguage VIRTUAL METHOD VisitLocalFunctionDeclarationStatement(localFunctionDeclarationStatement AS LocalFunctionDeclarationStatement ) AS VOID SELF:StartNode(localFunctionDeclarationStatement) - SELF:WriteModifiers(localFunctionDeclarationStatement:ModifierTokens) - localFunctionDeclarationStatement:ReturnType:AcceptVisitor(SELF) - SELF:Space() - SELF:WriteIdentifier(localFunctionDeclarationStatement:NameToken) - SELF:WriteTypeParameters(localFunctionDeclarationStatement:TypeParameters) - SELF:Space(SELF:policy:SpaceBeforeMethodDeclarationParentheses) - SELF:WriteCommaSeparatedListInParenthesis(localFunctionDeclarationStatement:Parameters, SELF:policy:SpaceWithinMethodDeclarationParentheses) - FOREACH constraint AS Constraint IN localFunctionDeclarationStatement:Constraints - constraint:AcceptVisitor(SELF) - NEXT - SELF:WriteMethodBody(localFunctionDeclarationStatement:Body, SELF:policy:MethodBraceStyle) +// SELF:WriteModifiers(localFunctionDeclarationStatement:ModifierTokens) +// localFunctionDeclarationStatement:ReturnType:AcceptVisitor(SELF) +// SELF:Space() +// SELF:WriteIdentifier(localFunctionDeclarationStatement:NameToken) +// SELF:WriteTypeParameters(localFunctionDeclarationStatement:TypeParameters) +// SELF:Space(SELF:policy:SpaceBeforeMethodDeclarationParentheses) +// SELF:WriteCommaSeparatedListInParenthesis(localFunctionDeclarationStatement:Parameters, SELF:policy:SpaceWithinMethodDeclarationParentheses) +// FOREACH constraint AS Constraint IN localFunctionDeclarationStatement:Constraints +// constraint:AcceptVisitor(SELF) +// NEXT +// SELF:WriteMethodBody(localFunctionDeclarationStatement:Body, SELF:policy:MethodBraceStyle) + localFunctionDeclarationStatement:Declaration:AcceptVisitor(SELF) SELF:EndNode(localFunctionDeclarationStatement) @@ -1860,7 +1862,7 @@ BEGIN NAMESPACE ILSpy.XSharpLanguage VIRTUAL METHOD VisitNullReferenceExpression(nullReferenceExpression AS NullReferenceExpression) AS VOID // SELF:StartNode(nullReferenceExpression) - SELF:writer:WritePrimitiveValue(NULL, NULL) + SELF:writer:WritePrimitiveValue(NULL) SELF:isAfterSpace := FALSE SELF:EndNode(nullReferenceExpression) @@ -2014,6 +2016,8 @@ BEGIN NAMESPACE ILSpy.XSharpLanguage SELF:Space(SELF:policy:SpacesWithinParentheses) SELF:RPar() SELF:EndNode(parenthesizedExpression) + + VIRTUAL METHOD VisitParenthesizedVariableDesignation( parenthesizedVariableDesignation AS ParenthesizedVariableDesignation ) AS VOID VIRTUAL METHOD VisitPatternPlaceholder(placeholder AS AstNode, pattern AS Pattern) AS VOID // @@ -2039,12 +2043,13 @@ BEGIN NAMESPACE ILSpy.XSharpLanguage VIRTUAL METHOD VisitPrimitiveExpression(primitiveExpression AS PrimitiveExpression) AS VOID // SELF:StartNode(primitiveExpression) - SELF:writer:WritePrimitiveValue(primitiveExpression:Value, primitiveExpression:UnsafeLiteralValue) - // Store Parameters Name - IF ( SELF:inMethodAttributes == ClipperState.Attribute) .AND. SELF:isClipper - SELF:paramsList:Add( primitiveExpression:Value:ToString() ) - ENDIF - // +// SELF:writer:WritePrimitiveValue(primitiveExpression:Value, primitiveExpression:UnsafeLiteralValue) +// // Store Parameters Name +// IF ( SELF:inMethodAttributes == ClipperState.Attribute) .AND. SELF:isClipper +// SELF:paramsList:Add( primitiveExpression:Value:ToString() ) +// ENDIF +// // + SELF:writer:WritePrimitiveValue(primitiveExpression:Value, primitiveExpression:Format ) SELF:isAfterSpace := FALSE SELF:EndNode(primitiveExpression) @@ -2347,6 +2352,8 @@ BEGIN NAMESPACE ILSpy.XSharpLanguage ENDIF SELF:WriteTypeArguments(simpleType:TypeArguments) SELF:EndNode(simpleType) + + VIRTUAL METHOD VisitSingleVariableDesignation( singleVariableDesignation AS SingleVariableDesignation ) AS VOID VIRTUAL METHOD VisitSizeOfExpression(sizeOfExpression AS SizeOfExpression) AS VOID // @@ -2374,7 +2381,7 @@ BEGIN NAMESPACE ILSpy.XSharpLanguage switchExpression:Expression:AcceptVisitor(SELF) SELF:Space() SELF:WriteKeyword(SwitchExpression.SwitchKeywordRole) - FOREACH node AS AstNode IN switchExpression.SwitchSections + FOREACH node AS AstNode IN switchExpression:SwitchSections node.AcceptVisitor(SELF) SELF:Comma(node) SELF:NewLine() @@ -2387,7 +2394,7 @@ BEGIN NAMESPACE ILSpy.XSharpLanguage SELF:Space() SELF:WriteToken(Roles.Arrow) SELF:Space() - switchExpressionSection.Body:AcceptVisitor(SELF) + switchExpressionSection:Body:AcceptVisitor(SELF) SELF:EndNode(switchExpressionSection) VIRTUAL METHOD VisitSwitchSection(switchSection AS SwitchSection) AS VOID