Skip to content

Commit

Permalink
Tweaking Lamar's check for types it should always ignore to include G…
Browse files Browse the repository at this point in the history
…uids. Bumps to 13.0.3.
  • Loading branch information
jeremydmiller committed Feb 19, 2024
1 parent e3ddc4f commit 29ee873
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Lamar.Diagnostics/Lamar.Diagnostics.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>Adds diagnostic checks to the command line of your Lamar-enabled ASP.Net Core app</Description>
<Version>13.0.2</Version>
<Version>13.0.3</Version>
<Authors>Jeremy D. Miller</Authors>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<DebugType>portable</DebugType>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>Lamar Adapter for HostBuilder Integration</Description>
<Version>13.0.2</Version>
<Version>13.0.3</Version>
<Authors>Jeremy D. Miller</Authors>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<DebugType>portable</DebugType>
Expand Down
46 changes: 46 additions & 0 deletions src/Lamar.Testing/IoC/Instances/ConstructorInstanceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Lamar.IoC.Frames;
using Lamar.IoC.Instances;
using Lamar.IoC.Resolvers;
using Microsoft.CodeAnalysis.VisualBasic.Syntax;
using Microsoft.Extensions.DependencyInjection;
using NSubstitute;
using Shouldly;
Expand Down Expand Up @@ -277,6 +278,51 @@ public void resolve_from_scope_when_scoped_and_used_as_a_dependency()
.ShouldBeOfType<GetInstanceFrame>();
}

[Fact]
public void do_not_consider_guid_as_something_it_can_resolve()
{
var instance = new ConstructorInstance(typeof(GuyWithGuidConstructor), typeof(GuyWithGuidConstructor), ServiceLifetime.Singleton);
var theServices = new ServiceRegistry();
theServices.AddSingleton<IWidget, AWidget>();
theServices.AddTransient<Rule, BlueRule>();

var theGraph = new ServiceGraph(theServices, Scope.Empty());
theGraph.Initialize();
var ctor = instance.DetermineConstructor(theGraph, out var message);
ctor.ShouldNotBeNull();
ctor.GetParameters().Any(x => x.ParameterType == typeof(Guid)).ShouldBeFalse();
}

public class GuyWithGuidConstructor
{
public GuyWithGuidConstructor(IWidget widget)
{

}

public GuyWithGuidConstructor(IWidget widget, Guid id)
{

}

public GuyWithGuidConstructor(IWidget widget, Guid id, Guid other)
{

}

public GuyWithGuidConstructor(Guid id, Guid other)
{

}
}

public class GuyWithOnlyGuids
{
public GuyWithOnlyGuids(Guid id, Guid other)
{
}
}

public class GuyWithMultipleConstructors
{
public GuyWithMultipleConstructors(IWidget widget, Rule rule)
Expand Down
2 changes: 1 addition & 1 deletion src/Lamar/Lamar.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>Fast ASP.Net Core compatible IoC Tool, Successor to StructureMap</Description>
<Version>13.0.2</Version>
<Version>13.0.3</Version>
<Authors>Jeremy D. Miller</Authors>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<DebugType>portable</DebugType>
Expand Down
2 changes: 2 additions & 0 deletions src/Lamar/Util/TypeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ internal static bool ShouldIgnore(this Type type)
return true;
}

if (type == typeof(Guid)) return true;

if (type.IsEnum)
{
return true;
Expand Down

0 comments on commit 29ee873

Please sign in to comment.