Skip to content

Commit 69da5a9

Browse files
author
Jonas Gauffin
committed
Version 3.0 rc-01
1 parent f2f717e commit 69da5a9

File tree

80 files changed

+854
-365
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+854
-365
lines changed

src/Server/Coderr.Server.Abstractions/Boot/RegisterExtensions.cs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
using System;
2-
using System.Diagnostics;
32
using System.Linq;
43
using System.Reflection;
5-
using System.Security.Cryptography.X509Certificates;
4+
using System.Runtime.CompilerServices;
65
using Microsoft.Extensions.DependencyInjection;
76

87
namespace Coderr.Server.Abstractions.Boot
98
{
109
public static class RegisterExtensions
1110
{
1211

13-
public static void RegisterContainerServices(this IServiceCollection serviceCollection, Assembly assembly)
12+
public static void RegisterContainerServices(this IServiceCollection serviceCollection, Assembly assembly, [CallerMemberName] string callerName = "")
1413
{
1514
var gotWrongAttribute = (
1615
from type in assembly.GetTypes()
@@ -28,8 +27,6 @@ where attributes.Count(x => x.GetType().FullName == "Griffin.Container.Container
2827

2928
foreach (var containerService in containerServices)
3029
{
31-
Debug.WriteLine(Assembly.GetCallingAssembly().GetName().Name + " registers " + containerService.FullName);
32-
3330
var attr = containerService.GetCustomAttribute<ContainerServiceAttribute>();
3431
var interfaces = containerService.GetInterfaces();
3532
var lifetime = ConvertLifetime(attr);
@@ -39,9 +36,9 @@ where attributes.Count(x => x.GetType().FullName == "Griffin.Container.Container
3936
if (interfaces.Length > 1 || attr.RegisterAsSelf)
4037
{
4138
serviceCollection.Add(new ServiceDescriptor(containerService, containerService, lifetime));
42-
isRegisteredAsSelf=true;
39+
isRegisteredAsSelf = true;
4340
}
44-
41+
4542

4643
foreach (var @interface in interfaces)
4744
{
@@ -53,16 +50,14 @@ where attributes.Count(x => x.GetType().FullName == "Griffin.Container.Container
5350
}
5451
}
5552

56-
public static void RegisterMessageHandlers(this IServiceCollection serviceCollection, Assembly assembly)
53+
public static void RegisterMessageHandlers(this IServiceCollection serviceCollection, Assembly assembly, [CallerMemberName] string callerName = "")
5754
{
5855
var types = assembly.GetTypes()
5956
.Where(y => y.GetInterfaces()
6057
.Any(x => x.Name.Contains("IMessageHandler") || x.Name.Contains("IQueryHandler")))
6158
.ToList();
6259
foreach (var type in types)
6360
{
64-
Debug.WriteLine(Assembly.GetCallingAssembly().GetName().Name + " registers " + type.FullName);
65-
6661
serviceCollection.AddScoped(type, type);
6762

6863
var ifs = type.GetInterfaces()

src/Server/Coderr.Server.Abstractions/Coderr.Server.Abstractions.csproj

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,4 @@
1313
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.22" />
1414
</ItemGroup>
1515

16-
<ItemGroup>
17-
<Folder Include="Tags\" />
18-
</ItemGroup>
19-
20-
2116
</Project>

src/Server/Coderr.Server.Api.Client.Tests/Coderr.Server.Api.Client.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net6</TargetFramework>
3+
<TargetFramework>netcoreapp3.1</TargetFramework>
44
<RootNamespace>Coderr.Server.Api.Client.Tests</RootNamespace>
55
<AssemblyName>Coderr.Server.Api.Client.Tests</AssemblyName>
66
<Configurations>Debug;Release;Premise</Configurations>

src/Server/Coderr.Server.App.Tests/Coderr.Server.App.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net6</TargetFramework>
3+
<TargetFramework>netcoreapp3.1</TargetFramework>
44
<RootNamespace>Coderr.Server.App.Tests</RootNamespace>
55
<AssemblyName>Coderr.Server.App.Tests</AssemblyName>
66
<Configurations>Debug;Release;Premise</Configurations>

src/Server/Coderr.Server.App/Core/Accounts/AccountService.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,23 +70,26 @@ public async Task<bool> ResetPassword(string activationKey, string newPassword)
7070
await _repository.UpdateAsync(account);
7171
return true;
7272
}
73-
73+
7474

7575
/// <summary>
7676
/// Execute the request and generate a reply.
7777
/// </summary>
78-
/// <param name="request">Request to execute</param>
78+
/// <param name="messagingPrincipal"></param>
79+
/// <param name="activationKey"></param>
7980
/// <returns>
8081
/// Task which will contain the reply once completed.
8182
/// </returns>
8283
public async Task<ClaimsIdentity> ActivateAccount(ClaimsPrincipal messagingPrincipal, string activationKey)
8384
{
85+
if (messagingPrincipal == null) throw new ArgumentNullException(nameof(messagingPrincipal));
86+
if (activationKey == null) throw new ArgumentNullException(nameof(activationKey));
87+
8488
var account = await _repository.FindByActivationKeyAsync(activationKey);
8589
if (account == null)
86-
throw new ArgumentOutOfRangeException("ActivationKey", activationKey,
90+
throw new ArgumentOutOfRangeException(nameof(activationKey), activationKey,
8791
"Key was not found.");
8892

89-
9093
account.Activate();
9194
await _repository.UpdateAsync(account);
9295

src/Server/Coderr.Server.App/Modules/Whitelists/WhitelistService.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ public async Task<bool> Validate(string appKey, IPAddress remoteAddress)
3939
/// <returns></returns>h
4040
public async Task<bool> Validate(int applicationId, IPAddress remoteAddress)
4141
{
42+
if (remoteAddress.IsIPv6LinkLocal || remoteAddress.IsIPv6SiteLocal || Equals(remoteAddress, IPAddress.Loopback) || Equals(remoteAddress, IPAddress.IPv6Loopback))
43+
{
44+
return true;
45+
}
46+
4247
var ipEntry = await _repository.FindIp(applicationId, remoteAddress);
4348
if (ipEntry != null)
4449
{

src/Server/Coderr.Server.Infrastructure.Tests/Coderr.Server.Infrastructure.Tests.csproj

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net461</TargetFramework>
5-
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
65
<IsPackable>false</IsPackable>
76
</PropertyGroup>
87

98
<ItemGroup>
10-
<PackageReference Include="FluentAssertions" Version="5.10.3" />
9+
<PackageReference Include="FluentAssertions" Version="6.4.0" />
1110
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
1211
<PackageReference Include="xunit" Version="2.4.0" />
1312
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
1413
<PrivateAssets>all</PrivateAssets>
1514
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1615
</PackageReference>
1716
<PackageReference Include="coverlet.collector" Version="1.2.0" />
18-
<PackageReference Include="DotNetCqs" Version="2.1.0" />
17+
<PackageReference Include="DotNetCqs" Version="2.1.1" />
1918
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
2019
</ItemGroup>
2120

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using Coderr.Server.ReportAnalyzer.ApplicationVersions.Handlers;
2+
using FluentAssertions;
3+
using Xunit;
4+
5+
namespace Coderr.Server.ReportAnalyzer.Tests.ApplicationVersions.Handlers
6+
{
7+
public class GetVersionFromReportTests
8+
{
9+
[Fact]
10+
public void Should_keep_one_zero_for_exact_majors()
11+
{
12+
var expected = "1.0";
13+
14+
var actual = GetVersionFromReport.SimplifyVersion("1.0.0.0");
15+
16+
actual.Should().Be(expected);
17+
}
18+
19+
[Fact]
20+
public void Should_trim_end_zeros_but_leave_other_digits()
21+
{
22+
var expected = "3.1";
23+
24+
var actual = GetVersionFromReport.SimplifyVersion("3.1.0.0");
25+
26+
actual.Should().Be(expected);
27+
}
28+
}
29+
}

src/Server/Coderr.Server.ReportAnalyzer.Tests/Coderr.Server.ReportAnalyzer.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net6</TargetFramework>
3+
<TargetFramework>netcoreapp3.1</TargetFramework>
44
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
55
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
66
</PropertyGroup>

src/Server/Coderr.Server.ReportAnalyzer.Tests/Domain/Reports/HashCodeGeneratorTests.cs

Lines changed: 49 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Text.RegularExpressions;
43
using Coderr.Server.Domain.Core.ErrorReports;
54
using Coderr.Server.ReportAnalyzer.ErrorReports;
65
using FluentAssertions;
7-
using NSubstitute;
86
using Xunit;
97

108
namespace Coderr.Server.ReportAnalyzer.Tests.Domain.Reports
@@ -14,9 +12,9 @@ public class HashCodeGeneratorTests
1412
[Fact]
1513
public void Should_strip_line_numbers_to_reduce_the_number_of_incidents()
1614
{
17-
var ex1 = new ErrorReportException {StackTrace = @" at System.Web.Compilation.AssemblyBuilder.Compile():line 64
15+
var ex1 = new ErrorReportException { StackTrace = @" at System.Web.Compilation.AssemblyBuilder.Compile():line 64
1816
at System.Web.Compilation.BuildProvidersCompiler.PerformBuild():line 65
19-
at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath):line 67"};
17+
at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath):line 67" };
2018
var ex2 = new ErrorReportException
2119
{
2220
StackTrace = @" at System.Web.Compilation.AssemblyBuilder.Compile():line 12
@@ -30,7 +28,7 @@ at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath):l
3028
var actual1 = sut.GenerateHashCode(report1);
3129
var actual2 = sut.GenerateHashCode(report2);
3230

33-
actual1.Should().Be(actual2);
31+
actual1.HashCode.Should().Be(actual2.HashCode);
3432
}
3533

3634
[Fact]
@@ -52,7 +50,7 @@ at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath)"
5250
var actual1 = sut.GenerateHashCode(report1);
5351
var actual2 = sut.GenerateHashCode(report2);
5452

55-
actual1.Should().Be(actual2);
53+
actual1.HashCode.Should().Be(actual2.HashCode);
5654
}
5755

5856

@@ -133,17 +131,16 @@ at DotNetCqs.DependencyInjection.MessageInvoker.<InvokeQueryHandler>d__22.MoveNe
133131
var data = HashCodeGenerator.CleanStackTrace(stacktrace);
134132

135133
data.Should().Be(
136-
@" at System.Data.SqlClient.SqlCommand.<>c.<ExecuteDbDataReaderAsync>b__108_0(Task`1 result)
137-
at Coderr.Server.SqlServer.Core.Incidents.Queries.GetCollectionHandler.HandleAsync in D:\AgentWork\10\s\src\Server\Coderr.Server.SqlServer\Core\Incidents\Queries\GetCollectionHandler.cs()
138-
at DotNetCqs.DependencyInjection.MessageInvoker.InvokeQueryHandler()
139-
at DotNetCqs.DependencyInjection.MessageInvoker.InvokeQueryHandler()
140-
at DotNetCqs.DependencyInjection.MessageInvoker.ProcessAsync()
141-
at DotNetCqs.MessageProcessor.ExecuteQueriesInvocationContext.QueryAsync()
142-
at DotNetCqs.Bus.ScopedQueryBus.QueryAsync()
143-
at Coderr.Server.Common.App.HighlightedData.CustomContextDataProvider.CollectAsync() in D:\AgentWork\10\s\src\Server\Common\Coderr.Server.Common.App\HighlightedData\CustomContextDataProvider.cs()
144-
at Coderr.Server.SqlServer.Core.Incidents.Queries.GetIncidentHandler.HandleAsync() in D:\AgentWork\10\s\src\Server\Coderr.Server.SqlServer\Core\Incidents\Queries\GetIncidentHandler.cs()
145-
at DotNetCqs.DependencyInjection.MessageInvoker.InvokeQueryHandler()
146-
");
134+
@"System.Data.SqlClient.SqlCommand.<>c.<ExecuteDbDataReaderAsync>b__108_0(Task`1 result)
135+
Coderr.Server.SqlServer.Core.Incidents.Queries.GetCollectionHandler.HandleAsync() in D:\AgentWork\10\s\src\Server\Coderr.Server.SqlServer\Core\Incidents\Queries\GetCollectionHandler.cs
136+
DotNetCqs.DependencyInjection.MessageInvoker.InvokeQueryHandler()
137+
DotNetCqs.DependencyInjection.MessageInvoker.InvokeQueryHandler()
138+
DotNetCqs.DependencyInjection.MessageInvoker.ProcessAsync()
139+
DotNetCqs.MessageProcessor.ExecuteQueriesInvocationContext.QueryAsync()
140+
DotNetCqs.Bus.ScopedQueryBus.QueryAsync()
141+
Coderr.Server.Common.App.HighlightedData.CustomContextDataProvider.CollectAsync() in D:\AgentWork\10\s\src\Server\Common\Coderr.Server.Common.App\HighlightedData\CustomContextDataProvider.cs
142+
Coderr.Server.SqlServer.Core.Incidents.Queries.GetIncidentHandler.HandleAsync() in D:\AgentWork\10\s\src\Server\Coderr.Server.SqlServer\Core\Incidents\Queries\GetIncidentHandler.cs
143+
DotNetCqs.DependencyInjection.MessageInvoker.InvokeQueryHandler()");
147144
}
148145

149146
[Fact]
@@ -162,17 +159,17 @@ public void Should_ignore_java_lambdas()
162159
at java.lang.Thread->run(null:-1)" };
163160
var ex2 = new ErrorReportException
164161
{
165-
StackTrace = @"at java.lang.NumberFormatException->forInputString(null:-1)
166-
at java.lang.Integer->parseInt(null:-1)
167-
at java.lang.Integer->parseInt(null:-1)
168-
at se.fleetech.gateway.app.services.alarms.EngineCoolantTemperatureAlarmStateChangeServiceImpl->handleET1Message(EngineCoolantTemperatureAlarmStateChangeServiceImpl.java:112)
169-
at se.fleetech.gateway.app.services.alarms.EngineCoolantTemperatureAlarmStateChangeServiceImpl->actorCallback(EngineCoolantTemperatureAlarmStateChangeServiceImpl.java:62)
170-
at se.fleetech.gateway.app.services.alarms.EngineCoolantTemperatureAlarmStateChangeServiceImpl$$Lambda$19/14039178->accept(null:-1)
171-
at se.fleetech.gateway.app.services.general.ActorService->lambda$start$0(ActorService.java:45)
172-
at se.fleetech.gateway.app.services.general.ActorService$$Lambda$36/12952319->run(null:-1)
173-
at java.util.concurrent.ThreadPoolExecutor->runWorker(null:-1)
174-
at java.util.concurrent.ThreadPoolExecutor$Worker->run(null:-1)
175-
at java.lang.Thread->run(null:-1)"
162+
StackTrace = @"java.lang.NumberFormatException->forInputString(null:-1)
163+
java.lang.Integer->parseInt(null:-1)
164+
java.lang.Integer->parseInt(null:-1)
165+
se.fleetech.gateway.app.services.alarms.EngineCoolantTemperatureAlarmStateChangeServiceImpl->handleET1Message(EngineCoolantTemperatureAlarmStateChangeServiceImpl.java:112)
166+
se.fleetech.gateway.app.services.alarms.EngineCoolantTemperatureAlarmStateChangeServiceImpl->actorCallback(EngineCoolantTemperatureAlarmStateChangeServiceImpl.java:62)
167+
se.fleetech.gateway.app.services.alarms.EngineCoolantTemperatureAlarmStateChangeServiceImpl$$Lambda$19/14039178->accept(null:-1)
168+
se.fleetech.gateway.app.services.general.ActorService->lambda$start$0(ActorService.java:45)
169+
se.fleetech.gateway.app.services.general.ActorService$$Lambda$36/12952319->run(null:-1)
170+
java.util.concurrent.ThreadPoolExecutor->runWorker(null:-1)
171+
java.util.concurrent.ThreadPoolExecutor$Worker->run(null:-1)
172+
java.lang.Thread->run(null:-1)"
176173
};
177174

178175
var report1 = new ErrorReportEntity(1, "fjkkfjjkf", DateTime.UtcNow, ex1, new List<ErrorReportContextCollection>());
@@ -182,7 +179,30 @@ public void Should_ignore_java_lambdas()
182179
var actual1 = sut.GenerateHashCode(report1);
183180
var actual2 = sut.GenerateHashCode(report2);
184181

185-
actual1.Should().Be(actual2);
182+
actual1.HashCode.Should().Be(actual2.HashCode);
183+
}
184+
185+
[Fact]
186+
public void Should_remove_dotNet_lambdas()
187+
{
188+
var strackTrace =
189+
@"at MvcDemo.Controllers.HomeController.Index(PostModel model) in E:\src\1tcompany\coderr\Demos\csharp\Web\ASP.NET Core Mvc\MvcDemo\MvcDemo\Controllers\HomeController.cs:line 31
190+
at lambda_method26(Closure , Object , Object[] )
191+
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
192+
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
193+
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
194+
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()
195+
--- End of stack trace from previous location ---
196+
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
197+
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
198+
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
199+
--- End of stack trace from previous location ---
200+
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)";
201+
202+
var cleaned = HashCodeGenerator.CleanStackTrace(strackTrace);
203+
204+
var actual = @"MvcDemo.Controllers.HomeController.Index(PostModel model) in E:\src\1tcompany\coderr\Demos\csharp\Web\ASP.NET Core Mvc\MvcDemo\MvcDemo\Controllers\HomeController.cs";
205+
cleaned.Should().Be(actual);
186206
}
187207
}
188208
}

0 commit comments

Comments
 (0)