Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated code fails to build #42

Closed
thomaslevesque opened this issue Oct 20, 2015 · 14 comments
Closed

Generated code fails to build #42

thomaslevesque opened this issue Oct 20, 2015 · 14 comments

Comments

@thomaslevesque
Copy link
Member

I tried to run a small benchmark from LINQPad, and the generated code fails to compile:

using System;
using System.Diagnostics;
using System.Threading;
using System.Runtime.CompilerServices;
using BenchmarkDotNet;
using BenchmarkDotNet.Tasks;
using ;
using System;



namespace BenchmarkDotNet.Autogenerated
{
    public class Program : UserQuery.CallStyleBenchmark
    {
        public static void Main(string[] args)
        {
...

This is caused by the empty using clause on line 7

@AndreyAkinshin
Copy link
Member

@thomaslevesque, can you share a repro for the issue?

@thomaslevesque
Copy link
Member Author

I think this is because LINQPad's UserQuery class is not in a namespace, but the template expects a namespace.

@thomaslevesque
Copy link
Member Author

@AndreyAkinshin, just try to create any benchmark in LINQPad. Given the cause of the issue, I'm pretty sure it can be reproduced every time.

@thomaslevesque
Copy link
Member Author

OK, I just tried to fix the code to handle this case, but there's another issue. BenchmarkDotNet seems to assume that all required assemblies are in the working directory, but it's not necessarily the case. In fact, it's definitely not the case when running a LinqPad query.

@AndreyAkinshin
Copy link
Member

@thomaslevesque, ok, thanks for the investigation, I will try to fix it.

@mattwarren
Copy link
Contributor

@thomaslevesque I'm just taking a look at this, sorry for the delay.

Just to make sure I'm testing in the same way as you, in LINQPad I assume you have your Benchmark setup something like this (sorry, I'm no LINQPad expert, so I don't know if this is the natural way to do it or not)?

image

image

@mattwarren
Copy link
Contributor

Either way, I see the same problem, here's my output:

// ***** BenchmarkRunner: Start   *****
// Found benchmarks:
//   Intro_00_Basic_Sleep (SingleRun_HostPlatform_HostJit_NET-HostFramework)
//   Thread.Sleep(100) (SingleRun_HostPlatform_HostJit_NET-HostFramework)

// **************************
// Benchmark: Intro_00_Basic_Sleep (SingleRun_HostPlatform_HostJit_NET-HostFramework)
// *** Generate *** 
// Result = Success
// DirectoryPath = C:\Program Files (x86)\LINQPad4\Intro_00_Basic_Sleep_SingleRun_HostPlatform_HostJit_NET-HostFramework

// *** Build ***
// Program.cs(7,7): error CS1001: Identifier expected
// Result = Failure


// **************************
// Benchmark: Thread.Sleep(100) (SingleRun_HostPlatform_HostJit_NET-HostFramework)
// *** Generate *** 
// Result = Success
// DirectoryPath = C:\Program Files (x86)\LINQPad4\Intro_00_Basic_SleepWithDescription_SingleRun_HostPlatform_HostJit_NET-HostFramework

// *** Build ***
// Program.cs(7,7): error CS1001: Identifier expected
// Result = Failure


// ***** BenchmarkRunner: Finish  *****

BenchmarkDotNet-Dev=v0.7.8.0+
OS=Microsoft Windows NT 6.1.7601 Service Pack 1
Processor=Intel(R) Core(TM) i7-4800MQ CPU @ 2.70GHz, ProcessorCount=8
HostCLR=MS.NET 4.0.30319.42000, Arch=32-bit 
There are no found benchmarks

Benchmarks with troubles:
  Intro_00_Basic_Sleep_SingleRun_HostPlatform_HostJit_NET-HostFramework
  Intro_00_Basic_SleepWithDescription_SingleRun_HostPlatform_HostJit_NET-HostFramework

// ***** BenchmarkRunner: End *****

@thomaslevesque
Copy link
Member Author

in LINQPad I assume you have your Benchmark setup something like this

Yes (assuming you also have a Main method that's not visible in your screenshot)

The namespace issue is easy to fix. To fix the missing assembly issue, I think the referenced assemblies will have to be copied.

@mattwarren
Copy link
Contributor

The namespace issue is easy to fix. To fix the missing assembly issue, I think the referenced assemblies will have to be copied.

I just checked in a fix that does exactly this, when you get a chance can you try it out?

@thomaslevesque
Copy link
Member Author

I just checked in a fix that does exactly this, when you get a chance can you try it out?

Sure, I'll do this ASAP. Is there a pre-release NuGet package available with the fix, or do I have to build it from source?

@AndreyAkinshin
Copy link
Member

@thomaslevesque, for now you should build it from source (VisualStudio 2015 is required).

@thomaslevesque
Copy link
Member Author

It works fine now 👍

@AndreyAkinshin
Copy link
Member

@thomaslevesque, cool! I will update the NuGet package on the weekend.

@mattwarren
Copy link
Contributor

@thomaslevesque thanks for confirming the fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants