Skip to content

Commit

Permalink
Merge pull request skbkontur#13 from skbkontur/removeMethodBodyParsing
Browse files Browse the repository at this point in the history
Remove broken code
  • Loading branch information
AndrewKostousov authored Jan 14, 2019
2 parents e2e6268 + d03cb7c commit 30307ec
Show file tree
Hide file tree
Showing 75 changed files with 93 additions and 6,963 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
dist: trusty
dist: xenial
sudo: false
language: csharp
dotnet: 2.2.100
matrix:
include:
- dotnet: 2.1.400
mono: none
- mono: none
env: DOTNETCORE=1
- mono: latest
script:
Expand Down
2 changes: 1 addition & 1 deletion AsmToBytes/AsmToBytes.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<IsPackable>false</IsPackable>
<TargetFrameworks>netcoreapp2.0;net45</TargetFrameworks>
<TargetFrameworks>netcoreapp2.2;net45</TargetFrameworks>
</PropertyGroup>

</Project>
6 changes: 3 additions & 3 deletions AsmToBytes/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static void Main(string[] args)
var tempFile = Path.Combine(dirName, "temp.asm");
var dllFile = Path.Combine(dirName, "temp.dll");
var marker = Guid.NewGuid().ToByteArray();
var stringMarker = string.Join(Environment.NewLine, marker.Select(x => string.Format("db 0{0:x2}h", x)));
var stringMarker = string.Join(Environment.NewLine, marker.Select(x => $"db 0{x:x2}h"));
string content;
if (architecture == "x86")
content = string.Format(@"
Expand Down Expand Up @@ -92,7 +92,7 @@ end data
RedirectStandardOutput = true,
RedirectStandardInput = true,
UseShellExecute = false,
Arguments = string.Format(@"""{0}"" ""{1}""", tempFile, dllFile),
Arguments = $@"""{tempFile}"" ""{dllFile}""",
FileName = Path.Combine(pathToFasm, "fasm.exe")
};
var process = new Process
Expand Down Expand Up @@ -139,7 +139,7 @@ end data
{
var result = new StringBuilder();
for (var j = i; j < k; ++j)
result.Append(string.Format("0x{0:x2},", dllContent[j]));
result.Append($"0x{dllContent[j]:x2},");
result.AppendLine();
result.AppendLine(Convert.ToBase64String(dllContent, i, k - i));
File.WriteAllText(outputFile, result.ToString());
Expand Down
1 change: 1 addition & 0 deletions Common.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpRenamePlacementToArrangementMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAlwaysTreatStructAsNotReorderableMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002ECSharpPlaceAttributeOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<!-- Nerdbank.GitVersioning does not work on Ubuntu+Mono (see https://github.com/AArnott/Nerdbank.GitVersioning/issues/224) -->
<ItemGroup Condition="'$(OS)' != 'Unix'">
<PackageReference Include="Nerdbank.GitVersioning" Version="2.2.13" PrivateAssets="All" />
<PackageReference Include="Nerdbank.GitVersioning" Version="2.3.38" PrivateAssets="All" />
</ItemGroup>

</Project>
8 changes: 4 additions & 4 deletions GrEmit.Tests/GrEmit.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

<PropertyGroup>
<IsPackable>false</IsPackable>
<TargetFrameworks>netcoreapp2.0;net45</TargetFrameworks>
<TargetFrameworks>netcoreapp2.2;net45</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
<PackageReference Include="NUnit" Version="3.10.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.10.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.12.0" />
</ItemGroup>

<ItemGroup>
Expand Down
25 changes: 3 additions & 22 deletions GrEmit.Tests/Test.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Emit;
Expand All @@ -7,7 +7,6 @@

using NUnit.Framework;

using MethodBody = GrEmit.MethodBodyParsing.MethodBody;
#if NET45
using System.Diagnostics;
using System.Linq;
Expand All @@ -18,24 +17,6 @@ namespace GrEmit.Tests
[TestFixture]
public class Test
{
public static void Qzz()
{
var list = new List<int>();
list.Add(1);
}

[Test, Ignore("Is used for debugging")]
public void TestZzz()
{
var method = HackHelpers.GetMethodDefinition<int>(x => Qzz());
var body = MethodBody.Read(method, true);
var z = body.CreateDelegate<Action>();
z();
var body2 = MethodBody.Read(z.Method, true);
var z2 = body2.CreateDelegate<Action>();
z2();
}

[Test]
public void TestDifferentStructs()
{
Expand Down Expand Up @@ -480,7 +461,7 @@ public void TestPerformance_Ifs_vs_Switch()

var ifs = BuildIfs(module, keys);
var switCh = BuildSwitch(module, keys);
const int iterations = 1000000000;
const int iterations = 100_000_000;

Console.WriteLine("Worst case:");

Expand Down Expand Up @@ -600,7 +581,7 @@ private static void CheckDifferent(string[] values)
foreach (var str in values)
{
if (hashSet.Contains(str))
throw new InvalidOperationException(string.Format("Duplicate value '{0}'", str));
throw new InvalidOperationException($"Duplicate value '{str}'");
hashSet.Add(str);
}
}
Expand Down
8 changes: 4 additions & 4 deletions GrEmit.Tests/TestGrobufUsages.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Reflection;
using System.Reflection.Emit;

Expand Down Expand Up @@ -45,10 +45,10 @@ private static void AssertDateTimeOffsetFields(DateTime dateTime, short offsetMi

private static string SelectName(string netcoreName, string net45Name)
{
#if NETCOREAPP2_0
return netcoreName;
#else
#if NET45
return net45Name;
#else
return netcoreName;
#endif
}

Expand Down
3 changes: 2 additions & 1 deletion GrEmit.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
<s:String x:Key="/Default/Environment/InjectedLayers/FileInjectedLayer/=4592A3FB6844284CBDE4DE722C9B5808/AbsolutePath/@EntryValue">C:\projects\open-source\skbkontur\gremit\Common.DotSettings</s:String>
<s:String x:Key="/Default/Environment/InjectedLayers/FileInjectedLayer/=4592A3FB6844284CBDE4DE722C9B5808/RelativePath/@EntryValue">..\Common.DotSettings</s:String>
<s:Boolean x:Key="/Default/Environment/InjectedLayers/InjectedLayerCustomization/=File4592A3FB6844284CBDE4DE722C9B5808/@KeyIndexDefined">True</s:Boolean>
<s:Double x:Key="/Default/Environment/InjectedLayers/InjectedLayerCustomization/=File4592A3FB6844284CBDE4DE722C9B5808/RelativePriority/@EntryValue">1</s:Double></wpf:ResourceDictionary>
<s:Double x:Key="/Default/Environment/InjectedLayers/InjectedLayerCustomization/=File4592A3FB6844284CBDE4DE722C9B5808/RelativePriority/@EntryValue">1</s:Double>
<s:Boolean x:Key="/Default/UserDictionary/Words/=grobo/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
14 changes: 7 additions & 7 deletions GrEmit/GroboIL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -464,14 +464,14 @@ public void Jmp(MethodInfo method)
if (method == null)
throw new ArgumentNullException("method");
if (method.ReturnType != methodReturnType)
throw new ArgumentException(string.Format("The return type must be of type '{0}'", methodReturnType), "method");
throw new ArgumentException($"The return type must be of type '{methodReturnType}'", "method");
var parameterTypes = method.GetParameters().Select(info => info.ParameterType).ToArray();
if (parameterTypes.Length != methodParameterTypes.Length)
throw new ArgumentException(string.Format("The number of arguments must be equal to {0}", methodParameterTypes.Length), "method");
throw new ArgumentException($"The number of arguments must be equal to {methodParameterTypes.Length}", "method");
for (var i = 0; i < parameterTypes.Length; ++i)
{
if (parameterTypes[i] != methodParameterTypes[i])
throw new ArgumentException(string.Format("The argument #{0} must be of type '{1}'", i + 1, methodParameterTypes[i]), "method");
throw new ArgumentException($"The argument #{i + 1} must be of type '{methodParameterTypes[i]}'", "method");
}
Emit(OpCodes.Jmp, method);
}
Expand Down Expand Up @@ -1749,7 +1749,7 @@ public void Conv<T>()
opCode = OpCodes.Conv_R8;
break;
default:
throw new ArgumentException(string.Format("Expected numeric type but was '{0}'", type), "type");
throw new ArgumentException($"Expected numeric type but was '{type}'", "type");
}
}
Emit(opCode);
Expand Down Expand Up @@ -1821,7 +1821,7 @@ public void Conv_Ovf<T>(bool unsigned)
opCode = OpCodes.Conv_Ovf_U8;
break;
default:
throw new ArgumentException(string.Format("Expected integer type but was '{0}'", type), "T");
throw new ArgumentException($"Expected integer type but was '{type}'", "T");
}
}
}
Expand Down Expand Up @@ -1860,7 +1860,7 @@ public void Conv_Ovf<T>(bool unsigned)
opCode = OpCodes.Conv_Ovf_U8_Un;
break;
default:
throw new ArgumentException(string.Format("Expected integer type but was '{0}'", type), "T");
throw new ArgumentException($"Expected integer type but was '{type}'", "T");
}
}
}
Expand Down Expand Up @@ -2077,7 +2077,7 @@ private void Emit(OpCode opCode, ILInstructionParameter parameter)
il.Emit(opCode, (float)primitiveParameter.Value);
break;
default:
throw new InvalidOperationException(string.Format("Type code '{0}' is not valid at this point", typeCode));
throw new InvalidOperationException($"Type code '{typeCode}' is not valid at this point");
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions GrEmit/ILCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal class ILCode
public int MarkLabel(GroboIL.Label label, ILInstructionComment comment)
{
if (labelLineNumbers.ContainsKey(label))
throw new InvalidOperationException(string.Format("The label '{0}' has already been marked", label.Name));
throw new InvalidOperationException($"The label '{label.Name}' has already been marked");
labelLineNumbers.Add(label, Count);
instructions.Add(new ILInstruction(InstructionKind.Label, default(OpCode), new LabelILInstructionParameter(label), comment));
return Count++;
Expand All @@ -27,14 +27,14 @@ public void CheckLabels()
{
var label = (LabelILInstructionParameter)instruction.Parameter;
if (!labelLineNumbers.ContainsKey(label.Label))
throw new InvalidOperationException(string.Format("The label '{0}' has not been marked", label.Label.Name));
throw new InvalidOperationException($"The label '{label.Label.Name}' has not been marked");
}
if (instruction.Parameter is LabelsILInstructionParameter)
{
foreach (var label in ((LabelsILInstructionParameter)instruction.Parameter).Labels)
{
if (!labelLineNumbers.ContainsKey(label))
throw new InvalidOperationException(string.Format("The label '{0}' has not been marked", label.Name));
throw new InvalidOperationException($"The label '{label.Name}' has not been marked");
}
}
}
Expand Down
Loading

0 comments on commit 30307ec

Please sign in to comment.