Browse Source

Use Humanizer in GenerateForeachVariableName

pull/881/merge
Siegfried Pammer 8 years ago
parent
commit
c118a24cbf
  1. 1
      ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj
  2. 19
      ICSharpCode.Decompiler/IL/Transforms/AssignVariableNames.cs
  3. 1
      ILSpy/ILSpy.csproj

1
ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj

@ -47,6 +47,7 @@ @@ -47,6 +47,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Humanizer.Core" Version="2.2.0" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="System.Collections.Immutable" Version="1.3.0" />
<PackageReference Include="System.ValueTuple" Version="4.3.0" />

19
ICSharpCode.Decompiler/IL/Transforms/AssignVariableNames.cs

@ -21,6 +21,7 @@ using System.Collections.Generic; @@ -21,6 +21,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Humanizer;
using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.Semantics;
using ICSharpCode.Decompiler.TypeSystem;
@ -432,19 +433,11 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -432,19 +433,11 @@ namespace ICSharpCode.Decompiler.IL.Transforms
private static bool IsPlural(string baseName, ref string proposedName)
{
if (baseName.EndsWith("ies", StringComparison.OrdinalIgnoreCase) && baseName.Length > 3) {
proposedName = baseName.Remove(baseName.Length - 3) + "y";
return true;
}
if (baseName.EndsWith("es", StringComparison.OrdinalIgnoreCase) && baseName.Length > 2) {
proposedName = baseName.Remove(baseName.Length - 2);
return true;
}
if (baseName.EndsWith("s", StringComparison.OrdinalIgnoreCase) && baseName.Length > 1) {
proposedName = baseName.Remove(baseName.Length - 1);
return true;
}
return false;
var newName = baseName.Singularize(inputIsKnownToBePlural: false);
if (newName == baseName)
return false;
proposedName = newName;
return true;
}
}
}

1
ILSpy/ILSpy.csproj

@ -398,5 +398,6 @@ @@ -398,5 +398,6 @@
<Exec Command="copy $(TargetDir)\System.Collections.Immutable.dll $(SolutionDir)\ILSpy.AddIn\packages\" />
<Exec Command="copy $(TargetDir)\ICSharpCode.AvalonEdit.dll $(SolutionDir)\ILSpy.AddIn\packages\" />
<Exec Command="copy $(TargetDir)\Newtonsoft.Json.dll $(SolutionDir)\ILSpy.AddIn\packages\" />
<Exec Command="copy $(TargetDir)\Humanizer.dll $(SolutionDir)\ILSpy.AddIn\packages\" />
</Target>
</Project>
Loading…
Cancel
Save