Skip to content

Commit 583bc1d

Browse files
committed
Prevent the compiler from inlining the call to Assembly.GetCallingAssembly()
Fixes #16
1 parent 7de3ba3 commit 583bc1d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/Core/Shared/Extensions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Linq;
22
using System.Reflection;
3+
using System.Runtime.CompilerServices;
34
using Community.VisualStudio.Toolkit.DependencyInjection.Core;
45
using Microsoft.Extensions.DependencyInjection;
56

@@ -17,6 +18,7 @@ public static class Extensions
1718
/// <param name="serviceLifetime">Generally you should register them with a lifetime of <see cref="ServiceLifetime.Singleton"/>. You can also register them with a lifetime of <see cref="ServiceLifetime.Scoped"/></param>
1819
/// <param name="assemblies">Assemblies to scan for commands that inherit from <see cref="BaseDICommand"/>. If none are provided, then the calling assembly is scanned.</param>
1920
/// <returns></returns>
21+
[MethodImpl(MethodImplOptions.NoInlining)] // prevent the compiler from inlining the call to Assembly.GetCallingAssembly()
2022
public static IServiceCollection RegisterCommands(this IServiceCollection services, ServiceLifetime serviceLifetime, params Assembly[] assemblies)
2123
{
2224
if (!(assemblies?.Any() ?? false))

0 commit comments

Comments
 (0)