Browse Source

Adjust ILSpy to new NRefactory version.

pull/297/head
Daniel Grunwald 14 years ago
parent
commit
49c92cfba8
  1. 5
      ICSharpCode.Decompiler/Ast/AstMethodBodyBuilder.cs
  2. 189
      ICSharpCode.Decompiler/Ast/CecilTypeResolveContext.cs
  3. 12
      ICSharpCode.Decompiler/Ast/Transforms/CombineQueryExpressions.cs
  4. 5
      ICSharpCode.Decompiler/Ast/Transforms/ConvertConstructorCallIntoInitializer.cs
  5. 7
      ICSharpCode.Decompiler/Ast/Transforms/DelegateConstruction.cs
  6. 46
      ICSharpCode.Decompiler/Ast/Transforms/PatternStatementTransform.cs
  7. 1
      ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj
  8. 6
      ILSpy/Properties/app.config.template
  9. 17
      ILSpy/VB/ILSpyEnvironmentProvider.cs
  10. 20
      ILSpy/VB/VBLanguage.cs
  11. 5
      NRefactory/ICSharpCode.NRefactory.VB/Visitors/CSharpToVBConverterVisitor.cs

5
ICSharpCode.Decompiler/Ast/AstMethodBodyBuilder.cs

@ -135,7 +135,7 @@ namespace ICSharpCode.Decompiler.Ast @@ -135,7 +135,7 @@ namespace ICSharpCode.Decompiler.Ast
Ast.BlockStatement astBlock = new BlockStatement();
if (block != null) {
foreach(ILNode node in block.GetChildren()) {
astBlock.AddRange(TransformNode(node));
astBlock.Statements.AddRange(TransformNode(node));
}
}
return astBlock;
@ -864,7 +864,8 @@ namespace ICSharpCode.Decompiler.Ast @@ -864,7 +864,8 @@ namespace ICSharpCode.Decompiler.Ast
static readonly AstNode objectInitializerPattern = new AssignmentExpression(
new MemberReferenceExpression {
Target = new InitializedObjectExpression()
Target = new InitializedObjectExpression(),
MemberName = Pattern.AnyString
}.WithName("left"),
new AnyNode("right")
);

189
ICSharpCode.Decompiler/Ast/CecilTypeResolveContext.cs

@ -1,189 +0,0 @@ @@ -1,189 +0,0 @@
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.TypeSystem;
using Mono.Cecil;
namespace ICSharpCode.Decompiler.Ast
{
/// <summary>
/// ITypeResolveContext implementation that lazily loads types from Cecil.
/// </summary>
public class CecilTypeResolveContext : AbstractAnnotatable, ISynchronizedTypeResolveContext, IProjectContent
{
readonly ModuleDefinition module;
readonly string[] namespaces;
readonly CecilLoader loader;
Dictionary<TypeDefinition, WeakReference> dict = new Dictionary<TypeDefinition, WeakReference>();
int countUntilNextCleanup = 4;
public CecilTypeResolveContext(ModuleDefinition module)
{
this.loader = new CecilLoader();
this.loader.IncludeInternalMembers = true;
this.module = module;
this.namespaces = module.Types.Select(t => t.Namespace).Distinct().ToArray();
List<IAttribute> assemblyAttributes = new List<IAttribute>();
foreach (var attr in module.Assembly.CustomAttributes) {
assemblyAttributes.Add(loader.ReadAttribute(attr));
}
this.AssemblyAttributes = assemblyAttributes.AsReadOnly();
}
ITypeDefinition GetClass(TypeDefinition cecilType)
{
lock (dict) {
WeakReference wr;
ITypeDefinition type;
if (dict.TryGetValue(cecilType, out wr)) {
type = (ITypeDefinition)wr.Target;
} else {
wr = null;
type = null;
}
if (type == null) {
type = loader.LoadType(cecilType, this);
}
if (wr == null) {
if (--countUntilNextCleanup <= 0)
CleanupDict();
wr = new WeakReference(type);
dict.Add(cecilType, wr);
} else {
wr.Target = type;
}
return type;
}
}
void CleanupDict()
{
List<TypeDefinition> deletedKeys = new List<TypeDefinition>();
foreach (var pair in dict) {
if (!pair.Value.IsAlive) {
deletedKeys.Add(pair.Key);
}
}
foreach (var key in deletedKeys) {
dict.Remove(key);
}
countUntilNextCleanup = dict.Count + 4;
}
public string AssemblyName {
get { return module.Assembly.Name.Name; }
}
public IList<IAttribute> ModuleAttributes { get; private set; }
public IList<IAttribute> AssemblyAttributes { get; private set; }
public ITypeDefinition GetTypeDefinition(string nameSpace, string name, int typeParameterCount, StringComparer nameComparer)
{
if (typeParameterCount > 0)
name = name + "`" + typeParameterCount.ToString();
if (nameComparer == StringComparer.Ordinal) {
TypeDefinition cecilType = module.GetType(nameSpace, name);
if (cecilType != null)
return GetClass(cecilType);
else
return null;
}
foreach (TypeDefinition cecilType in module.Types) {
if (nameComparer.Equals(name, cecilType.Name)
&& nameComparer.Equals(nameSpace, cecilType.Namespace)
&& cecilType.GenericParameters.Count == typeParameterCount)
{
return GetClass(cecilType);
}
}
return null;
}
public ITypeDefinition GetKnownTypeDefinition(TypeCode typeCode)
{
return GetTypeDefinition("System", ReflectionHelper.GetShortNameByTypeCode(typeCode), 0, StringComparer.Ordinal);
}
public IEnumerable<ITypeDefinition> GetTypes()
{
foreach (TypeDefinition cecilType in module.Types) {
yield return GetClass(cecilType);
}
}
public IEnumerable<ITypeDefinition> GetTypes(string nameSpace, StringComparer nameComparer)
{
foreach (TypeDefinition cecilType in module.Types) {
if (nameComparer.Equals(nameSpace, cecilType.Namespace))
yield return GetClass(cecilType);
}
}
public IEnumerable<string> GetNamespaces()
{
return namespaces;
}
public string GetNamespace(string nameSpace, StringComparer nameComparer)
{
foreach (string ns in namespaces) {
if (nameComparer.Equals(ns, nameSpace))
return ns;
}
return null;
}
ICSharpCode.NRefactory.Utils.CacheManager ITypeResolveContext.CacheManager {
get {
// We don't support caching
return null;
}
}
ISynchronizedTypeResolveContext ITypeResolveContext.Synchronize()
{
// This class is logically immutable
return this;
}
void IDisposable.Dispose()
{
// exit from Synchronize() block
}
IEnumerable<IParsedFile> IProjectContent.Files {
get { return new IParsedFile[0]; }
}
void IProjectContent.UpdateProjectContent(IParsedFile oldFile, IParsedFile newFile)
{
throw new NotSupportedException();
}
IParsedFile IProjectContent.GetFile(string fileName)
{
return null;
}
}
}

12
ICSharpCode.Decompiler/Ast/Transforms/CombineQueryExpressions.cs

@ -81,13 +81,19 @@ namespace ICSharpCode.Decompiler.Ast.Transforms @@ -81,13 +81,19 @@ namespace ICSharpCode.Decompiler.Ast.Transforms
Expression = new Choice {
new AnonymousTypeCreateExpression {
Initializers = {
new NamedNode("nae1", new NamedExpression { Expression = new IdentifierExpression() }),
new NamedNode("nae2", new NamedExpression { Expression = new AnyNode("nae2Expr") })
new NamedExpression {
Identifier = Pattern.AnyString,
Expression = new IdentifierExpression(Pattern.AnyString)
}.WithName("nae1"),
new NamedExpression {
Identifier = Pattern.AnyString,
Expression = new AnyNode("nae2Expr")
}.WithName("nae2")
}
},
new AnonymousTypeCreateExpression {
Initializers = {
new NamedNode("identifier", new IdentifierExpression()),
new NamedNode("identifier", new IdentifierExpression(Pattern.AnyString)),
new AnyNode("nae2Expr")
}
}

5
ICSharpCode.Decompiler/Ast/Transforms/ConvertConstructorCallIntoInitializer.cs

@ -60,7 +60,10 @@ namespace ICSharpCode.Decompiler.Ast.Transforms @@ -60,7 +60,10 @@ namespace ICSharpCode.Decompiler.Ast.Transforms
static readonly ExpressionStatement fieldInitializerPattern = new ExpressionStatement {
Expression = new AssignmentExpression {
Left = new NamedNode("fieldAccess", new MemberReferenceExpression { Target = new ThisReferenceExpression() }),
Left = new NamedNode("fieldAccess", new MemberReferenceExpression {
Target = new ThisReferenceExpression(),
MemberName = Pattern.AnyString
}),
Operator = AssignmentOperatorType.Assign,
Right = new AnyNode("initializer")
}

7
ICSharpCode.Decompiler/Ast/Transforms/DelegateConstruction.cs

@ -293,7 +293,7 @@ namespace ICSharpCode.Decompiler.Ast.Transforms @@ -293,7 +293,7 @@ namespace ICSharpCode.Decompiler.Ast.Transforms
static readonly ExpressionStatement displayClassAssignmentPattern =
new ExpressionStatement(new AssignmentExpression(
new NamedNode("variable", new IdentifierExpression()),
new NamedNode("variable", new IdentifierExpression(Pattern.AnyString)),
new ObjectCreateExpression { Type = new AnyNode("type") }
));
@ -348,7 +348,10 @@ namespace ICSharpCode.Decompiler.Ast.Transforms @@ -348,7 +348,10 @@ namespace ICSharpCode.Decompiler.Ast.Transforms
// "variableName.MemberName = right;"
ExpressionStatement closureFieldAssignmentPattern = new ExpressionStatement(
new AssignmentExpression(
new NamedNode("left", new MemberReferenceExpression { Target = new IdentifierExpression(variable.Name) }),
new NamedNode("left", new MemberReferenceExpression {
Target = new IdentifierExpression(variable.Name),
MemberName = Pattern.AnyString
}),
new AnyNode("right")
)
);

46
ICSharpCode.Decompiler/Ast/Transforms/PatternStatementTransform.cs

@ -140,7 +140,7 @@ namespace ICSharpCode.Decompiler.Ast.Transforms @@ -140,7 +140,7 @@ namespace ICSharpCode.Decompiler.Ast.Transforms
/// </summary>
static readonly AstNode variableAssignPattern = new ExpressionStatement(
new AssignmentExpression(
new NamedNode("variable", new IdentifierExpression()),
new NamedNode("variable", new IdentifierExpression(Pattern.AnyString)),
new AnyNode("initializer")
));
@ -158,12 +158,12 @@ namespace ICSharpCode.Decompiler.Ast.Transforms @@ -158,12 +158,12 @@ namespace ICSharpCode.Decompiler.Ast.Transforms
FinallyBlock = new BlockStatement {
new Choice {
{ "valueType",
new ExpressionStatement(InvokeDispose(new NamedNode("ident", new IdentifierExpression())))
new ExpressionStatement(InvokeDispose(new NamedNode("ident", new IdentifierExpression(Pattern.AnyString))))
},
{ "referenceType",
new IfElseStatement {
Condition = new BinaryOperatorExpression(
new NamedNode("ident", new IdentifierExpression()),
new NamedNode("ident", new IdentifierExpression(Pattern.AnyString)),
BinaryOperatorType.InEquality,
new NullReferenceExpression()
),
@ -319,6 +319,7 @@ namespace ICSharpCode.Decompiler.Ast.Transforms @@ -319,6 +319,7 @@ namespace ICSharpCode.Decompiler.Ast.Transforms
new NamedNode(
"enumeratorVariable",
new VariableInitializer {
Name = Pattern.AnyString,
Initializer = new AnyNode("collection").ToExpression().Invoke("GetEnumerator")
}
)
@ -326,16 +327,19 @@ namespace ICSharpCode.Decompiler.Ast.Transforms @@ -326,16 +327,19 @@ namespace ICSharpCode.Decompiler.Ast.Transforms
},
EmbeddedStatement = new BlockStatement {
new Repeat(
new VariableDeclarationStatement { Type = new AnyNode(), Variables = { new VariableInitializer() } }.WithName("variablesOutsideLoop")
new VariableDeclarationStatement { Type = new AnyNode(), Variables = { new VariableInitializer(Pattern.AnyString) } }.WithName("variablesOutsideLoop")
).ToStatement(),
new WhileStatement {
Condition = new IdentifierExpressionBackreference("enumeratorVariable").ToExpression().Invoke("MoveNext"),
EmbeddedStatement = new BlockStatement {
new Repeat(
new VariableDeclarationStatement { Type = new AnyNode(), Variables = { new VariableInitializer() } }.WithName("variablesInsideLoop")
new VariableDeclarationStatement {
Type = new AnyNode(),
Variables = { new VariableInitializer(Pattern.AnyString) }
}.WithName("variablesInsideLoop")
).ToStatement(),
new AssignmentExpression {
Left = new IdentifierExpression().WithName("itemVariable"),
Left = new IdentifierExpression(Pattern.AnyString).WithName("itemVariable"),
Operator = AssignmentOperatorType.Assign,
Right = new IdentifierExpressionBackreference("enumeratorVariable").ToExpression().Member("Current")
},
@ -398,17 +402,17 @@ namespace ICSharpCode.Decompiler.Ast.Transforms @@ -398,17 +402,17 @@ namespace ICSharpCode.Decompiler.Ast.Transforms
#region foreach (non-generic)
ExpressionStatement getEnumeratorPattern = new ExpressionStatement(
new AssignmentExpression(
new NamedNode("left", new IdentifierExpression()),
new NamedNode("left", new IdentifierExpression(Pattern.AnyString)),
new AnyNode("collection").ToExpression().Invoke("GetEnumerator")
));
TryCatchStatement nonGenericForeachPattern = new TryCatchStatement {
TryBlock = new BlockStatement {
new WhileStatement {
Condition = new IdentifierExpression().WithName("enumerator").Invoke("MoveNext"),
Condition = new IdentifierExpression(Pattern.AnyString).WithName("enumerator").Invoke("MoveNext"),
EmbeddedStatement = new BlockStatement {
new AssignmentExpression(
new IdentifierExpression().WithName("itemVar"),
new IdentifierExpression(Pattern.AnyString).WithName("itemVar"),
new Choice {
new Backreference("enumerator").ToExpression().Member("Current"),
new CastExpression {
@ -423,7 +427,7 @@ namespace ICSharpCode.Decompiler.Ast.Transforms @@ -423,7 +427,7 @@ namespace ICSharpCode.Decompiler.Ast.Transforms
},
FinallyBlock = new BlockStatement {
new AssignmentExpression(
new IdentifierExpression().WithName("disposable"),
new IdentifierExpression(Pattern.AnyString).WithName("disposable"),
new Backreference("enumerator").ToExpression().CastAs(new TypePattern(typeof(IDisposable)))
),
new IfElseStatement {
@ -511,7 +515,7 @@ namespace ICSharpCode.Decompiler.Ast.Transforms @@ -511,7 +515,7 @@ namespace ICSharpCode.Decompiler.Ast.Transforms
#region for
static readonly WhileStatement forPattern = new WhileStatement {
Condition = new BinaryOperatorExpression {
Left = new NamedNode("ident", new IdentifierExpression()),
Left = new NamedNode("ident", new IdentifierExpression(Pattern.AnyString)),
Operator = BinaryOperatorType.Any,
Right = new AnyNode("endExpr")
},
@ -604,7 +608,7 @@ namespace ICSharpCode.Decompiler.Ast.Transforms @@ -604,7 +608,7 @@ namespace ICSharpCode.Decompiler.Ast.Transforms
#region lock
static readonly AstNode lockFlagInitPattern = new ExpressionStatement(
new AssignmentExpression(
new NamedNode("variable", new IdentifierExpression()),
new NamedNode("variable", new IdentifierExpression(Pattern.AnyString)),
new PrimitiveExpression(false)
));
@ -614,7 +618,7 @@ namespace ICSharpCode.Decompiler.Ast.Transforms @@ -614,7 +618,7 @@ namespace ICSharpCode.Decompiler.Ast.Transforms
"Enter", new AnyNode("enter"),
new DirectionExpression {
FieldDirection = FieldDirection.Ref,
Expression = new NamedNode("flag", new IdentifierExpression())
Expression = new NamedNode("flag", new IdentifierExpression(Pattern.AnyString))
}),
new Repeat(new AnyNode()).ToStatement()
},
@ -622,7 +626,7 @@ namespace ICSharpCode.Decompiler.Ast.Transforms @@ -622,7 +626,7 @@ namespace ICSharpCode.Decompiler.Ast.Transforms
new IfElseStatement {
Condition = new Backreference("flag"),
TrueStatement = new BlockStatement {
new TypePattern(typeof(System.Threading.Monitor)).ToType().Invoke("Exit", new NamedNode("exit", new IdentifierExpression()))
new TypePattern(typeof(System.Threading.Monitor)).ToType().Invoke("Exit", new NamedNode("exit", new IdentifierExpression(Pattern.AnyString)))
}
}
}};
@ -680,10 +684,10 @@ namespace ICSharpCode.Decompiler.Ast.Transforms @@ -680,10 +684,10 @@ namespace ICSharpCode.Decompiler.Ast.Transforms
new IfElseStatement {
Condition = new Backreference("cachedDict").ToExpression().Invoke(
"TryGetValue",
new NamedNode("switchVar", new IdentifierExpression()),
new NamedNode("switchVar", new IdentifierExpression(Pattern.AnyString)),
new DirectionExpression {
FieldDirection = FieldDirection.Out,
Expression = new IdentifierExpression().WithName("intVar")
Expression = new IdentifierExpression(Pattern.AnyString).WithName("intVar")
}),
TrueStatement = new BlockStatement {
Statements = {
@ -784,6 +788,7 @@ namespace ICSharpCode.Decompiler.Ast.Transforms @@ -784,6 +788,7 @@ namespace ICSharpCode.Decompiler.Ast.Transforms
Modifiers = Modifiers.Any,
ReturnType = new AnyNode(),
PrivateImplementationType = new OptionalNode(new AnyNode()),
Name = Pattern.AnyString,
Getter = new Accessor {
Attributes = { new Repeat(new AnyNode()) },
Modifiers = Modifiers.Any,
@ -846,19 +851,20 @@ namespace ICSharpCode.Decompiler.Ast.Transforms @@ -846,19 +851,20 @@ namespace ICSharpCode.Decompiler.Ast.Transforms
new VariableDeclarationStatement { Type = new Backreference("type"), Variables = { new AnyNode() } },
new VariableDeclarationStatement { Type = new Backreference("type"), Variables = { new AnyNode() } },
new AssignmentExpression {
Left = new NamedNode("var1", new IdentifierExpression()),
Left = new NamedNode("var1", new IdentifierExpression(Pattern.AnyString)),
Operator = AssignmentOperatorType.Assign,
Right = new NamedNode(
"field",
new MemberReferenceExpression {
Target = new Choice { new ThisReferenceExpression(), new TypeReferenceExpression { Type = new AnyNode() } }
Target = new Choice { new ThisReferenceExpression(), new TypeReferenceExpression { Type = new AnyNode() } },
MemberName = Pattern.AnyString
})
},
new DoWhileStatement {
EmbeddedStatement = new BlockStatement {
new AssignmentExpression(new NamedNode("var2", new IdentifierExpression()), new IdentifierExpressionBackreference("var1")),
new AssignmentExpression(new NamedNode("var2", new IdentifierExpression(Pattern.AnyString)), new IdentifierExpressionBackreference("var1")),
new AssignmentExpression {
Left = new NamedNode("var3", new IdentifierExpression()),
Left = new NamedNode("var3", new IdentifierExpression(Pattern.AnyString)),
Operator = AssignmentOperatorType.Assign,
Right = new AnyNode("delegateCombine").ToExpression().Invoke(
new IdentifierExpressionBackreference("var2"),

1
ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj

@ -55,7 +55,6 @@ @@ -55,7 +55,6 @@
<Compile Include="Ast\Annotations.cs" />
<Compile Include="Ast\AstBuilder.cs" />
<Compile Include="Ast\AstMethodBodyBuilder.cs" />
<Compile Include="Ast\CecilTypeResolveContext.cs" />
<Compile Include="Ast\CommentStatement.cs" />
<Compile Include="Ast\DecompilerContext.cs" />
<Compile Include="Ast\NameVariables.cs" />

6
ILSpy/Properties/app.config.template

@ -17,15 +17,15 @@ @@ -17,15 +17,15 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="ICSharpCode.NRefactory" publicKeyToken="d4bfe873e7598c49" culture="neutral"/>
<bindingRedirect oldVersion="5.0.0.0-99.9.9.9" newVersion="5.0.0.0"/>
<bindingRedirect oldVersion="5.0.0.0-99.9.9.9" newVersion="5.0.0.2"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="ICSharpCode.NRefactory.CSharp" publicKeyToken="d4bfe873e7598c49" culture="neutral"/>
<bindingRedirect oldVersion="5.0.0.0-99.9.9.9" newVersion="5.0.0.0"/>
<bindingRedirect oldVersion="5.0.0.0-99.9.9.9" newVersion="5.0.0.2"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="ICSharpCode.NRefactory.VB" publicKeyToken="d4bfe873e7598c49" culture="neutral"/>
<bindingRedirect oldVersion="5.0.0.0-99.9.9.9" newVersion="5.0.0.0"/>
<bindingRedirect oldVersion="5.0.0.0-99.9.9.9" newVersion="5.0.0.2"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="ICSharpCode.Decompiler" publicKeyToken="d4bfe873e7598c49" culture="neutral"/>

17
ILSpy/VB/ILSpyEnvironmentProvider.cs

@ -36,21 +36,8 @@ namespace ICSharpCode.ILSpy.VB @@ -36,21 +36,8 @@ namespace ICSharpCode.ILSpy.VB
}
}
readonly ITypeResolveContext context;
readonly CecilLoader loader = new CecilLoader(false);
public ILSpyEnvironmentProvider(ITypeResolveContext context)
{
this.context = context;
}
public ITypeResolveContext ResolveContext {
get {
return context;
}
}
public string GetTypeNameForAttribute(ICSharpCode.NRefactory.CSharp.Attribute attribute)
{
return attribute.Type.Annotations
@ -61,6 +48,7 @@ namespace ICSharpCode.ILSpy.VB @@ -61,6 +48,7 @@ namespace ICSharpCode.ILSpy.VB
public IType ResolveType(NRefactory.VB.Ast.AstType type, NRefactory.VB.Ast.TypeDeclaration entity = null)
{
/*
var annotation = type.Annotation<TypeReference>();
if (annotation == null )
return null;
@ -71,7 +59,8 @@ namespace ICSharpCode.ILSpy.VB @@ -71,7 +59,8 @@ namespace ICSharpCode.ILSpy.VB
current = loader.ReadTypeReference(typeInfo).Resolve(context).GetDefinition();
}
return loader.ReadTypeReference(annotation, entity: current).Resolve(context);
return loader.ReadTypeReference(annotation, entity: current).Resolve(context);*/
return SpecialType.UnknownType;
}
public TypeKind GetTypeKindForAstType(ICSharpCode.NRefactory.CSharp.AstType type)

20
ILSpy/VB/VBLanguage.cs

@ -436,7 +436,7 @@ namespace ICSharpCode.ILSpy.VB @@ -436,7 +436,7 @@ namespace ICSharpCode.ILSpy.VB
astBuilder.RunTransformations(transformAbortCondition);
if (options.DecompilerSettings.ShowXmlDocumentation)
AddXmlDocTransform.Run(astBuilder.CompilationUnit);
var unit = astBuilder.CompilationUnit.AcceptVisitor(new CSharpToVBConverterVisitor(new ILSpyEnvironmentProvider(CreateResolveContext(module))), null);
var unit = astBuilder.CompilationUnit.AcceptVisitor(new CSharpToVBConverterVisitor(new ILSpyEnvironmentProvider()), null);
var outputFormatter = new VBTextOutputFormatter(output);
var formattingPolicy = new VBFormattingOptions();
unit.AcceptVisitor(new OutputVisitor(outputFormatter, formattingPolicy), null);
@ -478,25 +478,9 @@ namespace ICSharpCode.ILSpy.VB @@ -478,25 +478,9 @@ namespace ICSharpCode.ILSpy.VB
return TypeToString(options, type, typeAttributes);
}
ITypeResolveContext CreateResolveContext(ModuleDefinition module)
{
IProjectContent projectContent = new CecilTypeResolveContext(module);
List<ITypeResolveContext> resolveContexts = new List<ITypeResolveContext>();
resolveContexts.Add(projectContent);
foreach (AssemblyNameReference r in module.AssemblyReferences) {
AssemblyDefinition d = module.AssemblyResolver.Resolve(r);
if (d != null) {
resolveContexts.Add(new CecilTypeResolveContext(d.MainModule));
}
}
return new CompositeTypeResolveContext(resolveContexts);
}
string TypeToString(ConvertTypeOptions options, TypeReference type, ICustomAttributeProvider typeAttributes = null)
{
var envProvider = new ILSpyEnvironmentProvider(CreateResolveContext(type.Module));
var envProvider = new ILSpyEnvironmentProvider();
var converter = new CSharpToVBConverterVisitor(envProvider);
var astType = AstBuilder.ConvertType(type, typeAttributes, options);
StringWriter w = new StringWriter();

5
NRefactory/ICSharpCode.NRefactory.VB/Visitors/CSharpToVBConverterVisitor.cs

@ -1116,7 +1116,7 @@ namespace ICSharpCode.NRefactory.VB.Visitors @@ -1116,7 +1116,7 @@ namespace ICSharpCode.NRefactory.VB.Visitors
Condition = new NamedNode(
"condition",
new CSharp.BinaryOperatorExpression {
Left = new NamedNode("ident", new CSharp.IdentifierExpression()),
Left = new NamedNode("ident", new CSharp.IdentifierExpression(Pattern.AnyString)),
Operator = CSharp.BinaryOperatorType.Any,
Right = new AnyNode("endExpr")
}),
@ -1675,7 +1675,8 @@ namespace ICSharpCode.NRefactory.VB.Visitors @@ -1675,7 +1675,8 @@ namespace ICSharpCode.NRefactory.VB.Visitors
Right = new NamedNode(
"modifier",
new CSharp.MemberReferenceExpression() {
Target = new CSharp.IdentifierExpression("CharSet")
Target = new CSharp.IdentifierExpression("CharSet"),
MemberName = Pattern.AnyString
})
};

Loading…
Cancel
Save