Browse Source

Fix unit tests.

pull/118/head
Daniel Grunwald 15 years ago
parent
commit
6229a1dba8
  1. 3
      ICSharpCode.Decompiler/Ast/Transforms/IntroduceUsingDeclarations.cs
  2. 12
      ICSharpCode.Decompiler/DecompilerSettings.cs
  3. 4
      ICSharpCode.Decompiler/Tests/DecompilerTestBase.cs
  4. 6
      ICSharpCode.Decompiler/Tests/IncrementDecrement.cs

3
ICSharpCode.Decompiler/Ast/Transforms/IntroduceUsingDeclarations.cs

@ -44,6 +44,9 @@ namespace ICSharpCode.Decompiler.Ast.Transforms @@ -44,6 +44,9 @@ namespace ICSharpCode.Decompiler.Ast.Transforms
compilationUnit.InsertChildAfter(null, new UsingDeclaration { Import = nsType }, CompilationUnit.MemberRole);
}
if (!context.Settings.FullyQualifyAmbiguousTypeNames)
return;
FindAmbiguousTypeNames(context.CurrentModule, internalsVisible: true);
foreach (AssemblyNameReference r in context.CurrentModule.AssemblyReferences) {
AssemblyDefinition d = context.CurrentModule.AssemblyResolver.Resolve(r);

12
ICSharpCode.Decompiler/DecompilerSettings.cs

@ -140,6 +140,18 @@ namespace ICSharpCode.Decompiler @@ -140,6 +140,18 @@ namespace ICSharpCode.Decompiler
}
}
bool fullyQualifyAmbiguousTypeNames = true;
public bool FullyQualifyAmbiguousTypeNames {
get { return fullyQualifyAmbiguousTypeNames; }
set {
if (fullyQualifyAmbiguousTypeNames != value) {
fullyQualifyAmbiguousTypeNames = value;
OnPropertyChanged("FullyQualifyAmbiguousTypeNames");
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)

4
ICSharpCode.Decompiler/Tests/DecompilerTestBase.cs

@ -34,8 +34,10 @@ namespace ICSharpCode.Decompiler.Tests @@ -34,8 +34,10 @@ namespace ICSharpCode.Decompiler.Tests
/// <returns>The decompilation result of compiled source code.</returns>
static string RoundtripCode(string code)
{
DecompilerSettings settings = new DecompilerSettings();
settings.FullyQualifyAmbiguousTypeNames = false;
AssemblyDefinition assembly = Compile(code);
AstBuilder decompiler = new AstBuilder(new DecompilerContext(assembly.MainModule));
AstBuilder decompiler = new AstBuilder(new DecompilerContext(assembly.MainModule) { Settings = settings });
decompiler.AddAssembly(assembly);
new Helpers.RemoveCompilerAttribute().Run(decompiler.CompilationUnit);
StringWriter output = new StringWriter();

6
ICSharpCode.Decompiler/Tests/IncrementDecrement.cs

@ -36,7 +36,7 @@ public class IncrementDecrement @@ -36,7 +36,7 @@ public class IncrementDecrement
}
}
MyEnum enumField;
private IncrementDecrement.MyEnum enumField;
public static int StaticField;
public static int StaticProperty
@ -167,8 +167,8 @@ public class IncrementDecrement @@ -167,8 +167,8 @@ public class IncrementDecrement
public void CompoundAssignEnum()
{
enumField |= IncrementDecrement.MyEnum.Two;
enumField &= ~IncrementDecrement.MyEnum.Four;
this.enumField |= IncrementDecrement.MyEnum.Two;
this.enumField &= ~IncrementDecrement.MyEnum.Four;
}
public int PostIncrementInAddition(int i, int j)

Loading…
Cancel
Save