diff --git a/.github/workflows/Master-CodeQL.yml b/.github/workflows/Master-CodeQL.yml index b5081a6..f64e1d6 100644 --- a/.github/workflows/Master-CodeQL.yml +++ b/.github/workflows/Master-CodeQL.yml @@ -7,70 +7,96 @@ # ******** 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. +# supported CodeQL languages. # name: "master-codeql" on: push: - pull_request: - types: [opened, reopened, edited, synchronize] + branches: [ "master" ] paths-ignore: - "**/*.md" - "**/*.gitignore" - - "**/*.gitattributes" + - "**/*.gitattributes" schedule: - - cron: '35 15 * * 2' + - cron: '42 7 * * 5' jobs: analyze: - name: Analyze - runs-on: ubuntu-latest + name: Analyze (${{ matrix.language }}) + # Runner size impacts CodeQL analysis time. To learn more, please see: + # - https://gh.io/recommended-hardware-resources-for-running-codeql + # - https://gh.io/supported-runners-and-hardware-resources + # - https://gh.io/using-larger-runners (GitHub.com only) + # Consider using larger runners or machines with greater resources for possible analysis time improvements. + runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} permissions: + # required for all workflows + security-events: write + + # required to fetch internal or private CodeQL packs + packages: read + + # only required for workflows in private repositories actions: read contents: read - security-events: write strategy: fail-fast: false matrix: - language: [ 'csharp' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] - # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support - + include: + - language: actions + build-mode: none + - language: csharp + build-mode: none + # CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' + # Use `c-cpp` to analyze code written in C, C++ or both + # Use 'java-kotlin' to analyze code written in Java, Kotlin or both + # Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both + # To learn more about changing the languages that are analyzed or customizing the build mode for your analysis, + # see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning. + # If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how + # your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 + + # Add any setup steps before running the `github/codeql-action/init` action. + # This includes steps like installing compilers or runtimes (`actions/setup-node` + # or others). This is typically only required for manual builds. + # - name: Setup runtime (example) + # uses: actions/setup-example@v1 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} + build-mode: ${{ matrix.build-mode }} # 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. - # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs # queries: security-extended,security-and-quality - - # Autobuild attempts to build any compiled languages (C/C++, C#, Go, 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@v2 - + # If the analyze step fails for one of the languages you are analyzing with + # "We were unable to automatically build your code", modify the matrix above + # to set the build mode to "manual" for that language. Then modify this step + # to build your code. # ℹ️ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - - # If the Autobuild fails above, remove it and uncomment the following three lines. - # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. - - # - run: | - # echo "Run, Build Application using script" - # ./location_of_script_within_repo/buildscript.sh + - if: matrix.build-mode == 'manual' + shell: bash + run: | + echo 'If you are using a "manual" build mode for one or more of the' \ + 'languages you are analyzing, replace this with the commands to build' \ + 'your code, for example:' + echo ' make bootstrap' + echo ' make release' + exit 1 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 with: - category: "/language:${{matrix.language}}" \ No newline at end of file + category: "/language:${{matrix.language}}" diff --git a/.github/workflows/PullRequest-CI.yml b/.github/workflows/PullRequest-CI.yml index 9f76e6c..d6e0377 100644 --- a/.github/workflows/PullRequest-CI.yml +++ b/.github/workflows/PullRequest-CI.yml @@ -13,7 +13,7 @@ jobs: github-token: '${{ secrets.GH_Packages }}' steps: - name: Step-01 Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Step-02 Lint Code Base @@ -39,7 +39,7 @@ jobs: versionSpec: 5.x - name: Step-02 Check out Code - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -73,7 +73,7 @@ jobs: working-directory: '${{ env.working-directory }}' - name: Step-08 Upload Build Artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: build-artifact path: ${{env.working-directory}} @@ -90,7 +90,7 @@ jobs: working-directory: /home/runner/work/ApiAggregator/ApiAggregator steps: - name: Step-01 Retrieve Build Artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: build-artifact path: ${{env.working-directory}} @@ -111,7 +111,7 @@ jobs: working-directory: /home/runner/work/ApiAggregator/ApiAggregator steps: - name: Step-01 Retrieve Build Artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: build-artifact path: ${{env.working-directory}} diff --git a/.github/workflows/PullRequest-CodeQL.yml b/.github/workflows/PullRequest-CodeQL.yml index c3941b2..c8d9975 100644 --- a/.github/workflows/PullRequest-CodeQL.yml +++ b/.github/workflows/PullRequest-CodeQL.yml @@ -18,59 +18,86 @@ on: paths-ignore: - "**/*.md" - "**/*.gitignore" - - "**/*.gitattributes" + - "**/*.gitattributes" schedule: - cron: '35 15 * * 2' jobs: analyze: - name: Analyze - runs-on: ubuntu-latest + name: Analyze (${{ matrix.language }}) + # Runner size impacts CodeQL analysis time. To learn more, please see: + # - https://gh.io/recommended-hardware-resources-for-running-codeql + # - https://gh.io/supported-runners-and-hardware-resources + # - https://gh.io/using-larger-runners (GitHub.com only) + # Consider using larger runners or machines with greater resources for possible analysis time improvements. + runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} permissions: + # required for all workflows + security-events: write + + # required to fetch internal or private CodeQL packs + packages: read + + # only required for workflows in private repositories actions: read contents: read - security-events: write strategy: fail-fast: false matrix: - language: [ 'csharp' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] - # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support - + include: + - language: actions + build-mode: none + - language: csharp + build-mode: none + # CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' + # Use `c-cpp` to analyze code written in C, C++ or both + # Use 'java-kotlin' to analyze code written in Java, Kotlin or both + # Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both + # To learn more about changing the languages that are analyzed or customizing the build mode for your analysis, + # see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning. + # If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how + # your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 + + # Add any setup steps before running the `github/codeql-action/init` action. + # This includes steps like installing compilers or runtimes (`actions/setup-node` + # or others). This is typically only required for manual builds. + # - name: Setup runtime (example) + # uses: actions/setup-example@v1 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} + build-mode: ${{ matrix.build-mode }} # 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. - # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs # queries: security-extended,security-and-quality - - # Autobuild attempts to build any compiled languages (C/C++, C#, Go, 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@v2 - + # If the analyze step fails for one of the languages you are analyzing with + # "We were unable to automatically build your code", modify the matrix above + # to set the build mode to "manual" for that language. Then modify this step + # to build your code. # ℹ️ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - - # If the Autobuild fails above, remove it and uncomment the following three lines. - # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. - - # - run: | - # echo "Run, Build Application using script" - # ./location_of_script_within_repo/buildscript.sh + - if: matrix.build-mode == 'manual' + shell: bash + run: | + echo 'If you are using a "manual" build mode for one or more of the' \ + 'languages you are analyzing, replace this with the commands to build' \ + 'your code, for example:' + echo ' make bootstrap' + echo ' make release' + exit 1 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 with: - category: "/language:${{matrix.language}}" \ No newline at end of file + category: "/language:${{matrix.language}}" diff --git a/GitVersion.yml b/GitVersion.yml index 280505f..82a9b7c 100644 --- a/GitVersion.yml +++ b/GitVersion.yml @@ -1,4 +1,4 @@ -next-version: 2.0.0 +next-version: 2.0.1 tag-prefix: '[vV]' mode: ContinuousDeployment branches: diff --git a/LICENSE b/LICENSE index daf3b65..e3a0025 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2024 Code Shayk +Copyright (c) 2025 Code Shayk Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index a25046e..55d4c97 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# ninja ApiAggregator v2.0.0 +# ninja ApiAggregator v2.0.1 [![NuGet version](https://badge.fury.io/nu/ApiAggregator.svg)](https://badge.fury.io/nu/ApiAggregator) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/CodeShayk/ApiAggregator/blob/master/LICENSE.md) [![Master-Build](https://github.com/CodeShayk/ApiAggregator/actions/workflows/Master-Build.yml/badge.svg)](https://github.com/CodeShayk/ApiAggregator/actions/workflows/Master-Build.yml) [![GitHub Release](https://img.shields.io/github/v/release/CodeShayk/ApiAggregator?logo=github&sort=semver)](https://github.com/CodeShayk/ApiAggregator/releases/latest) diff --git a/src/ApiAggregator/ApiAggregate.cs b/src/ApiAggregator/ApiAggregate.cs index e98dc4c..ca4602a 100644 --- a/src/ApiAggregator/ApiAggregate.cs +++ b/src/ApiAggregator/ApiAggregate.cs @@ -1,3 +1,5 @@ +using System.Collections.Generic; + namespace ApiAggregator { /// diff --git a/src/ApiAggregator/ApiAggregator.csproj b/src/ApiAggregator/ApiAggregator.csproj index 398dbcf..4c85183 100644 --- a/src/ApiAggregator/ApiAggregator.csproj +++ b/src/ApiAggregator/ApiAggregator.csproj @@ -1,9 +1,9 @@ - net9.0 - enable - enable + net462; netstandard2.0;netstandard2.1;net5.0; net6.0; net8.0; net9.0 + disable + disable ApiAggregator CodeShayk CodeShayk @@ -11,7 +11,7 @@ ninja-icon-16.png README.md True - Copyright (c) 2024 Code Shayk + Copyright (c) 2025 Code Shayk api, aggregator, api-aggregator, utility, api-utility, data-aggregator, api-response, api-response-aggregator True @@ -20,9 +20,10 @@ True https://github.com/CodeShayk/ApiAggregator/wiki https://github.com/CodeShayk/ApiAggregator - v2.0 - Targets .Net9.0 + + v2.0.1 - Targets .Net9.0, net5.0, net6.0, net8.0, .Net Standard 2.0, and .Net Framework 4.6.2.
- Includes core functionality for aggregating apis.
- 2.0.0 + 2.0.1
@@ -46,6 +47,7 @@ + diff --git a/src/ApiAggregator/ApiComparer.cs b/src/ApiAggregator/ApiComparer.cs index 73f0c98..91f05e0 100644 --- a/src/ApiAggregator/ApiComparer.cs +++ b/src/ApiAggregator/ApiComparer.cs @@ -1,3 +1,5 @@ +using System.Collections.Generic; + namespace ApiAggregator { internal class ApiComparer : IEqualityComparer diff --git a/src/ApiAggregator/ApiList.cs b/src/ApiAggregator/ApiList.cs index 050a4ef..ceabc6a 100644 --- a/src/ApiAggregator/ApiList.cs +++ b/src/ApiAggregator/ApiList.cs @@ -1,3 +1,6 @@ +using System.Collections.Generic; +using System.Linq; + namespace ApiAggregator { internal class ApiList : IApiList diff --git a/src/ApiAggregator/ApiResult.cs b/src/ApiAggregator/ApiResult.cs index eed6d47..de45b45 100644 --- a/src/ApiAggregator/ApiResult.cs +++ b/src/ApiAggregator/ApiResult.cs @@ -1,3 +1,5 @@ +using System.Collections.Generic; + namespace ApiAggregator { public abstract class ApiResult : IApiResult diff --git a/src/ApiAggregator/CacheResultAttribute.cs b/src/ApiAggregator/CacheResultAttribute.cs index 5e8ffd5..90a2d2e 100644 --- a/src/ApiAggregator/CacheResultAttribute.cs +++ b/src/ApiAggregator/CacheResultAttribute.cs @@ -1,3 +1,5 @@ +using System; + namespace ApiAggregator { public class CacheResultAttribute : Attribute diff --git a/src/ApiAggregator/CollectionResult.cs b/src/ApiAggregator/CollectionResult.cs index 343b4da..93953a4 100644 --- a/src/ApiAggregator/CollectionResult.cs +++ b/src/ApiAggregator/CollectionResult.cs @@ -1,3 +1,5 @@ +using System.Collections.Generic; + namespace ApiAggregator { public class CollectionResult : List, IApiResult diff --git a/src/ApiAggregator/CreateAggregate.cs b/src/ApiAggregator/CreateAggregate.cs index 04d138a..93a95cc 100644 --- a/src/ApiAggregator/CreateAggregate.cs +++ b/src/ApiAggregator/CreateAggregate.cs @@ -1,3 +1,6 @@ +using System; +using System.Collections.Generic; + namespace ApiAggregator { #region Helpers @@ -65,7 +68,8 @@ public IMapOrComplete Map(IApiName if (dependents != null) foreach (var dep in ((IMappings)dependents(mapping)).GetMappings) { - dep.DependentOn ??= mapping.Api; + if (dep.DependentOn == null) + dep.DependentOn = mapping.Api; Add(dep); } diff --git a/src/ApiAggregator/Helpers/ArrayUtil.cs b/src/ApiAggregator/Helpers/ArrayUtil.cs index 865008e..91d0719 100644 --- a/src/ApiAggregator/Helpers/ArrayUtil.cs +++ b/src/ApiAggregator/Helpers/ArrayUtil.cs @@ -1,3 +1,5 @@ +using System; + namespace ApiAggregator.Helpers { public static class ArrayUtil diff --git a/src/ApiAggregator/Helpers/Constraints.cs b/src/ApiAggregator/Helpers/Constraints.cs index b236ffa..047a6c4 100644 --- a/src/ApiAggregator/Helpers/Constraints.cs +++ b/src/ApiAggregator/Helpers/Constraints.cs @@ -1,4 +1,6 @@ -namespace ApiAggregator.Helpers +using System; + +namespace ApiAggregator.Helpers { public static class Constraints { diff --git a/src/ApiAggregator/Helpers/EnumerableExtentions.cs b/src/ApiAggregator/Helpers/EnumerableExtentions.cs index fb4a4e3..0d1d299 100644 --- a/src/ApiAggregator/Helpers/EnumerableExtentions.cs +++ b/src/ApiAggregator/Helpers/EnumerableExtentions.cs @@ -1,3 +1,5 @@ +using System; +using System.Collections.Generic; using System.Text; namespace ApiAggregator.Helpers diff --git a/src/ApiAggregator/Helpers/JsonExtensions.cs b/src/ApiAggregator/Helpers/JsonExtensions.cs index 5aaf653..645d6f3 100644 --- a/src/ApiAggregator/Helpers/JsonExtensions.cs +++ b/src/ApiAggregator/Helpers/JsonExtensions.cs @@ -1,11 +1,12 @@ +using System; using System.Text.Json; namespace ApiAggregator.Helpers { public static class JsonExtensions { - public static string? ToJson(this object value) => value != null ? JsonSerializer.Serialize(value) : null; + public static string ToJson(this object value) => value != null ? JsonSerializer.Serialize(value) : null; - public static object? ToObject(this string value, Type type) => !string.IsNullOrEmpty(value) ? JsonSerializer.Deserialize(value, type) : null; + public static object ToObject(this string value, Type type) => !string.IsNullOrEmpty(value) ? JsonSerializer.Deserialize(value, type) : null; } } \ No newline at end of file diff --git a/src/ApiAggregator/IApiAggregate.cs b/src/ApiAggregator/IApiAggregate.cs index 34be578..117ed54 100644 --- a/src/ApiAggregator/IApiAggregate.cs +++ b/src/ApiAggregator/IApiAggregate.cs @@ -1,3 +1,5 @@ +using System.Collections.Generic; + namespace ApiAggregator { /// diff --git a/src/ApiAggregator/IApiEngine.cs b/src/ApiAggregator/IApiEngine.cs index dceb9c2..e6dba53 100644 --- a/src/ApiAggregator/IApiEngine.cs +++ b/src/ApiAggregator/IApiEngine.cs @@ -1,3 +1,5 @@ +using System.Collections.Generic; + namespace ApiAggregator { public interface IApiEngine diff --git a/src/ApiAggregator/IApiExecutor.cs b/src/ApiAggregator/IApiExecutor.cs index 7ad401a..67cea83 100644 --- a/src/ApiAggregator/IApiExecutor.cs +++ b/src/ApiAggregator/IApiExecutor.cs @@ -1,3 +1,5 @@ +using System.Collections.Generic; + namespace ApiAggregator { internal interface IApiExecutor diff --git a/src/ApiAggregator/IApiList.cs b/src/ApiAggregator/IApiList.cs index e8e1064..94cf2c1 100644 --- a/src/ApiAggregator/IApiList.cs +++ b/src/ApiAggregator/IApiList.cs @@ -1,3 +1,5 @@ +using System.Collections.Generic; + namespace ApiAggregator { public interface IApiList diff --git a/src/ApiAggregator/IApiResult.cs b/src/ApiAggregator/IApiResult.cs index f6f4e90..c0a474c 100644 --- a/src/ApiAggregator/IApiResult.cs +++ b/src/ApiAggregator/IApiResult.cs @@ -1,7 +1,9 @@ +using System.Collections.Generic; + namespace ApiAggregator { public interface IApiResult { - IDictionary Headers { get; internal set; } + IDictionary Headers { get; set; } } } \ No newline at end of file diff --git a/src/ApiAggregator/IApiResultCache.cs b/src/ApiAggregator/IApiResultCache.cs index 58e69b1..46c6149 100644 --- a/src/ApiAggregator/IApiResultCache.cs +++ b/src/ApiAggregator/IApiResultCache.cs @@ -1,3 +1,5 @@ +using System.Collections.Generic; + namespace ApiAggregator { public interface IApiResultCache @@ -5,6 +7,6 @@ public interface IApiResultCache /// /// Cache dictionary holding api results for api result type marked with [CacheResult] attribute. /// - internal Dictionary Cache { get; set; } + Dictionary Cache { get; set; } } } \ No newline at end of file diff --git a/src/ApiAggregator/IContractBuilder.cs b/src/ApiAggregator/IContractBuilder.cs index 6d3dc23..06f73d9 100644 --- a/src/ApiAggregator/IContractBuilder.cs +++ b/src/ApiAggregator/IContractBuilder.cs @@ -1,3 +1,5 @@ +using System.Collections.Generic; + namespace ApiAggregator { public interface IContractBuilder where TContract : IContract diff --git a/src/ApiAggregator/IRequestContext.cs b/src/ApiAggregator/IRequestContext.cs index 465a91c..03291d2 100644 --- a/src/ApiAggregator/IRequestContext.cs +++ b/src/ApiAggregator/IRequestContext.cs @@ -5,6 +5,6 @@ public interface IRequestContext : IApiResultCache /// /// Aggregate api names for data retrieval. /// - public string[] Names { get; } + string[] Names { get; } } } \ No newline at end of file diff --git a/src/ApiAggregator/ITransformerResultType.cs b/src/ApiAggregator/ITransformerResultType.cs index d5b3b8e..11dcb74 100644 --- a/src/ApiAggregator/ITransformerResultType.cs +++ b/src/ApiAggregator/ITransformerResultType.cs @@ -1,3 +1,5 @@ +using System; + namespace ApiAggregator { /// diff --git a/src/ApiAggregator/IWebApi.cs b/src/ApiAggregator/IWebApi.cs index 89c5d19..09493bb 100644 --- a/src/ApiAggregator/IWebApi.cs +++ b/src/ApiAggregator/IWebApi.cs @@ -1,3 +1,7 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Threading.Tasks; using Microsoft.Extensions.Logging; namespace ApiAggregator diff --git a/src/ApiAggregator/Impl/ApiBuilder.cs b/src/ApiAggregator/Impl/ApiBuilder.cs index d653ba1..41c3abb 100644 --- a/src/ApiAggregator/Impl/ApiBuilder.cs +++ b/src/ApiAggregator/Impl/ApiBuilder.cs @@ -1,3 +1,5 @@ +using System.Collections.Generic; +using System.Linq; using ApiAggregator.Helpers; namespace ApiAggregator.Impl diff --git a/src/ApiAggregator/Impl/ApiEngine.cs b/src/ApiAggregator/Impl/ApiEngine.cs index 2382e48..6485e0b 100644 --- a/src/ApiAggregator/Impl/ApiEngine.cs +++ b/src/ApiAggregator/Impl/ApiEngine.cs @@ -1,3 +1,7 @@ +using System.Collections.Generic; +using System.Linq; +using System.Net.Http; +using System.Threading.Tasks; using ApiAggregator.Helpers; using Microsoft.Extensions.Logging; @@ -21,7 +25,7 @@ public ApiEngine(IHttpClientFactory httpClientFactory, ILogger logger public IEnumerable Execute(IEnumerable apis) { if (apis == null || !apis.Any()) - return []; + return Enumerable.Empty(); logger?.LogInformation($"Total web apis to execute: {apis.Count()}"); diff --git a/src/ApiAggregator/Impl/ApiExecutor.cs b/src/ApiAggregator/Impl/ApiExecutor.cs index c53514c..9a79166 100644 --- a/src/ApiAggregator/Impl/ApiExecutor.cs +++ b/src/ApiAggregator/Impl/ApiExecutor.cs @@ -1,4 +1,6 @@ using ApiAggregator.Helpers; +using System.Collections.Generic; +using System.Linq; using System.Net.Http; namespace ApiAggregator.Impl diff --git a/src/ApiAggregator/Impl/ContractBuilder.cs b/src/ApiAggregator/Impl/ContractBuilder.cs index 2bfed41..378fe45 100644 --- a/src/ApiAggregator/Impl/ContractBuilder.cs +++ b/src/ApiAggregator/Impl/ContractBuilder.cs @@ -1,3 +1,5 @@ +using System.Collections.Generic; +using System.Linq; using ApiAggregator.Helpers; namespace ApiAggregator.Impl diff --git a/src/ApiAggregator/Impl/EventPublisher.cs b/src/ApiAggregator/Impl/EventPublisher.cs index ff020ec..1d71391 100644 --- a/src/ApiAggregator/Impl/EventPublisher.cs +++ b/src/ApiAggregator/Impl/EventPublisher.cs @@ -1,3 +1,5 @@ +using System; +using System.Collections.Generic; using ApiAggregator.Helpers; namespace ApiAggregator.Impl diff --git a/src/ApiAggregator/Impl/EventSubscriber.cs b/src/ApiAggregator/Impl/EventSubscriber.cs index 50d21e7..4343a26 100644 --- a/src/ApiAggregator/Impl/EventSubscriber.cs +++ b/src/ApiAggregator/Impl/EventSubscriber.cs @@ -1,3 +1,6 @@ +using System.Collections.Generic; +using System.Linq; + namespace ApiAggregator.Impl { internal class EventSubscriber : ISubscriber diff --git a/src/ApiAggregator/NestedApiList.cs b/src/ApiAggregator/NestedApiList.cs index 96298b9..6edcbc8 100644 --- a/src/ApiAggregator/NestedApiList.cs +++ b/src/ApiAggregator/NestedApiList.cs @@ -1,3 +1,6 @@ +using System; +using System.Collections.Generic; + namespace ApiAggregator { public class NestedApiList diff --git a/src/ApiAggregator/RequestContext.cs b/src/ApiAggregator/RequestContext.cs index d9d7ea1..3038059 100644 --- a/src/ApiAggregator/RequestContext.cs +++ b/src/ApiAggregator/RequestContext.cs @@ -1,4 +1,6 @@ -namespace ApiAggregator +using System.Collections.Generic; + +namespace ApiAggregator { public abstract class RequestContext : IRequestContext { diff --git a/src/ApiAggregator/ResultTransformer.cs b/src/ApiAggregator/ResultTransformer.cs index 92b4f05..1463f64 100644 --- a/src/ApiAggregator/ResultTransformer.cs +++ b/src/ApiAggregator/ResultTransformer.cs @@ -1,3 +1,5 @@ +using System; + namespace ApiAggregator { diff --git a/src/ApiAggregator/StringContainsMatcher.cs b/src/ApiAggregator/StringContainsMatcher.cs index 8dd8d6b..bed6951 100644 --- a/src/ApiAggregator/StringContainsMatcher.cs +++ b/src/ApiAggregator/StringContainsMatcher.cs @@ -1,3 +1,4 @@ +using System.Linq; using ApiAggregator.Helpers; namespace ApiAggregator diff --git a/src/ApiAggregator/WebApi.cs b/src/ApiAggregator/WebApi.cs index fecf2ab..ec2799a 100644 --- a/src/ApiAggregator/WebApi.cs +++ b/src/ApiAggregator/WebApi.cs @@ -1,3 +1,9 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; using ApiAggregator.Helpers; using Microsoft.Extensions.Logging; @@ -58,7 +64,7 @@ protected virtual IDictionary GetRequestHeaders() /// /// protected virtual IEnumerable GetResponseHeaders() - { return []; } + { return Enumerable.Empty(); ; } /// /// Implement to construct the api endpoint. @@ -175,7 +181,7 @@ public virtual async Task Run(IHttpClientFactory httpClientFactory, return null; } - private void SetResponseHeaders(HttpResponseMessage response, TResult? result) + private void SetResponseHeaders(HttpResponseMessage response, TResult result) { if (response.Headers == null || result == null) return; @@ -193,8 +199,8 @@ private void SetResponseHeaders(HttpResponseMessage response, TResult? result) var value = responseHeader.Value != null && responseHeader.Value.Any() ? responseHeader.Value.ElementAt(0) : string.Empty; - - result.Headers ??= new Dictionary(); + if (result.Headers == null) + result.Headers = new Dictionary(); result.Headers.Add(responseHeader.Key, value); }