Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small performance improvements #150

Merged
merged 7 commits into from
Aug 9, 2020
Merged
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
8 changes: 5 additions & 3 deletions Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<PackageReference Update="AutoFixture.AutoMoq" Version="4.8.0" />
<PackageReference Update="AutoFixture.Idioms" Version="4.8.0" />
<PackageReference Update="AutoFixture.Xunit2" Version="4.8.0" />
<PackageReference Update="BenchmarkDotNet" Version="0.12.1" />
<PackageReference Update="BenchmarkDotNet.Diagnostics.Windows" Version="0.12.1" />
<PackageReference Update="FluentAssertions" Version="5.6.0" />
<PackageReference Update="Microsoft.AspNetCore.App">
<Version>$(AspNetCoreAllRuntimeFrameworkVersion)</Version>
Expand All @@ -20,9 +22,9 @@
<PackageReference Update="Selenium.Support" Version="3.14.0" />
<PackageReference Update="Selenium.WebDriver" Version="3.14.0" />
<PackageReference Update="Selenium.WebDriver.ChromeDriver" Version="2.43.0" />
<PackageReference Update="SonarAnalyzer.CSharp" Version="7.14.0.8411" />
<PackageReference Update="SpecFlow.Tools.MsBuild.Generation" Version="3.0.213" />
<PackageReference Update="SpecFlow.xUnit" version="3.0.213" />
<PackageReference Update="SonarAnalyzer.CSharp" Version="8.10.0.19839" />
<PackageReference Update="SpecFlow.Tools.MsBuild.Generation" Version="3.3.74" />
<PackageReference Update="SpecFlow.xUnit" version="3.3.74" />
<PackageReference Update="System.ComponentModel.TypeConverter" Version="4.3.0" />
<PackageReference Update="NUnit" Version="3.10.1" />
<PackageReference Update="System.Collections.Immutable" Version="1.5.0" />
Expand Down
3 changes: 2 additions & 1 deletion SonarQube/SolutionBinding.sqconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
"Name": "Lucas Loegel"
},
"ProjectKey": "Tranquire",
"ProjectName": "Tranquire",
"Profiles": {
"CSharp": {
"ProfileKey": "AWLo_hSnX0BbYiea--EJ",
"ProfileTimestamp": "2018-04-21T18:21:41+02:00"
"ProfileTimestamp": "2018-04-21T16:21:41Z"
}
}
}
35 changes: 28 additions & 7 deletions SonarQube/TranquireCSharp.ruleset
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="SonarQube - Tranquire Tranquire-csharp" Description="This rule set was automatically generated from SonarQube.&#xD;&#xA;https://sonarcloud.io/profiles/show?key=AWLo_hSnX0BbYiea--EJ" ToolsVersion="15.0">
<RuleSet Name="SonarQube - Tranquire Tranquire-csharp" Description="This rule set was automatically generated from SonarQube.&#xD;&#xA;https://sonarcloud.io/profiles/show?key=AWLo_hSnX0BbYiea--EJ" ToolsVersion="16.0">
<Rules AnalyzerId="SonarAnalyzer.CSharp" RuleNamespace="SonarAnalyzer.CSharp">
<Rule Id="S100" Action="None" />
<Rule Id="S1006" Action="Warning" />
Expand All @@ -26,6 +26,7 @@
<Rule Id="S1121" Action="Warning" />
<Rule Id="S1123" Action="Warning" />
<Rule Id="S1125" Action="Warning" />
<Rule Id="S1128" Action="None" />
<Rule Id="S113" Action="None" />
<Rule Id="S1134" Action="Warning" />
<Rule Id="S1135" Action="Warning" />
Expand All @@ -40,6 +41,7 @@
<Rule Id="S1185" Action="Warning" />
<Rule Id="S1186" Action="Warning" />
<Rule Id="S1192" Action="None" />
<Rule Id="S1199" Action="None" />
<Rule Id="S1200" Action="None" />
<Rule Id="S1206" Action="Warning" />
<Rule Id="S121" Action="None" />
Expand All @@ -64,7 +66,6 @@
<Rule Id="S1451" Action="None" />
<Rule Id="S1479" Action="Warning" />
<Rule Id="S1481" Action="Warning" />
<Rule Id="S1523" Action="None" />
<Rule Id="S1541" Action="None" />
<Rule Id="S1607" Action="Warning" />
<Rule Id="S1643" Action="Warning" />
Expand Down Expand Up @@ -110,6 +111,8 @@
<Rule Id="S2228" Action="None" />
<Rule Id="S2234" Action="Warning" />
<Rule Id="S2245" Action="None" />
<Rule Id="S2251" Action="None" />
<Rule Id="S2252" Action="None" />
<Rule Id="S2255" Action="None" />
<Rule Id="S2259" Action="Warning" />
<Rule Id="S2275" Action="Warning" />
Expand Down Expand Up @@ -140,6 +143,7 @@
<Rule Id="S2387" Action="None" />
<Rule Id="S2436" Action="None" />
<Rule Id="S2437" Action="Warning" />
<Rule Id="S2479" Action="None" />
<Rule Id="S2486" Action="Warning" />
<Rule Id="S2551" Action="None" />
<Rule Id="S2583" Action="Warning" />
Expand All @@ -153,10 +157,12 @@
<Rule Id="S2701" Action="None" />
<Rule Id="S2737" Action="Warning" />
<Rule Id="S2743" Action="Warning" />
<Rule Id="S2755" Action="None" />
<Rule Id="S2757" Action="Warning" />
<Rule Id="S2758" Action="Warning" />
<Rule Id="S2760" Action="None" />
<Rule Id="S2761" Action="Warning" />
<Rule Id="S2857" Action="None" />
<Rule Id="S2930" Action="Warning" />
<Rule Id="S2931" Action="None" />
<Rule Id="S2933" Action="Warning" />
Expand Down Expand Up @@ -272,6 +278,7 @@
<Rule Id="S3927" Action="Warning" />
<Rule Id="S3928" Action="Warning" />
<Rule Id="S3937" Action="None" />
<Rule Id="S3949" Action="None" />
<Rule Id="S3956" Action="None" />
<Rule Id="S3962" Action="None" />
<Rule Id="S3963" Action="None" />
Expand Down Expand Up @@ -321,12 +328,14 @@
<Rule Id="S4061" Action="None" />
<Rule Id="S4069" Action="None" />
<Rule Id="S4070" Action="None" />
<Rule Id="S4136" Action="None" />
<Rule Id="S4142" Action="None" />
<Rule Id="S4143" Action="None" />
<Rule Id="S4144" Action="Warning" />
<Rule Id="S4158" Action="Warning" />
<Rule Id="S4159" Action="Warning" />
<Rule Id="S4200" Action="Warning" />
<Rule Id="S4201" Action="None" />
<Rule Id="S4210" Action="Warning" />
<Rule Id="S4211" Action="None" />
<Rule Id="S4212" Action="None" />
Expand All @@ -345,24 +354,30 @@
<Rule Id="S4456" Action="None" />
<Rule Id="S4457" Action="None" />
<Rule Id="S4462" Action="None" />
<Rule Id="S4487" Action="None" />
<Rule Id="S4507" Action="None" />
<Rule Id="S4524" Action="None" />
<Rule Id="S4529" Action="None" />
<Rule Id="S4564" Action="None" />
<Rule Id="S4581" Action="None" />
<Rule Id="S4583" Action="None" />
<Rule Id="S4586" Action="None" />
<Rule Id="S4721" Action="None" />
<Rule Id="S4635" Action="None" />
<Rule Id="S4784" Action="None" />
<Rule Id="S4787" Action="None" />
<Rule Id="S4790" Action="None" />
<Rule Id="S4792" Action="None" />
<Rule Id="S4797" Action="None" />
<Rule Id="S4817" Action="None" />
<Rule Id="S4818" Action="None" />
<Rule Id="S4823" Action="None" />
<Rule Id="S4825" Action="None" />
<Rule Id="S4829" Action="None" />
<Rule Id="S4830" Action="None" />
<Rule Id="S4834" Action="None" />
<Rule Id="S5034" Action="None" />
<Rule Id="S5042" Action="None" />
<Rule Id="S5542" Action="None" />
<Rule Id="S5547" Action="None" />
<Rule Id="S5659" Action="None" />
<Rule Id="S5766" Action="None" />
<Rule Id="S5773" Action="None" />
<Rule Id="S818" Action="Warning" />
<Rule Id="S881" Action="None" />
<Rule Id="S907" Action="Warning" />
Expand All @@ -375,5 +390,11 @@
<Rule Id="S2091" Action="None" />
<Rule Id="S2631" Action="None" />
<Rule Id="S3649" Action="Warning" />
<Rule Id="S5131" Action="None" />
<Rule Id="S5135" Action="None" />
<Rule Id="S5144" Action="None" />
<Rule Id="S5145" Action="None" />
<Rule Id="S5146" Action="None" />
<Rule Id="S5167" Action="None" />
</Rules>
</RuleSet>
6 changes: 6 additions & 0 deletions Tranquire.sln
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{C8E46BAC
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ToDoList", "src\ToDoList\ToDoList.csproj", "{3EDE9B40-FF91-4B41-8C02-ABBAED729D73}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Benchmarks", "tests\Benchmarks\Benchmarks.csproj", "{802EF1DB-7AA6-4AEA-BBB4-2B83281558AD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -93,6 +95,10 @@ Global
{3EDE9B40-FF91-4B41-8C02-ABBAED729D73}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3EDE9B40-FF91-4B41-8C02-ABBAED729D73}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3EDE9B40-FF91-4B41-8C02-ABBAED729D73}.Release|Any CPU.Build.0 = Release|Any CPU
{802EF1DB-7AA6-4AEA-BBB4-2B83281558AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{802EF1DB-7AA6-4AEA-BBB4-2B83281558AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{802EF1DB-7AA6-4AEA-BBB4-2B83281558AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{802EF1DB-7AA6-4AEA-BBB4-2B83281558AD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
14 changes: 5 additions & 9 deletions src/Tranquire.Selenium/ActorExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,11 @@ public static Actor TakeScreenshots(

var id = 0;

string screenshotFormat;
if (string.Format(screenshotNameOrFormat, 1) == screenshotNameOrFormat)
{
screenshotFormat = screenshotNameOrFormat + "_" + "{0:00}";
}
else
{
screenshotFormat = screenshotNameOrFormat;
}
#pragma warning disable S1854 // Unused assignments should be removed. False positive
var screenshotFormat = string.Format(screenshotNameOrFormat, 1) == screenshotNameOrFormat
#pragma warning restore S1854 // Unused assignments should be removed
? screenshotNameOrFormat + "_" + "{0:00}"
: screenshotNameOrFormat;

string nextScreenshotName()
{
Expand Down
9 changes: 8 additions & 1 deletion src/Tranquire.Selenium/Questions/UIModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,14 @@ private static Func<IActor, ITarget, CultureInfo, object> RetrieveValue(Property
private static readonly IntegerArrayConverters _integerArrayConverters = new IntegerArrayConverters();
private static readonly DoubleArrayConverters _doubleArrayConverters = new DoubleArrayConverters();

private static Func<IActor, ITarget, CultureInfo, object> ApplyGetConverter(ITarget target, Type type, UIStateAttribute uiStateAttribute)
private static Func<IActor, ITarget, CultureInfo, object> ApplyGetConverter(
#pragma warning disable S1172 // Unused method parameters should be removed. False positive
ITarget target,
#pragma warning restore S1172 // Unused method parameters should be removed
Type type,
#pragma warning disable S1172 // Unused method parameters should be removed. False positive
UIStateAttribute uiStateAttribute)
#pragma warning restore S1172 // Unused method parameters should be removed
{
if (type == typeof(int))
{
Expand Down
6 changes: 5 additions & 1 deletion src/Tranquire/ActionTags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ public TTag FindBestGivenTag(IEnumerable<TTag> tags)
return GetBestTag(GivenTags, tags);
}

private TTag GetBestTag(ImmutableDictionary<TTag, int> orderedTags, IEnumerable<TTag> tags)
private TTag GetBestTag(
#pragma warning disable S1172 // Unused method parameters should be removed. False positive
ImmutableDictionary<TTag, int> orderedTags,
#pragma warning restore S1172 // Unused method parameters should be removed
IEnumerable<TTag> tags)
{
if (tags == null)
{
Expand Down
14 changes: 0 additions & 14 deletions src/Tranquire/IThenAction.cs

This file was deleted.

2 changes: 1 addition & 1 deletion src/Tranquire/Reporting/ActionNotification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/// <summary>
/// Represent informations about the action execution
/// </summary>
public class ActionNotification
public struct ActionNotification
{
/// <summary>
/// The action that trigerred the notification
Expand Down
84 changes: 84 additions & 0 deletions src/Tranquire/Reporting/INotificationContentFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Tranquire.Reporting
{
internal interface INotificationContentFactory
{
IActionNotificationContent CreateBefore<T>(INamed action, DateTimeOffset date, CommandType commandType);
IActionNotificationContent CreateAfter(TimeSpan time);
IActionNotificationContent CreateError(Exception error, TimeSpan time);
}

internal class ThenNotificationContentFactory : INotificationContentFactory
{
public IActionNotificationContent CreateAfter(TimeSpan time)
{
return new AfterThenNotificationContent(time, ThenOutcome.Pass);
}

public IActionNotificationContent CreateBefore<T>(INamed action, DateTimeOffset date, CommandType commandType)
{
return new BeforeThenNotificationContent(date, (action as ThenAction<T>).Question);
}

public IActionNotificationContent CreateError(Exception error, TimeSpan time)
{
return new AfterThenNotificationContent(time, GetOutcome(error), error);
}

private static ThenOutcome GetOutcome(Exception error)
{
if (_knownNamespaces.Any(error.GetType().FullName.StartsWith))
{
return ThenOutcome.Failed;
}
return ThenOutcome.Error;
}

private static readonly string[] _knownNamespaces = new[]
{
"Xunit.Sdk.",
"NUnit.Framework.",
"Microsoft.VisualStudio.TestTools.UnitTesting."
};
}

internal class CommandNotificationContentfactory : INotificationContentFactory
{
public IActionNotificationContent CreateAfter(TimeSpan time)
{
return new AfterActionNotificationContent(time);
}

public IActionNotificationContent CreateBefore<T>(INamed action, DateTimeOffset date, CommandType commandType)
{
return new BeforeFirstActionNotificationContent(date, (action as CommandAction<T>).ActionContext);
}

public IActionNotificationContent CreateError(Exception error, TimeSpan time)
{
return new ExecutionErrorNotificationContent(error, time);
}
}

internal class DefaultNotificationContentFactory : INotificationContentFactory
{
public IActionNotificationContent CreateAfter(TimeSpan time)
{
return new AfterActionNotificationContent(time);
}

public IActionNotificationContent CreateBefore<T>(INamed action, DateTimeOffset date, CommandType commandType)
{
return new BeforeActionNotificationContent(date, commandType);
}

public IActionNotificationContent CreateError(Exception error, TimeSpan time)
{
return new ExecutionErrorNotificationContent(error, time);
}
}
}
9 changes: 2 additions & 7 deletions src/Tranquire/Reporting/RenderedReportingObserver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ public void OnError(Exception error)
/// <inheritsdoc />
public void OnNext(ActionNotification value)
{
if (value == null)
{
throw new ArgumentNullException(nameof(value));
}

Observer.OnNext(Renderer(value));
}

Expand All @@ -67,9 +62,9 @@ public void OnNext(ActionNotification value)
/// <returns></returns>
public static string DefaultRenderer(ActionNotification notification)
{
if (notification == null)
if (notification.Content == null)
{
throw new ArgumentNullException(nameof(notification));
return "Unknown action";
}

switch (notification.Content.NotificationContentType)
Expand Down
Loading