Skip to content

Commit ae5eab6

Browse files
authored
Merge pull request #8 from DeviesDevelopment/cleanup
Cleanup & Publish
2 parents 1076c25 + 7c439c7 commit ae5eab6

29 files changed

+195
-224
lines changed

.github/workflows/nuget-publish.yml

Whitespace-only changes.

EntityInjector.Route/EntityInjector.Route.csproj

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,19 @@
77
<Company>Devies</Company>
88
<Authors>John Johansson; Erik Jergéus</Authors>
99
<TargetFramework>netstandard2.1</TargetFramework>
10-
<LangVersion>13</LangVersion>
10+
<LangVersion>latest</LangVersion>
1111
<ImplicitUsings>enable</ImplicitUsings>
1212
<Nullable>enable</Nullable>
13-
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
13+
<Description>A small library for injecting routes into Entity Framework contexts.</Description>
14+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
15+
<PackageProjectUrl>https://github.com/DeviesDevelopment/entity-injector</PackageProjectUrl>
16+
<RepositoryUrl>https://github.com/DeviesDevelopment/entity-injector</RepositoryUrl>
17+
<RepositoryType>git</RepositoryType>
1418
</PropertyGroup>
1519

1620
<ItemGroup>
17-
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.3.0" />
18-
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.3.0" />
21+
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.3.0"/>
22+
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.3.0"/>
1923
</ItemGroup>
2024

2125
</Project>

EntityInjector.Route/Exceptions/StatusExceptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ namespace EntityInjector.Route.Exceptions;
22

33
public class InternalServerErrorException(string message) : Exception(message);
44

5-
public class NotFoundException(string message) : Exception(message);
5+
public class NotFoundException(string message) : Exception(message);
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
namespace EntityInjector.Route.Middleware.Attributes;
22

3-
[AttributeUsage(AttributeTargets.Parameter, Inherited = true)]
3+
[AttributeUsage(AttributeTargets.Parameter)]
44
public class FromRouteToCollectionAttribute(string argumentName, string? metaData = null) : Attribute
55
{
66
public readonly string ArgumentName = argumentName;
77
public readonly Dictionary<string, string> MetaData = MetadataParsingHelper.ParseMetaData(metaData);
8-
}
8+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
namespace EntityInjector.Route.Middleware.Attributes;
22

3-
[AttributeUsage(AttributeTargets.Parameter, Inherited = true)]
3+
[AttributeUsage(AttributeTargets.Parameter)]
44
public class FromRouteToEntityAttribute(string argumentName, string? metaData = null) : Attribute
55
{
66
public readonly string ArgumentName = argumentName;
77
public readonly Dictionary<string, string> MetaData = MetadataParsingHelper.ParseMetaData(metaData);
8-
}
8+
}

EntityInjector.Route/Middleware/Attributes/MetadataParsingHelper.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ namespace EntityInjector.Route.Middleware.Attributes;
22

33
public static class MetadataParsingHelper
44
{
5-
65
public static Dictionary<string, string> ParseMetaData(string? metaData)
76
{
87
if (string.IsNullOrEmpty(metaData)) return new Dictionary<string, string>();

EntityInjector.Route/Middleware/BindingMetadata/Collection/GuidCollectionBindingMetadataProvicer.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,40 +11,28 @@ protected override List<Guid> GetIds(ActionContext context, string argumentName)
1111
var routeValue = context.HttpContext.GetRouteValue(argumentName);
1212

1313
if (routeValue == null)
14-
{
1514
throw new InternalServerErrorException(
1615
$"No route value found for parameter '{argumentName}'. Ensure it's included in the route.");
17-
}
1816

1917
var rawString = routeValue.ToString();
2018
if (string.IsNullOrWhiteSpace(rawString))
21-
{
2219
throw new InternalServerErrorException(
2320
$"Route parameter '{argumentName}' is present but empty. Expected a comma-separated list of GUIDs.");
24-
}
2521

2622
var segments = rawString.Split(',');
2723

2824
var invalidSegments = new List<string>();
2925
var parsedGuids = new List<Guid>();
3026

3127
foreach (var segment in segments)
32-
{
3328
if (Guid.TryParse(segment, out var parsed))
34-
{
3529
parsedGuids.Add(parsed);
36-
}
3730
else
38-
{
3931
invalidSegments.Add(segment);
40-
}
41-
}
4232

4333
if (invalidSegments.Any())
44-
{
4534
throw new InternalServerErrorException(
4635
$"The following values in route parameter '{argumentName}' are not valid GUIDs: {string.Join(", ", invalidSegments)}.");
47-
}
4836

4937
return parsedGuids;
5038
}

EntityInjector.Route/Middleware/BindingMetadata/Collection/IntCollectionBindingMetadataProvicer.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,40 +11,28 @@ protected override List<int> GetIds(ActionContext context, string argumentName)
1111
var routeValue = context.HttpContext.GetRouteValue(argumentName);
1212

1313
if (routeValue == null)
14-
{
1514
throw new InternalServerErrorException(
1615
$"No route value found for parameter '{argumentName}'. Ensure it's included in the route.");
17-
}
1816

1917
var rawString = routeValue.ToString();
2018
if (string.IsNullOrWhiteSpace(rawString))
21-
{
2219
throw new InternalServerErrorException(
2320
$"Route parameter '{argumentName}' is present but empty. Expected a comma-separated list of ints.");
24-
}
2521

2622
var segments = rawString.Split(',');
2723

2824
var invalidSegments = new List<string>();
2925
var parsedInts = new List<int>();
3026

3127
foreach (var segment in segments)
32-
{
3328
if (int.TryParse(segment, out var parsed))
34-
{
3529
parsedInts.Add(parsed);
36-
}
3730
else
38-
{
3931
invalidSegments.Add(segment);
40-
}
41-
}
4232

4333
if (invalidSegments.Any())
44-
{
4534
throw new InternalServerErrorException(
4635
$"The following values in route parameter '{argumentName}' are not valid ints: {string.Join(", ", invalidSegments)}.");
47-
}
4836

4937
return parsedInts;
5038
}

EntityInjector.Route/Middleware/BindingMetadata/Collection/StringCollectionBindingMetadataProvicer.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,21 @@
44

55
namespace EntityInjector.Route.Middleware.BindingMetadata.Collection;
66

7-
public class StringCollectionBindingMetadataProvider<TValue> : FromRouteToCollectionBindingMetadataProvider<string, TValue>
7+
public class
8+
StringCollectionBindingMetadataProvider<TValue> : FromRouteToCollectionBindingMetadataProvider<string, TValue>
89
{
910
protected override List<string> GetIds(ActionContext context, string argumentName)
1011
{
1112
var routeValue = context.HttpContext.GetRouteValue(argumentName);
1213

1314
if (routeValue == null)
14-
{
1515
throw new InternalServerErrorException(
1616
$"No route value found for parameter '{argumentName}'. Ensure it's included in the route.");
17-
}
1817

1918
var rawString = routeValue.ToString();
2019
if (string.IsNullOrWhiteSpace(rawString))
21-
{
2220
throw new InternalServerErrorException(
2321
$"Route parameter '{argumentName}' is present but empty. Expected a comma-separated list of GUIDs.");
24-
}
2522

2623
var segments = rawString
2724
.Split(',', StringSplitOptions.RemoveEmptyEntries)
@@ -30,10 +27,8 @@ protected override List<string> GetIds(ActionContext context, string argumentNam
3027
.ToList();
3128

3229
if (segments.Count == 0)
33-
{
3430
throw new InternalServerErrorException(
3531
$"Route parameter '{argumentName}' did not contain any valid string segments.");
36-
}
3732

3833
return segments;
3934
}

EntityInjector.Route/Middleware/BindingMetadata/Entity/GuidEntityBindingMetadataProvicer.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,15 @@
44

55
namespace EntityInjector.Route.Middleware.BindingMetadata.Entity;
66

7-
public class GuidEntityBindingMetadataProvider<TValue> : FromRouteToEntityBindingMetadataProvider<Guid,TValue>
7+
public class GuidEntityBindingMetadataProvider<TValue> : FromRouteToEntityBindingMetadataProvider<Guid, TValue>
88
{
99
protected override Guid GetId(ActionContext context, string argumentName)
1010
{
1111
var routeValue = context.HttpContext.GetRouteValue(argumentName);
1212

1313
if (routeValue == null)
14-
{
1514
throw new InternalServerErrorException(
1615
$"Route value for '{argumentName}' was not found. Make sure it is part of the route pattern.");
17-
}
1816

1917
try
2018
{

0 commit comments

Comments
 (0)