Browse Source

Merge pull request #2762 from hexafluoride/always-use-global

pull/2774/head
Siegfried Pammer 3 years ago committed by GitHub
parent
commit
2ada0db587
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs
  2. 1
      ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs
  3. 7
      ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs
  4. 1
      ICSharpCode.Decompiler/CSharp/Transforms/IntroduceUsingDeclarations.cs
  5. 18
      ICSharpCode.Decompiler/DecompilerSettings.cs
  6. 2
      ILSpy/ILSpy.csproj
  7. 9
      ILSpy/Properties/Resources.Designer.cs
  8. 3
      ILSpy/Properties/Resources.resx

1
ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs

@ -508,6 +508,7 @@ namespace ICSharpCode.Decompiler.CSharp
typeSystemAstBuilder.SupportInitAccessors = settings.InitAccessors; typeSystemAstBuilder.SupportInitAccessors = settings.InitAccessors;
typeSystemAstBuilder.SupportRecordClasses = settings.RecordClasses; typeSystemAstBuilder.SupportRecordClasses = settings.RecordClasses;
typeSystemAstBuilder.SupportRecordStructs = settings.RecordStructs; typeSystemAstBuilder.SupportRecordStructs = settings.RecordStructs;
typeSystemAstBuilder.AlwaysUseGlobal = settings.AlwaysUseGlobal;
return typeSystemAstBuilder; return typeSystemAstBuilder;
} }

1
ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs

@ -100,6 +100,7 @@ namespace ICSharpCode.Decompiler.CSharp
this.astBuilder.AddResolveResultAnnotations = true; this.astBuilder.AddResolveResultAnnotations = true;
this.astBuilder.ShowAttributes = true; this.astBuilder.ShowAttributes = true;
this.astBuilder.UseNullableSpecifierForValueTypes = settings.LiftNullables; this.astBuilder.UseNullableSpecifierForValueTypes = settings.LiftNullables;
this.astBuilder.AlwaysUseGlobal = settings.AlwaysUseGlobal;
this.typeInference = new TypeInference(compilation) { Algorithm = TypeInferenceAlgorithm.Improved }; this.typeInference = new TypeInference(compilation) { Algorithm = TypeInferenceAlgorithm.Improved };
} }

7
ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs

@ -224,6 +224,11 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// Controls whether C# 10 "record" struct types are supported. /// Controls whether C# 10 "record" struct types are supported.
/// </summary> /// </summary>
public bool SupportRecordStructs { get; set; } public bool SupportRecordStructs { get; set; }
/// <summary>
/// Controls whether all fully qualified type names should be prefixed with "global::".
/// </summary>
public bool AlwaysUseGlobal { get; set; }
#endregion #endregion
#region Convert Type #region Convert Type
@ -535,7 +540,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
else else
{ {
result.Target = ConvertNamespace(genericType.Namespace, result.Target = ConvertNamespace(genericType.Namespace,
out _, genericType.Namespace == genericType.Name); out _, AlwaysUseGlobal || genericType.Namespace == genericType.Name);
} }
} }
result.MemberName = genericType.Name; result.MemberName = genericType.Name;

1
ICSharpCode.Decompiler/CSharp/Transforms/IntroduceUsingDeclarations.cs

@ -170,6 +170,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
return new TypeSystemAstBuilder(resolver) { return new TypeSystemAstBuilder(resolver) {
UseNullableSpecifierForValueTypes = settings.LiftNullables, UseNullableSpecifierForValueTypes = settings.LiftNullables,
AlwaysUseGlobal = settings.AlwaysUseGlobal,
AddResolveResultAnnotations = true, AddResolveResultAnnotations = true,
UseAliases = true UseAliases = true
}; };

18
ICSharpCode.Decompiler/DecompilerSettings.cs

@ -1915,6 +1915,24 @@ namespace ICSharpCode.Decompiler
} }
} }
bool alwaysUseGlobal = false;
/// <summary>
/// Always fully qualify namespaces using the "global::" prefix.
/// </summary>
[Category("DecompilerSettings.Other")]
[Description("DecompilerSettings.AlwaysUseGlobal")]
public bool AlwaysUseGlobal {
get { return alwaysUseGlobal; }
set {
if (alwaysUseGlobal != value)
{
alwaysUseGlobal = value;
OnPropertyChanged();
}
}
}
CSharpFormattingOptions csharpFormattingOptions; CSharpFormattingOptions csharpFormattingOptions;
[Browsable(false)] [Browsable(false)]

2
ILSpy/ILSpy.csproj

@ -119,7 +119,7 @@
<SortResXStamp Include="obj\sort-resx.stamp" /> <SortResXStamp Include="obj\sort-resx.stamp" />
</ItemGroup> </ItemGroup>
<Target Name="SortResX" BeforeTargets="BeforeBuild" Inputs="@(SortResXInput)" Outputs="@(SortResXStamp)"> <Target Name="SortResX" BeforeTargets="BeforeBuild" Inputs="@(SortResXInput)" Outputs="@(SortResXStamp)" Condition="'$(GITHUB_ACTIONS)' != 'true'">
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT' "> <PropertyGroup Condition=" '$(OS)' == 'Windows_NT' ">
<SortResX>powershell -NoProfile -ExecutionPolicy Bypass -File BuildTools/sort-resx.ps1</SortResX> <SortResX>powershell -NoProfile -ExecutionPolicy Bypass -File BuildTools/sort-resx.ps1</SortResX>
</PropertyGroup> </PropertyGroup>

9
ILSpy/Properties/Resources.Designer.cs generated

@ -738,6 +738,15 @@ namespace ICSharpCode.ILSpy.Properties {
} }
} }
/// <summary>
/// Looks up a localized string similar to Always fully qualify namespaces using the &quot;global::&quot; prefix.
/// </summary>
public static string DecompilerSettings_AlwaysUseGlobal {
get {
return ResourceManager.GetString("DecompilerSettings.AlwaysUseGlobal", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Apply Windows Runtime projections on loaded assemblies. /// Looks up a localized string similar to Apply Windows Runtime projections on loaded assemblies.
/// </summary> /// </summary>

3
ILSpy/Properties/Resources.resx

@ -270,6 +270,9 @@ Are you sure you want to continue?</value>
<data name="DecompilerSettings.AlwaysUseBraces" xml:space="preserve"> <data name="DecompilerSettings.AlwaysUseBraces" xml:space="preserve">
<value>Always use braces</value> <value>Always use braces</value>
</data> </data>
<data name="DecompilerSettings.AlwaysUseGlobal" xml:space="preserve">
<value>Always fully qualify namespaces using the "global::" prefix</value>
</data>
<data name="DecompilerSettings.ApplyWindowsRuntimeProjectionsOnLoadedAssemblies" xml:space="preserve"> <data name="DecompilerSettings.ApplyWindowsRuntimeProjectionsOnLoadedAssemblies" xml:space="preserve">
<value>Apply Windows Runtime projections on loaded assemblies</value> <value>Apply Windows Runtime projections on loaded assemblies</value>
</data> </data>

Loading…
Cancel
Save