diff options
Diffstat (limited to 'src/ILVerification')
28 files changed, 157 insertions, 39 deletions
diff --git a/src/ILVerification/src/ILVerification.csproj b/src/ILVerification/src/ILVerification.csproj index efa6e5349..8d058dbf6 100644 --- a/src/ILVerification/src/ILVerification.csproj +++ b/src/ILVerification/src/ILVerification.csproj @@ -7,8 +7,12 @@ <AllowUnsafeBlocks>true</AllowUnsafeBlocks> <EnableDefaultCompileItems>false</EnableDefaultCompileItems> <TargetFramework>netstandard1.3</TargetFramework> - <AssemblyKey></AssemblyKey> <AssemblyOriginatorKeyFile>..\StrongNameKeys\ILVerify.snk</AssemblyOriginatorKeyFile> + <SignAssembly>true</SignAssembly> + <!-- Suppress signing done by buildtools sign.targets --> + <SkipSigning>true</SkipSigning> + <!-- Delete once we pick up fix for https://github.com/dotnet/roslyn/issues/8210 --> + <DelaySign Condition="'$(OS)' != 'Windows_NT'">true</DelaySign> </PropertyGroup> <ItemGroup> @@ -77,6 +81,9 @@ <Compile Include="..\..\Common\src\TypeSystem\Common\ExceptionStringID.cs"> <Link>TypeSystem\Common\ExceptionStringID.cs</Link> </Compile> + <Compile Include="..\..\Common\src\TypeSystem\Common\Utilities\DebugNameFormatter.cs"> + <Link>Utilities\DebugNameFormatter.cs</Link> + </Compile> <Compile Include="..\..\Common\src\TypeSystem\Common\FieldForInstantiatedType.cs"> <Link>TypeSystem\Common\FieldForInstantiatedType.cs</Link> </Compile> @@ -86,6 +93,9 @@ <Compile Include="..\..\Common\src\TypeSystem\Common\FieldDesc.FieldLayout.cs"> <Link>TypeSystem\Common\FieldDesc.FieldLayout.cs</Link> </Compile> + <Compile Include="..\..\Common\src\TypeSystem\Common\FieldDesc.ToString.cs"> + <Link>TypeSystem\Common\FieldDesc.ToString.cs</Link> + </Compile> <Compile Include="..\..\Common\src\TypeSystem\Common\FieldLayoutAlgorithm.cs"> <Link>TypeSystem\Common\FieldLayoutAlgorithm.cs</Link> </Compile> @@ -167,6 +177,9 @@ <Compile Include="..\..\Common\src\TypeSystem\Common\MethodDesc.cs"> <Link>TypeSystem\Common\MethodDesc.cs</Link> </Compile> + <Compile Include="..\..\Common\src\TypeSystem\Common\MethodDesc.ToString.cs"> + <Link>TypeSystem\Common\MethodDesc.ToString.cs</Link> + </Compile> <Compile Include="..\..\Common\src\TypeSystem\Common\MetadataVirtualMethodAlgorithm.cs"> <Link>TypeSystem\Common\StandardVirtualMethodAlgorithm.cs</Link> </Compile> @@ -176,6 +189,9 @@ <Compile Include="..\..\Common\src\TypeSystem\Common\TypeDesc.Interfaces.cs"> <Link>TypeSystem\Common\TypeDesc.Interfaces.cs</Link> </Compile> + <Compile Include="..\..\Common\src\TypeSystem\Common\TypeDesc.ToString.cs"> + <Link>TypeSystem\Common\TypeDesc.ToString.cs</Link> + </Compile> <Compile Include="..\..\Common\src\TypeSystem\Common\DefType.cs"> <Link>TypeSystem\Common\DefType.cs</Link> </Compile> diff --git a/src/ILVerification/src/ILVerifyTypeSystemContext.cs b/src/ILVerification/src/ILVerifyTypeSystemContext.cs index 528dc6a90..96aaa3fd9 100644 --- a/src/ILVerification/src/ILVerifyTypeSystemContext.cs +++ b/src/ILVerification/src/ILVerifyTypeSystemContext.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; +using System.IO; using System.Reflection; using System.Reflection.Metadata; using System.Reflection.PortableExecutable; @@ -29,18 +30,39 @@ namespace ILVerify public override ModuleDesc ResolveAssembly(AssemblyName name, bool throwIfNotFound = true) { - PEReader peReader = _resolver.Resolve(name); - if (peReader == null && throwIfNotFound) + // Note: we use simple names instead of full names to resolve, because we can't get a full name from an assembly without reading it + string simpleName = name.Name; + return ResolveAssemblyOrNetmodule(simpleName, simpleName, throwIfNotFound); + } + + internal override ModuleDesc ResolveModule(ModuleDesc referencingModule, string fileName, bool throwIfNotFound = true) + { + // Referenced modules are stored without their extension (see CommandLineHelpers.cs), so we have to drop + // the extension here as well to find a match. + string simpleName = Path.GetFileNameWithoutExtension(fileName); + // The referencing module is not getting verified currently. + // However, netmodules are resolved in the context of assembly, not in the global context. + EcmaModule module = ResolveAssemblyOrNetmodule(simpleName, fileName, throwIfNotFound); + if (module.MetadataReader.IsAssembly) { - throw new VerifierException("Assembly or module not found: " + name.Name); + throw new VerifierException($"The module '{fileName}' is not expected to be an assembly"); } + return module; + } + private EcmaModule ResolveAssemblyOrNetmodule(string simpleName, string verificationName, bool throwIfNotFound) + { + PEReader peReader = _resolver.Resolve(simpleName); + if (peReader == null && throwIfNotFound) + { + throw new VerifierException("Assembly or module not found: " + simpleName); + } var module = GetModule(peReader); - VerifyModuleName(name, module); + VerifyModuleName(verificationName, module); return module; } - private static void VerifyModuleName(AssemblyName name, EcmaModule module) + private static void VerifyModuleName(string simpleName, EcmaModule module) { MetadataReader metadataReader = module.MetadataReader; StringHandle nameHandle = metadataReader.IsAssembly @@ -48,9 +70,9 @@ namespace ILVerify : metadataReader.GetModuleDefinition().Name; string actualSimpleName = metadataReader.GetString(nameHandle); - if (!actualSimpleName.Equals(name.Name, StringComparison.OrdinalIgnoreCase)) + if (!actualSimpleName.Equals(simpleName, StringComparison.OrdinalIgnoreCase)) { - throw new VerifierException($"Actual PE name '{actualSimpleName}' does not match provided name '{name}'"); + throw new VerifierException($"Actual PE name '{actualSimpleName}' does not match provided name '{simpleName}'"); } } diff --git a/src/ILVerification/src/IResolver.cs b/src/ILVerification/src/IResolver.cs index f3706cf3b..aec09c82a 100644 --- a/src/ILVerification/src/IResolver.cs +++ b/src/ILVerification/src/IResolver.cs @@ -13,7 +13,7 @@ namespace ILVerify /// <summary> /// This method should return the same instance when queried multiple times. /// </summary> - PEReader Resolve(AssemblyName name); + PEReader Resolve(string simpleName); } /// <summary> @@ -23,16 +23,14 @@ namespace ILVerify { private readonly Dictionary<string, PEReader> _resolverCache = new Dictionary<string, PEReader>(); - public PEReader Resolve(AssemblyName name) + public PEReader Resolve(string simpleName) { - // Note: we use simple names instead of full names to resolve, because we can't get a full name from an assembly without reading it - string simpleName = name.Name; if (_resolverCache.TryGetValue(simpleName, out PEReader peReader)) { return peReader; } - PEReader result = ResolveCore(name); + PEReader result = ResolveCore(simpleName); if (result != null) { _resolverCache.Add(simpleName, result); @@ -42,6 +40,6 @@ namespace ILVerify return null; } - protected abstract PEReader ResolveCore(AssemblyName name); + protected abstract PEReader ResolveCore(string simpleName); } } diff --git a/src/ILVerification/src/Verifier.cs b/src/ILVerification/src/Verifier.cs index 9341ef395..ef9374f14 100644 --- a/src/ILVerification/src/Verifier.cs +++ b/src/ILVerification/src/Verifier.cs @@ -34,7 +34,12 @@ namespace ILVerify public void SetSystemModuleName(AssemblyName name) { - _typeSystemContext.SetSystemModule(_typeSystemContext.GetModule(_typeSystemContext._resolver.Resolve(name))); + PEReader peReader = _typeSystemContext._resolver.Resolve(name.Name); + if (peReader is null) + { + throw new VerifierException("Assembly or module not found: " + name.FullName); + } + _typeSystemContext.SetSystemModule(_typeSystemContext.GetModule(peReader)); } internal EcmaModule GetModule(PEReader peReader) @@ -161,7 +166,7 @@ namespace ILVerify private IEnumerable<VerificationResult> VerifyMethod(EcmaModule module, MethodIL methodIL, MethodDefinitionHandle methodHandle) { var builder = new ArrayBuilder<VerificationResult>(); - MethodDesc method = methodIL.OwningMethod; + MethodDesc method = methodIL.OwningMethod; try { diff --git a/src/ILVerification/tests/ILMethodTester.cs b/src/ILVerification/tests/ILMethodTester.cs index eb92c3dcb..871045ed0 100644 --- a/src/ILVerification/tests/ILMethodTester.cs +++ b/src/ILVerification/tests/ILMethodTester.cs @@ -20,7 +20,7 @@ namespace ILVerification.Tests void TestMethodsWithValidIL(ValidILTestCase validIL) { var results = Verify(validIL); - Assert.Equal(0, results.Count()); + Assert.Empty(results); } [Theory(DisplayName = "")] diff --git a/src/ILVerification/tests/ILTests/AccessTests.ilproj b/src/ILVerification/tests/ILTests/AccessTests.ilproj new file mode 100644 index 000000000..8e8765d14 --- /dev/null +++ b/src/ILVerification/tests/ILTests/AccessTests.ilproj @@ -0,0 +1,3 @@ +<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="ILTests.targets" /> +</Project> diff --git a/src/ILVerification/tests/ILTests/AccessTestsExtern.ilproj b/src/ILVerification/tests/ILTests/AccessTestsExtern.ilproj new file mode 100644 index 000000000..8e8765d14 --- /dev/null +++ b/src/ILVerification/tests/ILTests/AccessTestsExtern.ilproj @@ -0,0 +1,3 @@ +<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="ILTests.targets" /> +</Project> diff --git a/src/ILVerification/tests/ILTests/AccessTestsFriend.ilproj b/src/ILVerification/tests/ILTests/AccessTestsFriend.ilproj new file mode 100644 index 000000000..8e8765d14 --- /dev/null +++ b/src/ILVerification/tests/ILTests/AccessTestsFriend.ilproj @@ -0,0 +1,3 @@ +<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="ILTests.targets" /> +</Project> diff --git a/src/ILVerification/tests/ILTests/ArrayTests.ilproj b/src/ILVerification/tests/ILTests/ArrayTests.ilproj new file mode 100644 index 000000000..8e8765d14 --- /dev/null +++ b/src/ILVerification/tests/ILTests/ArrayTests.ilproj @@ -0,0 +1,3 @@ +<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="ILTests.targets" /> +</Project> diff --git a/src/ILVerification/tests/ILTests/BasicArithmeticTests.ilproj b/src/ILVerification/tests/ILTests/BasicArithmeticTests.ilproj new file mode 100644 index 000000000..8e8765d14 --- /dev/null +++ b/src/ILVerification/tests/ILTests/BasicArithmeticTests.ilproj @@ -0,0 +1,3 @@ +<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="ILTests.targets" /> +</Project> diff --git a/src/ILVerification/tests/ILTests/BranchingTests.ilproj b/src/ILVerification/tests/ILTests/BranchingTests.ilproj new file mode 100644 index 000000000..8e8765d14 --- /dev/null +++ b/src/ILVerification/tests/ILTests/BranchingTests.ilproj @@ -0,0 +1,3 @@ +<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="ILTests.targets" /> +</Project> diff --git a/src/ILVerification/tests/ILTests/CallTests.ilproj b/src/ILVerification/tests/ILTests/CallTests.ilproj new file mode 100644 index 000000000..8e8765d14 --- /dev/null +++ b/src/ILVerification/tests/ILTests/CallTests.ilproj @@ -0,0 +1,3 @@ +<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="ILTests.targets" /> +</Project> diff --git a/src/ILVerification/tests/ILTests/CastingTests.ilproj b/src/ILVerification/tests/ILTests/CastingTests.ilproj new file mode 100644 index 000000000..8e8765d14 --- /dev/null +++ b/src/ILVerification/tests/ILTests/CastingTests.ilproj @@ -0,0 +1,3 @@ +<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="ILTests.targets" /> +</Project> diff --git a/src/ILVerification/tests/ILTests/ComparisonTests.ilproj b/src/ILVerification/tests/ILTests/ComparisonTests.ilproj new file mode 100644 index 000000000..8e8765d14 --- /dev/null +++ b/src/ILVerification/tests/ILTests/ComparisonTests.ilproj @@ -0,0 +1,3 @@ +<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="ILTests.targets" /> +</Project> diff --git a/src/ILVerification/tests/ILTests/DelegateTests.ilproj b/src/ILVerification/tests/ILTests/DelegateTests.ilproj new file mode 100644 index 000000000..8e8765d14 --- /dev/null +++ b/src/ILVerification/tests/ILTests/DelegateTests.ilproj @@ -0,0 +1,3 @@ +<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="ILTests.targets" /> +</Project> diff --git a/src/ILVerification/tests/ILTests/ExceptionRegionTests.ilproj b/src/ILVerification/tests/ILTests/ExceptionRegionTests.ilproj new file mode 100644 index 000000000..8e8765d14 --- /dev/null +++ b/src/ILVerification/tests/ILTests/ExceptionRegionTests.ilproj @@ -0,0 +1,3 @@ +<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="ILTests.targets" /> +</Project> diff --git a/src/ILVerification/tests/ILTests/FieldTests.ilproj b/src/ILVerification/tests/ILTests/FieldTests.ilproj new file mode 100644 index 000000000..8e8765d14 --- /dev/null +++ b/src/ILVerification/tests/ILTests/FieldTests.ilproj @@ -0,0 +1,3 @@ +<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="ILTests.targets" /> +</Project> diff --git a/src/ILVerification/tests/ILTests/FtnTests.ilproj b/src/ILVerification/tests/ILTests/FtnTests.ilproj new file mode 100644 index 000000000..8e8765d14 --- /dev/null +++ b/src/ILVerification/tests/ILTests/FtnTests.ilproj @@ -0,0 +1,3 @@ +<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="ILTests.targets" /> +</Project> diff --git a/src/ILVerification/tests/ILTests/ILTests.targets b/src/ILVerification/tests/ILTests/ILTests.targets new file mode 100644 index 000000000..22983bd3a --- /dev/null +++ b/src/ILVerification/tests/ILTests/ILTests.targets @@ -0,0 +1,17 @@ +<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + + <PropertyGroup> + <OutputType>Library</OutputType> + <AssemblyName>$(MSBuildProjectName)</AssemblyName> + <OutputPath>$(BaseOutputPath)$(OSPlatformConfig)/ILVerification.Tests/Tests</OutputPath> + <SkipTestRun>true</SkipTestRun> + <SkipSigning>true</SkipSigning> + </PropertyGroup> + + <ItemGroup> + <Compile Include="$(MSBuildProjectName).il" /> + </ItemGroup> + + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/src/ILVerification/tests/ILTests/LoadStoreIndirectTests.ilproj b/src/ILVerification/tests/ILTests/LoadStoreIndirectTests.ilproj new file mode 100644 index 000000000..8e8765d14 --- /dev/null +++ b/src/ILVerification/tests/ILTests/LoadStoreIndirectTests.ilproj @@ -0,0 +1,3 @@ +<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="ILTests.targets" /> +</Project> diff --git a/src/ILVerification/tests/ILTests/NewobjTests.ilproj b/src/ILVerification/tests/ILTests/NewobjTests.ilproj new file mode 100644 index 000000000..8e8765d14 --- /dev/null +++ b/src/ILVerification/tests/ILTests/NewobjTests.ilproj @@ -0,0 +1,3 @@ +<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="ILTests.targets" /> +</Project> diff --git a/src/ILVerification/tests/ILTests/PrefixTests.ilproj b/src/ILVerification/tests/ILTests/PrefixTests.ilproj new file mode 100644 index 000000000..8e8765d14 --- /dev/null +++ b/src/ILVerification/tests/ILTests/PrefixTests.ilproj @@ -0,0 +1,3 @@ +<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="ILTests.targets" /> +</Project> diff --git a/src/ILVerification/tests/ILTests/ReturnTests.ilproj b/src/ILVerification/tests/ILTests/ReturnTests.ilproj new file mode 100644 index 000000000..8e8765d14 --- /dev/null +++ b/src/ILVerification/tests/ILTests/ReturnTests.ilproj @@ -0,0 +1,3 @@ +<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="ILTests.targets" /> +</Project> diff --git a/src/ILVerification/tests/ILTests/ShiftTests.ilproj b/src/ILVerification/tests/ILTests/ShiftTests.ilproj new file mode 100644 index 000000000..8e8765d14 --- /dev/null +++ b/src/ILVerification/tests/ILTests/ShiftTests.ilproj @@ -0,0 +1,3 @@ +<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="ILTests.targets" /> +</Project> diff --git a/src/ILVerification/tests/ILTests/ThisStateTests.ilproj b/src/ILVerification/tests/ILTests/ThisStateTests.ilproj new file mode 100644 index 000000000..8e8765d14 --- /dev/null +++ b/src/ILVerification/tests/ILTests/ThisStateTests.ilproj @@ -0,0 +1,3 @@ +<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="ILTests.targets" /> +</Project> diff --git a/src/ILVerification/tests/ILTests/ValueTypeTests.ilproj b/src/ILVerification/tests/ILTests/ValueTypeTests.ilproj new file mode 100644 index 000000000..8e8765d14 --- /dev/null +++ b/src/ILVerification/tests/ILTests/ValueTypeTests.ilproj @@ -0,0 +1,3 @@ +<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="ILTests.targets" /> +</Project> diff --git a/src/ILVerification/tests/ILVerification.Tests.csproj b/src/ILVerification/tests/ILVerification.Tests.csproj index 4d5f17abf..237655ccc 100644 --- a/src/ILVerification/tests/ILVerification.Tests.csproj +++ b/src/ILVerification/tests/ILVerification.Tests.csproj @@ -3,7 +3,7 @@ <PropertyGroup> <OutputType>Library</OutputType> - <TargetFramework>netstandard1.5</TargetFramework> + <TargetFramework>netstandard2.0</TargetFramework> <IsPackable>false</IsPackable> </PropertyGroup> @@ -14,10 +14,8 @@ </ItemGroup> <ItemGroup> - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0-preview-20170427-09" /> - <PackageReference Include="xunit" Version="2.2.0" /> - <PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" /> - <PackageReference Include="Newtonsoft.Json" Version="10.0.2" /> + <PackageReference Include="xunit" Version="$(XUnitPackageVersion)" /> + <PackageReference Include="Newtonsoft.Json" Version="9.0.1" /> </ItemGroup> <ItemGroup> @@ -25,15 +23,19 @@ </ItemGroup> <ItemGroup> - <Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" /> + <ProjectReference Include="ILTests\*.ilproj"> + <ReferenceOutputAssembly>false</ReferenceOutputAssembly> + <OutputItemType>Content</OutputItemType> + </ProjectReference> </ItemGroup> <ItemGroup> - <Folder Include="ILTests\" /> + <Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" /> </ItemGroup> <ItemGroup> - <None Include="..\..\ILVerification\StrongNameKeys\ILVerify.snk" Link="ILVerify.snk" /> + <Folder Include="ILTests\" /> </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> </Project> diff --git a/src/ILVerification/tests/TestDataLoader.cs b/src/ILVerification/tests/TestDataLoader.cs index 91a1195f8..4184a5f6f 100644 --- a/src/ILVerification/tests/TestDataLoader.cs +++ b/src/ILVerification/tests/TestDataLoader.cs @@ -20,19 +20,17 @@ namespace ILVerification.Tests { /// <summary> /// Parses the methods in the test assemblies. - /// It loads all assemblies from the test folder defined in <code>TestDataLoader.TESTASSEMBLYPATH</code> + /// It loads all assemblies from the test folder defined in <code>TestDataLoader.TestAssemblyPath</code> /// This class feeds the xunit Theories /// </summary> class TestDataLoader { /// <summary> - /// The folder with the binaries which are compiled from the test driver IL Code - /// Currently the test .il code is built manually, but the plan is to have a ProjectReference and automatically build the .il files. - /// See: https://github.com/dotnet/corert/pull/3725#discussion_r118820770 + /// The folder with the test binaries /// </summary> - public static string TESTASSEMBLYPATH = @"..\..\..\ILTests\"; + private const string TestAssemblyPath = @"Tests\"; - private const string SPECIALTEST_PREFIX = "special."; + private const string SpecialTestPrefix = "special."; /// <summary> /// Returns all methods that contain valid IL code based on the following naming convention: @@ -129,11 +127,11 @@ namespace ILVerification.Tests private static MethodDefinitionHandle HandleSpecialTests(string[] methodParams, EcmaMethod method) { - if (!methodParams[0].StartsWith(SPECIALTEST_PREFIX)) + if (!methodParams[0].StartsWith(SpecialTestPrefix)) return method.Handle; // Cut off special prefix - var specialParams = methodParams[0].Substring(SPECIALTEST_PREFIX.Length); + var specialParams = methodParams[0].Substring(SpecialTestPrefix.Length); // Get friendly name / special name int delimiter = specialParams.IndexOf('.'); @@ -152,7 +150,7 @@ namespace ILVerification.Tests private static IEnumerable<string> GetAllTestDlls() { - foreach (var item in Directory.GetFiles(TESTASSEMBLYPATH)) + foreach (var item in Directory.GetFiles(TestAssemblyPath)) { if (item.ToLower().EndsWith(".dll")) { @@ -167,7 +165,7 @@ namespace ILVerification.Tests foreach (var fileName in GetAllTestDlls()) { - simpleNameToPathMap.Add(Path.GetFileNameWithoutExtension(fileName), TESTASSEMBLYPATH + fileName); + simpleNameToPathMap.Add(Path.GetFileNameWithoutExtension(fileName), TestAssemblyPath + fileName); } Assembly coreAssembly = typeof(object).GetTypeInfo().Assembly; @@ -178,9 +176,9 @@ namespace ILVerification.Tests var resolver = new TestResolver(simpleNameToPathMap); var typeSystemContext = new ILVerifyTypeSystemContext(resolver); - typeSystemContext.SetSystemModule(typeSystemContext.GetModule(resolver.Resolve(coreAssembly.GetName()))); + typeSystemContext.SetSystemModule(typeSystemContext.GetModule(resolver.Resolve(coreAssembly.GetName().Name))); - return typeSystemContext.GetModule(resolver.Resolve(new AssemblyName(Path.GetFileNameWithoutExtension(assemblyName)))); + return typeSystemContext.GetModule(resolver.Resolve(new AssemblyName(Path.GetFileNameWithoutExtension(assemblyName)).Name)); } private sealed class TestResolver : ResolverBase @@ -191,9 +189,9 @@ namespace ILVerification.Tests _simpleNameToPathMap = simpleNameToPathMap; } - protected override PEReader ResolveCore(AssemblyName name) + protected override PEReader ResolveCore(string simpleName) { - if (_simpleNameToPathMap.TryGetValue(name.Name, out string path)) + if (_simpleNameToPathMap.TryGetValue(simpleName, out string path)) { return new PEReader(File.OpenRead(path)); } |