Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/BenchmarkDotNet/BenchmarkDotNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,10 @@
<ItemGroup>
<Compile Include="..\BenchmarkDotNet.Disassembler.x64\DataContracts.cs" Link="Disassemblers\DataContracts.cs" />
</ItemGroup>
<!-- Include files in nuget package for generating entry point -->
<ItemGroup>
<Compile Remove="Package\EntryPoint.*" />
<None Include="Package\EntryPoint.*" Pack="true" PackagePath="entrypoints\" />
<None Include="Package\BenchmarkDotNet.props" Pack="true" PackagePath="build\" />
</ItemGroup>
</Project>
12 changes: 12 additions & 0 deletions src/BenchmarkDotNet/Package/BenchmarkDotNet.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!-- Disables generation of MSTest entrypoint -->
<GenerateProgramFile>false</GenerateProgramFile>
<EntryPointSourceDirectory>$(MSBuildThisFileDirectory)..\entrypoints\</EntryPointSourceDirectory>
</PropertyGroup>
<ItemGroup Condition="'$(GenerateBDNEntryPoint)' == 'true'">
<Compile Include="$(EntryPointSourceDirectory)EntryPoint.cs" Condition="'$(Language)' == 'C#'" Visible="false"/>
<CompileAfter Include="$(EntryPointSourceDirectory)EntryPoint.fs" Condition="'$(Language)' == 'F#'" Visible="false"/>
<Compile Include="$(EntryPointSourceDirectory)EntryPoint.vb" Condition="'$(Language)' == 'VB'" Visible="false"/>
</ItemGroup>
</Project>
7 changes: 7 additions & 0 deletions src/BenchmarkDotNet/Package/EntryPoint.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using BenchmarkDotNet.Running;
using System.Reflection;

public class __AutoGeneratedEntryPointClass
{
public static void Main(string[] args) => BenchmarkSwitcher.FromAssembly(Assembly.GetEntryAssembly()).Run(args);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this type will be part of the produced .exe, we can use typeof(X).Assembly here:

Suggested change
public static void Main(string[] args) => BenchmarkSwitcher.FromAssembly(Assembly.GetEntryAssembly()).Run(args);
public static void Main(string[] args) => BenchmarkSwitcher.FromAssembly(typeof(__AutoGeneratedEntryPointClass).Assembly).Run(args);

}
8 changes: 8 additions & 0 deletions src/BenchmarkDotNet/Package/EntryPoint.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module __AutoGeneratedEntryPointClass
open System.Reflection;
open BenchmarkDotNet.Running

[<EntryPoint>]
let main argv =
BenchmarkSwitcher.FromAssembly(Assembly.GetEntryAssembly()).Run(argv) |> ignore
0 // return an integer exit code
10 changes: 10 additions & 0 deletions src/BenchmarkDotNet/Package/EntryPoint.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Imports System.Reflection
Imports BenchmarkDotNet.Running

Namespace Global
Module __AutoGeneratedEntryPointClass
Sub Main(args As String())
Dim summary = BenchmarkSwitcher.FromAssembly(Assembly.GetEntryAssembly()).Run(args)
End Sub
End Module
End Namespace