Skip to content
This repository has been archived by the owner on Sep 1, 2022. It is now read-only.

Feature/fix automated builds modernize code as part of portability to newer net versions #73

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
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
4 changes: 2 additions & 2 deletions Src/Dashboard/Mvc/HtmlExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public static string ActionFor<TController>(this IUrlHelper urlHelper, Expressio

public static HtmlString GetAppVersion()
{
var version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
return new HtmlString(version);
var version = typeof(HtmlExtensions).GetTypeInfo().Assembly.GetName().Version.ToString();
return new HtmlString(version);
}

[Pure]
Expand Down
2 changes: 1 addition & 1 deletion Src/Dashboard/Mvc/PageElementsIds.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Tellurium.VisualAssertion.Dashboard.Mvc
{
public class PageElementsIds
public static class PageElementsIds
{
public const string PageBody = "PageBody";
}
Expand Down
2 changes: 1 addition & 1 deletion Src/Dashboard/Mvc/Utils/ServiceLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Tellurium.VisualAssertion.Dashboard.Mvc.Utils
{
public class ServiceLocator
public static class ServiceLocator
{
private static IWindsorContainer _container;

Expand Down
3 changes: 1 addition & 2 deletions Src/Dashboard/Program.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Threading;
using Topshelf;

namespace Tellurium.VisualAssertion.Dashboard
{
public class Program
public static class Program
{
public static void Main(string[] args)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public static IBrowserCameraLens CreateLensForAutoMode(RemoteWebDriver webDriver
{
return new ResizeableLens(webDriver);
}

return new RegularLens(webDriver);
}

Expand Down
2 changes: 1 addition & 1 deletion Src/MvcPages/BrowserCamera/Lens/ZoomableLens.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Tellurium.MvcPages.BrowserCamera.Lens
{
public class ZoomableLens:IBrowserCameraLens
public class ZoomableLens : IBrowserCameraLens
{
private readonly RemoteWebDriver driver;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Tellurium.MvcPages.EndpointCoverage
{
public class EndpointCoverageReportBuilderFactory
public static class EndpointCoverageReportBuilderFactory
{
public static EndpointCoverageReportBuilder Create(BrowserAdapterConfig config, IEndpointCollector endpointCollector)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

namespace Tellurium.MvcPages.EndpointCoverage.EndpointExplorers
{
public class AspMvcEndpointExplorer:IEndpointExplorer
public class AspMvcEndpointExplorer : IEndpointExplorer
{
private readonly IReadOnlyList<Assembly> availableEndpointsAssemblies;


public AspMvcEndpointExplorer(IReadOnlyList<Assembly> availableEndpointsAssemblies)
{
Expand Down Expand Up @@ -44,25 +44,32 @@ private static string GetActionUrl(Type controller, MethodInfo action)

static IReadOnlyList<Type> GetAllControllers(Assembly assembly)
{

return assembly.GetTypes().Where(InheritFromController).ToList();
}

const string AspControllerNamespace = "System.Web.Mvc.Controller";
private const string AspControllerNamespace = "System.Web.Mvc.Controller";
private const string AspCoreControllerNamespace = "Microsoft.AspNetCore.Mvc";

private static bool InheritFromController(Type t)
{
if (t == typeof(object) || t.BaseType == null)
if (t == typeof(object))
{
return false;
}

var baseType = t.GetTypeInfo().BaseType;

if (baseType == null)
{
return false;
}

if (t.BaseType.Namespace == AspControllerNamespace || t.BaseType.Namespace == AspCoreControllerNamespace)
if (baseType.Namespace == AspControllerNamespace || baseType.Namespace == AspCoreControllerNamespace)
{
return true;
}
return InheritFromController(t.BaseType);
return InheritFromController(baseType);
}

private static IReadOnlyList<string> GetAllActionsUrlForController(Type controller)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Tellurium.MvcPages.EndpointCoverage.EndpointExplorers
{
public class CompositeEndpointExplorer:IEndpointExplorer
public class CompositeEndpointExplorer : IEndpointExplorer
{
private readonly IEndpointExplorer[] endpointsExplorers;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Tellurium.MvcPages.EndpointCoverage.EndpointExplorers
{
public class ExplicitEndpointExplorer:IEndpointExplorer
public class ExplicitEndpointExplorer : IEndpointExplorer
{
private readonly IReadOnlyList<string> knownEndpoints;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.IO;
using Tellurium.MvcPages.Configuration;

namespace Tellurium.MvcPages.Reports.ErrorReport
Expand All @@ -9,7 +10,7 @@ public static TelluriumErrorReportBuilder Create(BrowserAdapterConfig config)
{
var writeOutput = config.WriteOutput ?? Console.WriteLine;
var outputDir = string.IsNullOrWhiteSpace(config.ErrorReportOutputDir)
? Environment.CurrentDirectory
? Directory.GetCurrentDirectory()
: config.ErrorReportOutputDir;
var ciAdapter = new TeamCityAdapter(writeOutput);
return new TelluriumErrorReportBuilder(outputDir, writeOutput, ciAdapter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,25 @@ private static string MapToAbsoluteFilePath(string filePath)

private static string ToAbsolutePath(string filePath)
{
if (AppDomain.CurrentDomain.SetupInformation.PrivateBinPath != null)
// TODO: This needs to be reworked if we want to target .NET Core (however it will work on .NET 5.0)
string privateBinPath = AppDomain.CurrentDomain.SetupInformation.PrivateBinPath;
if (privateBinPath != null)
{
foreach (var rootPath in AppDomain.CurrentDomain.SetupInformation.PrivateBinPath.Split(';'))
foreach (var rootPath in privateBinPath.Split(';'))
{
var absolutePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, rootPath, filePath);
var absolutePath = Path.Combine(System.AppContext.BaseDirectory, rootPath, filePath);
if (File.Exists(absolutePath))
{
return absolutePath;
}
}
}
return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, filePath);
return Path.Combine(System.AppContext.BaseDirectory, filePath);
}

private static string ReadFileContentFromEmbededResource(string fileName)
private static string ReadFileContentFromEmbeddedResource(string fileName)
{
var assembly = Assembly.GetExecutingAssembly();
var assembly = typeof(FileUploadingExtensions).GetTypeInfo().Assembly;
var currentNamespace = typeof(FileUploadingExtensions).Namespace;
using (Stream stream = assembly.GetManifestResourceStream($"{currentNamespace}.{fileName}"))
{
Expand Down
8 changes: 1 addition & 7 deletions Src/MvcPages/Utils/Timeouts.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tellurium.MvcPages.Utils
namespace Tellurium.MvcPages.Utils
{
public static class Timeouts
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class SelectFormInputAdapter : IFormInputAdapter

public bool CanHandle(IWebElement webElement)
{
return webElement.TagName.ToLower() == "select";
return string.Equals(webElement.TagName, "select", System.StringComparison.OrdinalIgnoreCase);
}

public void SetValue(IWebElement webElement, string value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class TextFormInputAdapter : IFormInputAdapter
{
public bool CanHandle(IWebElement webElement)
{
if (webElement.TagName.ToLower() == "textarea")
if (string.Equals(webElement.TagName, "textarea", System.StringComparison.OrdinalIgnoreCase))
{
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion Src/Sample.Website/App_Start/FilterConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Tellurium.Sample.Website
{
public class FilterConfig
public static class FilterConfig
{
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
Expand Down
2 changes: 1 addition & 1 deletion Src/Sample.Website/App_Start/RouteConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Tellurium.Sample.Website
{
public class RouteConfig
public static class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
Expand Down
1 change: 0 additions & 1 deletion Src/Sample.Website/Sample.Website.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
<Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
<AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" />
Expand Down
2 changes: 1 addition & 1 deletion Src/VisualAssertions/Infrastructure/IQueryAll.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Tellurium.VisualAssertions.Infrastructure
{
public interface IQueryAll<TEntity> where TEntity:Entity
public interface IQueryAll<TEntity> where TEntity : Entity
{
List<TEntity> GetQuery(IQueryable<TEntity> query);
}
Expand Down
1 change: 0 additions & 1 deletion Src/VisualAssertions/Screenshots/Domain/BlindRegion.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Tellurium.MvcPages.BrowserCamera;
using Tellurium.VisualAssertions.Infrastructure;

namespace Tellurium.VisualAssertions.Screenshots.Domain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ private byte GetBitsPerPixel(PixelFormat pixelFormat)
break;
default:
throw new ArgumentException("Only 24 and 32 bit images are supported");

}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ public VisualAssertionsService(
public void CheckViewWithPattern(IBrowserCamera browserCamera, string viewName)
{
var screenshotIdentity = new ScreenshotIdentity(ProjectName, BrowserName, ScreenshotCategory, viewName);

if (takenScreenshots.Contains(screenshotIdentity))
{
throw new DuplicatedScreenshotInSession(screenshotIdentity);
}

var screenshot = browserCamera.TakeScreenshot();
takenScreenshots.Add(screenshotIdentity);
ScreenshotProcessor.Post(new Screenshot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Tellurium.VisualAssertions.Screenshots.Utils.TaskProcessing
{
public interface ITaskProcessor<T>: IDisposable
public interface ITaskProcessor<T> : IDisposable
{
void Post(T data);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static ITaskProcessor<T> Create<T>(TaskProcessorType processorType, Actio

enum TaskProcessorType
{
Sync=1,
Sync = 1,
Async
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private void UploadReportTabToCI(TestSession session, string browserName)
</script>
</head><body></body>
</html> ";
var fullFilePath = Path.Combine(Environment.CurrentDirectory, "VisualAssertions.html");
var fullFilePath = Path.Combine(Directory.GetCurrentDirectory(), "VisualAssertions.html");
File.WriteAllText(fullFilePath, reportContent);
serviceMessage.PublishArtifact(fullFilePath);
reportUploaded = true;
Expand Down