From b42b400fc2b3039fda3766b2832274ae4ce035ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20P=C4=99kala?= Date: Wed, 4 Nov 2020 23:31:35 +0100 Subject: [PATCH 1/6] Create codeql-analysis.yml --- .github/workflows/codeql-analysis.yml | 68 +++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 .github/workflows/codeql-analysis.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000..cebc177 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,68 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# ******** NOTE ******** + +name: "CodeQL" + +on: + push: + branches: [ master ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ master ] + schedule: + - cron: '15 20 * * 4' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + language: [ 'csharp', 'javascript' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] + # Learn more... + # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + # ℹ️ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 From 34b952d40c31e8edfb34eda2a2d30073cf19ef1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20P=C4=99kala?= Date: Sun, 8 Nov 2020 19:38:20 +0100 Subject: [PATCH 2/6] Revert "Create codeql-analysis.yml" This reverts commit b42b400fc2b3039fda3766b2832274ae4ce035ce. --- .github/workflows/codeql-analysis.yml | 68 --------------------------- 1 file changed, 68 deletions(-) delete mode 100644 .github/workflows/codeql-analysis.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index cebc177..0000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,68 +0,0 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# ******** NOTE ******** - -name: "CodeQL" - -on: - push: - branches: [ master ] - pull_request: - # The branches below must be a subset of the branches above - branches: [ master ] - schedule: - - cron: '15 20 * * 4' - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - language: [ 'csharp', 'javascript' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] - # Learn more... - # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v1 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - # queries: ./path/to/local/query, your-org/your-repo/queries@main - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v1 - - # ℹ️ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl - - # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language - - #- run: | - # make bootstrap - # make release - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 From 06fab908a7a8c6edf3d15e29db6661da8c78c0e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20P=C4=99kala?= Date: Sun, 8 Nov 2020 19:28:53 +0100 Subject: [PATCH 3/6] Minor code readability fixes and improvements --- Src/Dashboard/Mvc/PageElementsIds.cs | 2 +- Src/Dashboard/Mvc/Utils/ServiceLocator.cs | 2 +- Src/Dashboard/Program.cs | 3 +-- Src/MvcPages/BrowserCamera/Lens/BrowserCameraLensFactory.cs | 1 + Src/MvcPages/BrowserCamera/Lens/ZoomableLens.cs | 2 +- .../EndpointCoverage/EndpointCoverageReportBuilderFactory.cs | 2 +- .../EndpointExplorers/AspMvcEndpointExplorer.cs | 2 +- .../EndpointExplorers/CompositeEndpointExplorer.cs | 2 +- .../EndpointExplorers/ExplicitEndpointExplorer.cs | 2 +- Src/Sample.Website/App_Start/FilterConfig.cs | 2 +- Src/Sample.Website/App_Start/RouteConfig.cs | 2 +- Src/VisualAssertions/Infrastructure/IQueryAll.cs | 2 +- Src/VisualAssertions/Screenshots/Domain/BlindRegion.cs | 1 - .../Screenshots/Service/VisualAssertionsService.cs | 2 ++ .../Screenshots/Utils/TaskProcessing/ITaskProcessor.cs | 2 +- .../Screenshots/Utils/TaskProcessing/TaskProcessorFactory.cs | 2 +- 16 files changed, 16 insertions(+), 15 deletions(-) diff --git a/Src/Dashboard/Mvc/PageElementsIds.cs b/Src/Dashboard/Mvc/PageElementsIds.cs index 36ad6f4..1554973 100644 --- a/Src/Dashboard/Mvc/PageElementsIds.cs +++ b/Src/Dashboard/Mvc/PageElementsIds.cs @@ -1,6 +1,6 @@ namespace Tellurium.VisualAssertion.Dashboard.Mvc { - public class PageElementsIds + public static class PageElementsIds { public const string PageBody = "PageBody"; } diff --git a/Src/Dashboard/Mvc/Utils/ServiceLocator.cs b/Src/Dashboard/Mvc/Utils/ServiceLocator.cs index e034276..2dee1db 100644 --- a/Src/Dashboard/Mvc/Utils/ServiceLocator.cs +++ b/Src/Dashboard/Mvc/Utils/ServiceLocator.cs @@ -2,7 +2,7 @@ namespace Tellurium.VisualAssertion.Dashboard.Mvc.Utils { - public class ServiceLocator + public static class ServiceLocator { private static IWindsorContainer _container; diff --git a/Src/Dashboard/Program.cs b/Src/Dashboard/Program.cs index 3c11b4e..1e66a45 100644 --- a/Src/Dashboard/Program.cs +++ b/Src/Dashboard/Program.cs @@ -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) { diff --git a/Src/MvcPages/BrowserCamera/Lens/BrowserCameraLensFactory.cs b/Src/MvcPages/BrowserCamera/Lens/BrowserCameraLensFactory.cs index c3e1ee8..9162bbe 100644 --- a/Src/MvcPages/BrowserCamera/Lens/BrowserCameraLensFactory.cs +++ b/Src/MvcPages/BrowserCamera/Lens/BrowserCameraLensFactory.cs @@ -38,6 +38,7 @@ public static IBrowserCameraLens CreateLensForAutoMode(RemoteWebDriver webDriver { return new ResizeableLens(webDriver); } + return new RegularLens(webDriver); } diff --git a/Src/MvcPages/BrowserCamera/Lens/ZoomableLens.cs b/Src/MvcPages/BrowserCamera/Lens/ZoomableLens.cs index 1b6d542..bf79038 100644 --- a/Src/MvcPages/BrowserCamera/Lens/ZoomableLens.cs +++ b/Src/MvcPages/BrowserCamera/Lens/ZoomableLens.cs @@ -3,7 +3,7 @@ namespace Tellurium.MvcPages.BrowserCamera.Lens { - public class ZoomableLens:IBrowserCameraLens + public class ZoomableLens : IBrowserCameraLens { private readonly RemoteWebDriver driver; diff --git a/Src/MvcPages/EndpointCoverage/EndpointCoverageReportBuilderFactory.cs b/Src/MvcPages/EndpointCoverage/EndpointCoverageReportBuilderFactory.cs index b6c0640..8bbe826 100644 --- a/Src/MvcPages/EndpointCoverage/EndpointCoverageReportBuilderFactory.cs +++ b/Src/MvcPages/EndpointCoverage/EndpointCoverageReportBuilderFactory.cs @@ -3,7 +3,7 @@ namespace Tellurium.MvcPages.EndpointCoverage { - public class EndpointCoverageReportBuilderFactory + public static class EndpointCoverageReportBuilderFactory { public static EndpointCoverageReportBuilder Create(BrowserAdapterConfig config, IEndpointCollector endpointCollector) { diff --git a/Src/MvcPages/EndpointCoverage/EndpointExplorers/AspMvcEndpointExplorer.cs b/Src/MvcPages/EndpointCoverage/EndpointExplorers/AspMvcEndpointExplorer.cs index 607d489..2a5384e 100644 --- a/Src/MvcPages/EndpointCoverage/EndpointExplorers/AspMvcEndpointExplorer.cs +++ b/Src/MvcPages/EndpointCoverage/EndpointExplorers/AspMvcEndpointExplorer.cs @@ -48,7 +48,7 @@ static IReadOnlyList 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) diff --git a/Src/MvcPages/EndpointCoverage/EndpointExplorers/CompositeEndpointExplorer.cs b/Src/MvcPages/EndpointCoverage/EndpointExplorers/CompositeEndpointExplorer.cs index da7b859..bfb505e 100644 --- a/Src/MvcPages/EndpointCoverage/EndpointExplorers/CompositeEndpointExplorer.cs +++ b/Src/MvcPages/EndpointCoverage/EndpointExplorers/CompositeEndpointExplorer.cs @@ -2,7 +2,7 @@ namespace Tellurium.MvcPages.EndpointCoverage.EndpointExplorers { - public class CompositeEndpointExplorer:IEndpointExplorer + public class CompositeEndpointExplorer : IEndpointExplorer { private readonly IEndpointExplorer[] endpointsExplorers; diff --git a/Src/MvcPages/EndpointCoverage/EndpointExplorers/ExplicitEndpointExplorer.cs b/Src/MvcPages/EndpointCoverage/EndpointExplorers/ExplicitEndpointExplorer.cs index 4bcff3d..c9c3742 100644 --- a/Src/MvcPages/EndpointCoverage/EndpointExplorers/ExplicitEndpointExplorer.cs +++ b/Src/MvcPages/EndpointCoverage/EndpointExplorers/ExplicitEndpointExplorer.cs @@ -2,7 +2,7 @@ namespace Tellurium.MvcPages.EndpointCoverage.EndpointExplorers { - public class ExplicitEndpointExplorer:IEndpointExplorer + public class ExplicitEndpointExplorer : IEndpointExplorer { private readonly IReadOnlyList knownEndpoints; diff --git a/Src/Sample.Website/App_Start/FilterConfig.cs b/Src/Sample.Website/App_Start/FilterConfig.cs index 4cbc04f..c2c0105 100644 --- a/Src/Sample.Website/App_Start/FilterConfig.cs +++ b/Src/Sample.Website/App_Start/FilterConfig.cs @@ -2,7 +2,7 @@ namespace Tellurium.Sample.Website { - public class FilterConfig + public static class FilterConfig { public static void RegisterGlobalFilters(GlobalFilterCollection filters) { diff --git a/Src/Sample.Website/App_Start/RouteConfig.cs b/Src/Sample.Website/App_Start/RouteConfig.cs index 8f82466..33d5708 100644 --- a/Src/Sample.Website/App_Start/RouteConfig.cs +++ b/Src/Sample.Website/App_Start/RouteConfig.cs @@ -3,7 +3,7 @@ namespace Tellurium.Sample.Website { - public class RouteConfig + public static class RouteConfig { public static void RegisterRoutes(RouteCollection routes) { diff --git a/Src/VisualAssertions/Infrastructure/IQueryAll.cs b/Src/VisualAssertions/Infrastructure/IQueryAll.cs index 86066fe..c2b0dcf 100644 --- a/Src/VisualAssertions/Infrastructure/IQueryAll.cs +++ b/Src/VisualAssertions/Infrastructure/IQueryAll.cs @@ -3,7 +3,7 @@ namespace Tellurium.VisualAssertions.Infrastructure { - public interface IQueryAll where TEntity:Entity + public interface IQueryAll where TEntity : Entity { List GetQuery(IQueryable query); } diff --git a/Src/VisualAssertions/Screenshots/Domain/BlindRegion.cs b/Src/VisualAssertions/Screenshots/Domain/BlindRegion.cs index cad2def..c8d5161 100644 --- a/Src/VisualAssertions/Screenshots/Domain/BlindRegion.cs +++ b/Src/VisualAssertions/Screenshots/Domain/BlindRegion.cs @@ -1,4 +1,3 @@ -using Tellurium.MvcPages.BrowserCamera; using Tellurium.VisualAssertions.Infrastructure; namespace Tellurium.VisualAssertions.Screenshots.Domain diff --git a/Src/VisualAssertions/Screenshots/Service/VisualAssertionsService.cs b/Src/VisualAssertions/Screenshots/Service/VisualAssertionsService.cs index 5c7687b..dcddc5a 100644 --- a/Src/VisualAssertions/Screenshots/Service/VisualAssertionsService.cs +++ b/Src/VisualAssertions/Screenshots/Service/VisualAssertionsService.cs @@ -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 diff --git a/Src/VisualAssertions/Screenshots/Utils/TaskProcessing/ITaskProcessor.cs b/Src/VisualAssertions/Screenshots/Utils/TaskProcessing/ITaskProcessor.cs index 6bd9b21..193f573 100644 --- a/Src/VisualAssertions/Screenshots/Utils/TaskProcessing/ITaskProcessor.cs +++ b/Src/VisualAssertions/Screenshots/Utils/TaskProcessing/ITaskProcessor.cs @@ -2,7 +2,7 @@ namespace Tellurium.VisualAssertions.Screenshots.Utils.TaskProcessing { - public interface ITaskProcessor: IDisposable + public interface ITaskProcessor : IDisposable { void Post(T data); } diff --git a/Src/VisualAssertions/Screenshots/Utils/TaskProcessing/TaskProcessorFactory.cs b/Src/VisualAssertions/Screenshots/Utils/TaskProcessing/TaskProcessorFactory.cs index 308157a..f1e1d3c 100644 --- a/Src/VisualAssertions/Screenshots/Utils/TaskProcessing/TaskProcessorFactory.cs +++ b/Src/VisualAssertions/Screenshots/Utils/TaskProcessing/TaskProcessorFactory.cs @@ -20,7 +20,7 @@ public static ITaskProcessor Create(TaskProcessorType processorType, Actio enum TaskProcessorType { - Sync=1, + Sync = 1, Async } } \ No newline at end of file From a60d96240919a4ed35d32b2ddd181276ab49d98b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20P=C4=99kala?= Date: Sun, 8 Nov 2020 19:33:49 +0100 Subject: [PATCH 4/6] string.Equals is faster than comparison with ToLower() --- Src/MvcPages/Utils/Timeouts.cs | 8 +------- .../DefaultInputAdapters/SelectFormInputAdapter.cs | 2 +- .../WebForms/DefaultInputAdapters/TextFormInputAdapter.cs | 2 +- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/Src/MvcPages/Utils/Timeouts.cs b/Src/MvcPages/Utils/Timeouts.cs index 620f326..c2827e3 100644 --- a/Src/MvcPages/Utils/Timeouts.cs +++ b/Src/MvcPages/Utils/Timeouts.cs @@ -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 { diff --git a/Src/MvcPages/WebPages/WebForms/DefaultInputAdapters/SelectFormInputAdapter.cs b/Src/MvcPages/WebPages/WebForms/DefaultInputAdapters/SelectFormInputAdapter.cs index ccdc976..0cbe2f4 100644 --- a/Src/MvcPages/WebPages/WebForms/DefaultInputAdapters/SelectFormInputAdapter.cs +++ b/Src/MvcPages/WebPages/WebForms/DefaultInputAdapters/SelectFormInputAdapter.cs @@ -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) diff --git a/Src/MvcPages/WebPages/WebForms/DefaultInputAdapters/TextFormInputAdapter.cs b/Src/MvcPages/WebPages/WebForms/DefaultInputAdapters/TextFormInputAdapter.cs index 57721e6..3b15b7f 100644 --- a/Src/MvcPages/WebPages/WebForms/DefaultInputAdapters/TextFormInputAdapter.cs +++ b/Src/MvcPages/WebPages/WebForms/DefaultInputAdapters/TextFormInputAdapter.cs @@ -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; } From b3e54e6f25d25016277ce66db54c6cb5d06e9773 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20P=C4=99kala?= Date: Sun, 8 Nov 2020 20:13:30 +0100 Subject: [PATCH 5/6] Recommended changes by ApiPortAnalysis tool --- Src/Dashboard/Mvc/HtmlExtensions.cs | 4 ++-- .../AspMvcEndpointExplorer.cs | 19 +++++++++++++------ .../TelluriumErrorReportBuilderFactory.cs | 3 ++- .../FileUploading/FileUploadingExtensions.cs | 8 ++++---- .../Providers/TeamCityRunnerAdapter.cs | 2 +- 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/Src/Dashboard/Mvc/HtmlExtensions.cs b/Src/Dashboard/Mvc/HtmlExtensions.cs index c0a7f3f..18b2f41 100644 --- a/Src/Dashboard/Mvc/HtmlExtensions.cs +++ b/Src/Dashboard/Mvc/HtmlExtensions.cs @@ -21,8 +21,8 @@ public static string ActionFor(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] diff --git a/Src/MvcPages/EndpointCoverage/EndpointExplorers/AspMvcEndpointExplorer.cs b/Src/MvcPages/EndpointCoverage/EndpointExplorers/AspMvcEndpointExplorer.cs index 2a5384e..b53f7c4 100644 --- a/Src/MvcPages/EndpointCoverage/EndpointExplorers/AspMvcEndpointExplorer.cs +++ b/Src/MvcPages/EndpointCoverage/EndpointExplorers/AspMvcEndpointExplorer.cs @@ -6,10 +6,10 @@ namespace Tellurium.MvcPages.EndpointCoverage.EndpointExplorers { - public class AspMvcEndpointExplorer:IEndpointExplorer + public class AspMvcEndpointExplorer : IEndpointExplorer { private readonly IReadOnlyList availableEndpointsAssemblies; - + public AspMvcEndpointExplorer(IReadOnlyList availableEndpointsAssemblies) { @@ -44,7 +44,7 @@ private static string GetActionUrl(Type controller, MethodInfo action) static IReadOnlyList GetAllControllers(Assembly assembly) { - + return assembly.GetTypes().Where(InheritFromController).ToList(); } @@ -53,16 +53,23 @@ static IReadOnlyList GetAllControllers(Assembly assembly) 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 GetAllActionsUrlForController(Type controller) diff --git a/Src/MvcPages/Reports/ErrorReport/TelluriumErrorReportBuilderFactory.cs b/Src/MvcPages/Reports/ErrorReport/TelluriumErrorReportBuilderFactory.cs index c654265..43e26d9 100644 --- a/Src/MvcPages/Reports/ErrorReport/TelluriumErrorReportBuilderFactory.cs +++ b/Src/MvcPages/Reports/ErrorReport/TelluriumErrorReportBuilderFactory.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using Tellurium.MvcPages.Configuration; namespace Tellurium.MvcPages.Reports.ErrorReport @@ -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); diff --git a/Src/MvcPages/SeleniumUtils/FileUploading/FileUploadingExtensions.cs b/Src/MvcPages/SeleniumUtils/FileUploading/FileUploadingExtensions.cs index 85763fd..842bc8e 100644 --- a/Src/MvcPages/SeleniumUtils/FileUploading/FileUploadingExtensions.cs +++ b/Src/MvcPages/SeleniumUtils/FileUploading/FileUploadingExtensions.cs @@ -66,19 +66,19 @@ private static string ToAbsolutePath(string filePath) { foreach (var rootPath in AppDomain.CurrentDomain.SetupInformation.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}")) { diff --git a/Src/VisualAssertions/TestRunnersAdapters/Providers/TeamCityRunnerAdapter.cs b/Src/VisualAssertions/TestRunnersAdapters/Providers/TeamCityRunnerAdapter.cs index 1ace065..4ac0bf0 100644 --- a/Src/VisualAssertions/TestRunnersAdapters/Providers/TeamCityRunnerAdapter.cs +++ b/Src/VisualAssertions/TestRunnersAdapters/Providers/TeamCityRunnerAdapter.cs @@ -91,7 +91,7 @@ private void UploadReportTabToCI(TestSession session, string browserName) "; - 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; From 3ea1e9c6a1d5067534fb4380d02cb48900448c63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20P=C4=99kala?= Date: Sun, 8 Nov 2020 23:33:30 +0100 Subject: [PATCH 6/6] fix build --- .../SeleniumUtils/FileUploading/FileUploadingExtensions.cs | 6 ++++-- Src/Sample.Website/Sample.Website.csproj | 1 - .../ComparisonStrategies/PixelByPixelComparisonStrategy.cs | 1 - 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Src/MvcPages/SeleniumUtils/FileUploading/FileUploadingExtensions.cs b/Src/MvcPages/SeleniumUtils/FileUploading/FileUploadingExtensions.cs index 842bc8e..d4fc856 100644 --- a/Src/MvcPages/SeleniumUtils/FileUploading/FileUploadingExtensions.cs +++ b/Src/MvcPages/SeleniumUtils/FileUploading/FileUploadingExtensions.cs @@ -62,9 +62,11 @@ 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(System.AppContext.BaseDirectory, rootPath, filePath); if (File.Exists(absolutePath)) diff --git a/Src/Sample.Website/Sample.Website.csproj b/Src/Sample.Website/Sample.Website.csproj index 9af95c0..e9b8bff 100644 --- a/Src/Sample.Website/Sample.Website.csproj +++ b/Src/Sample.Website/Sample.Website.csproj @@ -274,7 +274,6 @@ MinimumRecommendedRules.ruleset - diff --git a/Src/VisualAssertions/Screenshots/Service/ComparisonStrategies/PixelByPixelComparisonStrategy.cs b/Src/VisualAssertions/Screenshots/Service/ComparisonStrategies/PixelByPixelComparisonStrategy.cs index 5a642ce..2f72d64 100644 --- a/Src/VisualAssertions/Screenshots/Service/ComparisonStrategies/PixelByPixelComparisonStrategy.cs +++ b/Src/VisualAssertions/Screenshots/Service/ComparisonStrategies/PixelByPixelComparisonStrategy.cs @@ -133,7 +133,6 @@ private byte GetBitsPerPixel(PixelFormat pixelFormat) break; default: throw new ArgumentException("Only 24 and 32 bit images are supported"); - } } }