Benchmarkdotnet: Add references to default framework assemblies (System.Runtime etc)

Created on 15 Jul 2016  路  2Comments  路  Source: dotnet/BenchmarkDotNet

Hi there,

Could be something simple but I struggle with project.json

I made an attempt to upgrade the ImageProcessorCore benchmarks to v0.9.8. The project compiles but fails with the following message when running the benchmark.

BuildScript: C:\github\ImageProcessor\tests\ImageProcessorCore.Benchmarks\bin\Release\net451\win7-x64\BDN.Auto.bat
CS0012: The type 'ValueType' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.// Result = Failure

I added the dependency to my base library but the error still threw. Is it a simple configuration issue?

Here's my project.json files.

ImageProcessorCore

{
  "version": "1.0.0-*",
  "title": "ImageProcessorCore",
  "description": "A cross-platform library for processing of image files written in C#",
  "authors": [
    "James Jackson-South and contributors"
  ],
  "packOptions": {
    "projectUrl": "https://github.com/JimBobSquarePants/ImageProcessor",
    "licenseUrl": "http://www.apache.org/licenses/LICENSE-2.0",
    "tags": [
      "Image Resize Crop Quality Gif Jpg Jpeg Bitmap Png Fluent Animated"
    ]
  },
  "buildOptions": {
    "allowUnsafe": true,
    "debugType": "portable"
  },
  "dependencies": {
    "System.Collections": "4.0.11",
    "System.Diagnostics.Debug": "4.0.11",
    "System.Diagnostics.Tools": "4.0.1",
    "System.IO": "4.1.0",
    "System.IO.Compression": "4.1.0",
    "System.Linq": "4.1.0",
    "System.Numerics.Vectors": "4.1.1",
    "System.Resources.ResourceManager": "4.0.1",
    "System.Runtime.Extensions": "4.1.0",
    "System.Runtime.InteropServices": "4.1.0",
    "System.Text.Encoding.Extensions": "4.0.11",
    "System.Threading": "4.0.11",
    "System.Threading.Tasks": "4.0.11",
    "System.Threading.Tasks.Parallel": "4.0.1"
  },
  "frameworks": {
    "netstandard1.1": {}
  }
}

BenchmarkDotNet

{
  "version": "1.0.0-*",
  "description": "ImageProcessorCore.Benchmarks Console Application",
  "authors": [ "James.South" ],
  "packOptions": {
    "projectUrl": "https://github.com/JimBobSquarePants/ImageProcessor",
    "licenseUrl": "http://www.apache.org/licenses/LICENSE-2.0",
    "tags": [
      "Image Resize Crop Quality Gif Jpg Jpeg Bitmap Png Fluent Animated"
    ]
  },
  "buildOptions": {
    "emitEntryPoint": true
  },
  "dependencies": {
    "BenchmarkDotNet": "0.9.7",
    "BenchmarkDotNet.Diagnostics.Windows": "0.9.7",
    "ImageProcessorCore": "1.0.0-*"
  },
  "commands": {
    "ImageProcessorCore.Benchmarks": "ImageProcessorCore.Benchmarks"
  },
  "frameworks": {
    "net451": {
      "dependencies": {
      },
      "imports": [
        "dnx451"
      ],
      "frameworkAssemblies": {
        "System.Drawing": "",
        "System.Runtime": ""
      }
    }
  }
}
bug

Most helpful comment

Fixed! It seems that when we switched from MSBuild to Roslyn we did not mimic all of it's behaviour (setting default framework assemblies). System.Runtime.dll is empty by default so when we were calling assembly.GetReferenced it was not returned, because the assembly that contained benchmark were not using any type from it...

Extra I have used different method AssemblyMetadata.CreateFromFile instead of MetadataReference.CreateFromFile which offers caching. The result is that our integration tests for the Classic toolchain execute two times faster now!

All 2 comments

Fixed! It seems that when we switched from MSBuild to Roslyn we did not mimic all of it's behaviour (setting default framework assemblies). System.Runtime.dll is empty by default so when we were calling assembly.GetReferenced it was not returned, because the assembly that contained benchmark were not using any type from it...

Extra I have used different method AssemblyMetadata.CreateFromFile instead of MetadataReference.CreateFromFile which offers caching. The result is that our integration tests for the Classic toolchain execute two times faster now!

Great to hear. Thanks for being so reactive.

Was this page helpful?
0 / 5 - 0 ratings