Skip to content

Commit

Permalink
First ILSpy 6 Version
Browse files Browse the repository at this point in the history
  • Loading branch information
fforay committed Dec 29, 2020
1 parent 56b91b7 commit f6a93c8
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 43 deletions.
12 changes: 6 additions & 6 deletions ILSpy.XSharpLanguage/ILSpy.XSharpLanguage.xsproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@
<Private>True</Private>
<HintPath>..\ILSpy6\ILSpy.exe</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Composition, Version=15.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Reference Include="Microsoft.VisualStudio.Composition, Version=16.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Name>Microsoft.VisualStudio.Composition</Name>
<AssemblyName>Microsoft.VisualStudio.Composition.dll</AssemblyName>
<SpecificVersion>False</SpecificVersion>
<Private>True</Private>
<HintPath>..\packages\Microsoft.VisualStudio.Composition.15.5.23\lib\net45\Microsoft.VisualStudio.Composition.dll</HintPath>
<HintPath>..\ILSpy6\Microsoft.VisualStudio.Composition.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Validation, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Name>Microsoft.VisualStudio.Validation</Name>
Expand Down Expand Up @@ -157,19 +157,19 @@
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Reflection.Metadata, Version=1.4.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Reference Include="System.Reflection.Metadata, Version=1.4.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Name>System.Reflection.Metadata</Name>
<AssemblyName>System.Reflection.Metadata.dll</AssemblyName>
<SpecificVersion>False</SpecificVersion>
<Private>True</Private>
<HintPath>..\ILSpy4\System.Reflection.Metadata.dll</HintPath>
<HintPath>..\ILSpy6\System.Reflection.Metadata.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Dataflow, Version=4.5.24.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Reference Include="System.Threading.Tasks.Dataflow, Version=4.6.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Name>System.Threading.Tasks.Dataflow</Name>
<AssemblyName>System.Threading.Tasks.Dataflow.dll</AssemblyName>
<SpecificVersion>False</SpecificVersion>
<Private>True</Private>
<HintPath>..\packages\System.Threading.Tasks.Dataflow.4.5.24\lib\portable-net45+win8+wpa81\System.Threading.Tasks.Dataflow.dll</HintPath>
<HintPath>..\ILSpy6\System.Threading.Tasks.Dataflow.dll</HintPath>
</Reference>
<Reference Include="System.Xaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<Name>System.Xaml</Name>
Expand Down
6 changes: 3 additions & 3 deletions ILSpy.XSharpLanguage/XSharpHighlightingTokenWriter.prg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down
6 changes: 2 additions & 4 deletions ILSpy.XSharpLanguage/XSharpLanguage.prg
Original file line number Diff line number Diff line change
Expand Up @@ -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<ValueTuple<STRING, STRING>>
Expand All @@ -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<STRING, STRING>{ ValueTuple.Create(exportedValue:EntryType, fileName) }
RETURN <ValueTuple<STRING, STRING>>{ ValueTuple.Create<STRING, STRING>(exportedValue:EntryType, fileName) }
ENDIF
NEXT
RETURN SUPER:WriteResourceToFile(fileName, resourceName, entryStream)
Expand Down
8 changes: 6 additions & 2 deletions ILSpy.XSharpLanguage/XSharpLocalVisitor.prg
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -325,20 +327,22 @@ 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

VIRTUAL METHOD VisitStackAllocExpression(stackAllocExpression AS StackAllocExpression) AS VOID

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
Expand Down
63 changes: 35 additions & 28 deletions ILSpy.XSharpLanguage/XSharpOutputVisitor.prg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -1407,7 +1408,7 @@ BEGIN NAMESPACE ILSpy.XSharpLanguage
ENDIF
//SELF:WriteToken(Roles.LChevron)
SELF:WriteCommaSeparatedList(;
functionPointerType:Parameters:Concat<AstNode>(NEW[] { functionPointerType.ReturnType }))
functionPointerType:Parameters:Concat<AstNode>(<AstNode>{ functionPointerType:ReturnType }))
//SELF:WriteToken(Roles.RChevron)
SELF:EndNode(functionPointerType)

Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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)


Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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
//
Expand All @@ -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)

Expand Down Expand Up @@ -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
//
Expand Down Expand Up @@ -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()
Expand All @@ -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
Expand Down

3 comments on commit f6a93c8

@RobertvanderHulst
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fabrice, there is a problem with string literals in this build (maybe also with the build for IL Spy 5).
I decoded the plugin itself.
The code for one of the Roles is in X#:

public static initonly AliasKeyword := TokenRole{"e""alias"} as TokenRole
In C# this looks like:

public static readonly TokenRole AliasKeyword = new TokenRole("alias");

I see 2 problems:

  1. the e is also quoted
  2. there is no real need to use an e"..." here. This is a smaller problem.

@fforay
Copy link
Member Author

@fforay fforay commented on f6a93c8 Dec 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohhhh :(, yes you are right.
I does only happen in V6, I mean the number 1 (e also quoted)... I will correct that asap.

For number 2, my trouble actually is that I just know that I'm manipulating a String, but not if it does contain some escaped sequences, so I'm always adding the e...just to be sure ;)

@RobertvanderHulst
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fabrice
No problem.
A tip for the next release:
Send it to Chris and me first. We’re quite good in “breaking“ things. :)

Please sign in to comment.