Skip to content

Commit

Permalink
Styling fixes (#14)
Browse files Browse the repository at this point in the history
* Fixed stylecop issues

* More stylecop fixes

* Move all projects to netstandard2.1, removed BCL interfaces

* Removed unused usings.

* Downgraded to compatible version of System.Text.Json

* Fixed PR comments

* Fixed csproj
  • Loading branch information
aasim authored Jun 23, 2022
1 parent 47d51cc commit 591b098
Show file tree
Hide file tree
Showing 146 changed files with 247 additions and 319 deletions.
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<PackageVersion Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.0"/>
<PackageVersion Include="Newtonsoft.Json" Version="13.0.1"/>
<PackageVersion Include="StyleCop.Analyzers" Version="1.1.118"/>
<PackageVersion Include="System.Text.Json" Version="6.0.0" />
<PackageVersion Include="System.Text.Json" Version="5.0.2" />
<PackageVersion Include="System.Composition.AttributedModel" Version="1.4.1"/>
<PackageVersion Include="System.Composition.Convention" Version="1.4.1"/>
<PackageVersion Include="System.Composition.Hosting" Version="1.4.1"/>
Expand Down
Binary file removed src/Microsoft.Sbom.Adapters/Microsoft.SBOM.Adapters.snk
Binary file not shown.
8 changes: 2 additions & 6 deletions src/Microsoft.Sbom.Adapters/Microsoft.Sbom.Adapters.csproj
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Nullable>enable</Nullable>
<TargetFramework>netstandard2.1</TargetFramework>
<AssemblyName>Microsoft.SBOM.Adapters</AssemblyName>
<SignAssembly>True</SignAssembly>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Authors>Microsoft Corporation</Authors>
<Description>Provides a set of adapters from external component formats to a single SBOM format.</Description>
<PackageVersion>$(SBOMPackageVersion)</PackageVersion>
<Nullable>enable</Nullable>
<!--NU5104: Warning thrown because Microsoft.VisualStudio.Services.Governance.ComponentDetection.Contracts is a "prerelease" package.-->
<!--Note: due to a bug in dotnet, this needs to be a global nowarn instead of for the specific package it is trying to suppress.-->
<NoWarn>NU5104</NoWarn>
<AssemblyOriginatorKeyFile>Microsoft.SBOM.Adapters.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion src/Microsoft.Sbom.Api/Config/ApiConfigurationBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Linq;
using Microsoft.Sbom.Extensions.Entities;
using Microsoft.Sbom.Api.Utils;
using Microsoft.Sbom.Common;
using Microsoft.Sbom.Common.Config;
using Microsoft.Sbom.Contracts;
using Serilog.Events;
Expand Down
2 changes: 2 additions & 0 deletions src/Microsoft.Sbom.Api/Config/ArgRevivers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
using PowerArgs;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;

namespace Microsoft.Sbom.Api.Config
{
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1313:Parameter names should begin with lower-case letter", Justification = "Discard variable has a _ name")]
public class ArgRevivers
{
/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.Sbom.Api/Config/Args/CommonArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace Microsoft.Sbom.Api.Config.Args
{
/// <summary>
/// Defines the common arguments used by all actions of the ManifestTool
/// Defines the common arguments used by all actions of the ManifestTool.
/// </summary>
public class CommonArgs
{
Expand All @@ -27,7 +27,7 @@ public class CommonArgs
public int? Parallelism { get; set; }

/// <summary>
/// Gets or sets a JSON config file that can be used to specify all the arguments for an action
/// Gets or sets a JSON config file that can be used to specify all the arguments for an action.
/// </summary>
[ArgDescription("The json file that contains the configuration for the DropValidator.")]
public string ConfigFilePath { get; set; }
Expand Down
8 changes: 4 additions & 4 deletions src/Microsoft.Sbom.Api/Config/Args/GenerationArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace Microsoft.Sbom.Api.Config.Args
{
/// <summary>
/// The command line arguments provided for the generate action in ManifestTool
/// The command line arguments provided for the generate action in ManifestTool.
/// </summary>
public class GenerationArgs : CommonArgs
{
Expand Down Expand Up @@ -36,7 +36,7 @@ public class GenerationArgs : CommonArgs

/// <summary>
/// Gets or sets the root folder where the generated manifest (and other files like bsi.json) files will be placed.
/// By default we will generate this folder in the same level as the build drop with the name '_manifest'
/// By default we will generate this folder in the same level as the build drop with the name '_manifest'.
/// </summary>
[ArgShortcut("m")]
[ArgDescription("The path of the directory where the generated manifest files will be placed." +
Expand Down Expand Up @@ -82,14 +82,14 @@ public class GenerationArgs : CommonArgs

/// <summary>
/// Gets or sets the base of the URI that will be used to generate this SBOM. This should be a value that identifies that
/// the SBOM belongs to a single publisher (or company)
/// the SBOM belongs to a single publisher (or company).
/// </summary>
[ArgShortcut("nsb")]
[ArgDescription("The base path of the SBOM namespace URI.")]
public string NamespaceUriBase { get; set; }

/// <summary>
/// Gets or sets a timestamp in the format <code>yyyy-MM-ddTHH:mm:ssZ</code> that will be used as the generated timestamp for the SBOM.
/// Gets or sets a timestamp in the format. <code>yyyy-MM-ddTHH:mm:ssZ</code> that will be used as the generated timestamp for the SBOM.
/// </summary>
[ArgShortcut("gt")]
[ArgDescription("A timestamp in the format 'yyyy-MM-ddTHH:mm:ssZ' that will be used as the generated timestamp for the SBOM.")]
Expand Down
6 changes: 2 additions & 4 deletions src/Microsoft.Sbom.Api/Config/Args/ValidationArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using PowerArgs;
using Microsoft.Sbom.Extensions.Entities;
using System.Collections.Generic;
using Microsoft.Sbom.Contracts.Enums;

namespace Microsoft.Sbom.Api.Config.Args
{
/// <summary>
/// The command line arguments provided for the validate action in ManifestTool
/// The command line arguments provided for the validate action in ManifestTool.
/// </summary>
public class ValidationArgs : CommonArgs
{
Expand Down Expand Up @@ -38,7 +36,7 @@ public class ValidationArgs : CommonArgs
public string OutputPath { get; set; }

/// <summary>
/// Gets or sets the path of the signed catalog file used to validate the manifest.json
/// Gets or sets the path of the signed catalog file used to validate the manifest.json.
/// </summary>
[ArgDescription("The path of signed catalog file that is used to verify the signature of the manifest json file.")]
public string CatalogFilePath { get; set; }
Expand Down
10 changes: 5 additions & 5 deletions src/Microsoft.Sbom.Api/Config/ConfigFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class ConfigFile

/// <summary>
/// Gets or sets the root folder where the generated manifest (and other files like bsi.json) files will be placed.
/// By default we will generate this folder in the same level as the build drop with the name '_manifest'
/// By default we will generate this folder in the same level as the build drop with the name '_manifest'.
/// </summary>
public string ManifestDirPath { get; set; }

Expand All @@ -53,7 +53,7 @@ public class ConfigFile
public string OutputPath { get; set; }

/// <summary>
/// Gets or sets the path of the signed catalog file used to validate the manifest.json
/// Gets or sets the path of the signed catalog file used to validate the manifest.json.
/// </summary>
public string CatalogFilePath { get; set; }

Expand Down Expand Up @@ -105,7 +105,7 @@ public class ConfigFile
public string PackageVersion { get; set; }

/// <summary>
/// Gets or sets a JSON config file that can be used to specify all the arguments for an action
/// Gets or sets a JSON config file that can be used to specify all the arguments for an action.
/// </summary>
[JsonIgnore]
public string ConfigFilePath { get; set; }
Expand Down Expand Up @@ -142,12 +142,12 @@ public class ConfigFile

/// <summary>
/// Gets or sets the base of the URI that will be used to generate this SBOM. This should be a value that identifies that
/// the SBOM belongs to a single publisher (or company)
/// the SBOM belongs to a single publisher (or company).
/// </summary>
public string NamespaceUriBase { get; set; }

/// <summary>
/// Gets or sets a timestamp in the format <code>yyyy-MM-ddTHH:mm:ssZ</code> that will be used as the generated timestamp for the SBOM.
/// Gets or sets a timestamp in the format. <code>yyyy-MM-ddTHH:mm:ssZ</code> that will be used as the generated timestamp for the SBOM.
/// </summary>
public string GenerationTimestamp { get; set; }

Expand Down
6 changes: 0 additions & 6 deletions src/Microsoft.Sbom.Api/Config/ConfigPostProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,11 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using AutoMapper;
using DropValidator.Api.Config;
using Microsoft.Sbom.Api.Config.Validators;
using Microsoft.Sbom.Api.Hashing;
using Microsoft.Sbom.Common;
using Microsoft.Sbom.Common.Config;
using Microsoft.Sbom.Common.Config.Validators;
using Microsoft.Sbom.Contracts.Enums;
using PowerArgs;
using System;
using System.ComponentModel;
using Constants = Microsoft.Sbom.Api.Utils.Constants;

namespace Microsoft.Sbom.Api.Config
{
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.Sbom.Api/Config/ConfigSanitizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ private ConfigurationSetting<string> GetNamespaceBaseUriFromAssembly(Configurati
}

/// <summary>
/// Set ManifestDirPath if the value is null or empty to default value
/// Set ManifestDirPath if the value is null or empty to default value.
/// </summary>
private ConfigurationSetting<string> GetManifestDirPath(ConfigurationSetting<string> manifestDirPathConfig, string buildDropPath, ManifestToolActions manifestToolAction)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace DropValidator.Api.Config.Extensions
public static class ConfigurationExtensions
{
/// <summary>
/// Get the name and value of each IConfiguration property that is annotated with <see cref=ComponentDetectorArgumentAttribute />.
/// Get the name and value of each IConfiguration property that is annotated with <see cref=ComponentDetectorArgumentAttribute />..
/// </summary>
/// <param name="configuration"></param>
/// <returns></returns>
Expand Down
6 changes: 4 additions & 2 deletions src/Microsoft.Sbom.Api/Config/ManifestToolCmdRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public ManifestToolCmdRunner(StandardKernel kernel)
/// Validate a build artifact using the manifest. Optionally also verify the signing certificate of the manfiest.
/// </summary>
/// <param name="validationArgs"></param>
[ArgActionMethod, ArgDescription("Validate a build artifact using the manifest. " +
[ArgActionMethod]
[ArgDescription("Validate a build artifact using the manifest. " +
"Optionally also verify the signing certificate of the manfiest.")]
public async Task Validate(ValidationArgs validationArgs)
{
Expand All @@ -87,7 +88,8 @@ public async Task Validate(ValidationArgs validationArgs)
/// <summary>
/// Generate a manifest.json and a bsi.json for all the files in the given build drop folder.
/// </summary>
[ArgActionMethod, ArgDescription("Generate a manifest.json and a bsi.json for all the files " +
[ArgActionMethod]
[ArgDescription("Generate a manifest.json and a bsi.json for all the files " +
"in the given build drop folder.")]
public async Task Generate(GenerationArgs generationArgs)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.Sbom.Common.Config.Validators
{
/// <summary>
/// Abstract class from which all validators must inherit.
/// This class only validates configuration properties that are of the type <see cref="ConfigurationSetting{T}"/>
/// This class only validates configuration properties that are of the type <see cref="ConfigurationSetting{T}"/>.
/// </summary>
public abstract class ConfigValidator
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace Microsoft.Sbom.Api.Config.Validators
{
/// <summary>
/// Verifies that the value is not null
/// Verifies that the value is not null.
/// </summary>
public class ValueRequiredValidator : ConfigValidator
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace Microsoft.Sbom.Api.Config.ValueConverters
{
/// <summary>
/// Converts a nullable bool member to a ConfigurationSetting decorated string member
/// Converts a nullable bool member to a ConfigurationSetting decorated string member.
/// </summary>
internal class BoolConfigurationSettingAddingConverter : IValueConverter<bool, ConfigurationSetting<bool>>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace Microsoft.Sbom.Api.Config.ValueConverters
{
/// <summary>
/// Converts an LogEventLevel member to a ConfigurationSetting decorated string member
/// Converts an LogEventLevel member to a ConfigurationSetting decorated string member.
/// </summary>
internal class HashAlgorithmNameConfigurationSettingAddingConverter : IValueConverter<AlgorithmName, ConfigurationSetting<AlgorithmName>>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using AutoMapper;
using Microsoft.Sbom.Api.Utils;
using Microsoft.Sbom.Common.Config;
using Serilog.Events;
using Constants = Microsoft.Sbom.Common.Constants;

namespace Microsoft.Sbom.Api.Config.ValueConverters
{
/// <summary>
/// Converts an LogEventLevel member to a ConfigurationSetting decorated string member
/// Converts an LogEventLevel member to a ConfigurationSetting decorated string member.
/// </summary>
internal class LogEventLevelConfigurationSettingAddingConverter : IValueConverter<LogEventLevel?, ConfigurationSetting<LogEventLevel>>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace Microsoft.Sbom.Api.Config.ValueConverters
{
/// <summary>
/// Converts an ManifestInfo member to a ConfigurationSetting decorated string member
/// Converts an ManifestInfo member to a ConfigurationSetting decorated string member.
/// </summary>
internal class ManifestInfoConfigurationSettingAddingConverter : IValueConverter<IList<ManifestInfo>, ConfigurationSetting<IList<ManifestInfo>>>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace Microsoft.Sbom.Api.Config.ValueConverters
{
/// <summary>
/// Converts a nullable bool member to a ConfigurationSetting decorated string member
/// Converts a nullable bool member to a ConfigurationSetting decorated string member.
/// </summary>
internal class NullableBoolConfigurationSettingAddingConverter : IValueConverter<bool?, ConfigurationSetting<bool>>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace Microsoft.Sbom.Api.Config.ValueConverters
{
/// <summary>
/// Converts a string member to a ConfigurationSetting decorated string member
/// Converts a string member to a ConfigurationSetting decorated string member.
/// </summary>
internal class StringConfigurationSettingAddingConverter : IValueConverter<string, ConfigurationSetting<string>>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
namespace Microsoft.Sbom.Api.Converters
{
/// <summary>
/// Converts ScannedComponent objects of SbomComponent type to ExternalDocumentReferenceInfo
/// Converts ScannedComponent objects of SbomComponent type to ExternalDocumentReferenceInfo.
/// </summary>
public class ComponentToExternalReferenceInfoConverter
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using Microsoft.Sbom.Extensions.Entities;
using Microsoft.ComponentDetection.Contracts.BcdeModels;
using Microsoft.Sbom.Api.Entities;
using Serilog;
using System;
Expand All @@ -12,7 +11,7 @@
namespace Microsoft.Sbom.Api.Converters
{
/// <summary>
/// Converts ExternalDocumentReferenceInfo objects to their path as string
/// Converts ExternalDocumentReferenceInfo objects to their path as string.
/// </summary>
public class ExternalReferenceInfoToPathConverter
{
Expand Down
2 changes: 0 additions & 2 deletions src/Microsoft.Sbom.Api/Converters/IManifestPathConverter.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using Microsoft.Sbom.Extensions.Entities;

namespace Microsoft.Sbom.Api.Convertors
{
public interface IManifestPathConverter
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.Sbom.Api/Entities/ExitCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Microsoft.Sbom.Api
{
/// <summary>
/// Defines the exit code returned by the ManifestTool executable
/// Defines the exit code returned by the ManifestTool executable.
/// </summary>
public enum ExitCode
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public ValidationResultGenerator(IConfiguration configuration, ManifestData mani
/// Retuns the <see cref="ValidationResultGenerator"/> for chaining.
/// </summary>
/// <param name="successCount"></param>
/// <returns><see cref="ValidationResultGenerator"/></returns>
/// <returns><see cref="ValidationResultGenerator"/>.</returns>
public ValidationResultGenerator WithSuccessCount(int successCount)
{
this.successCount = successCount;
Expand All @@ -44,7 +44,7 @@ public ValidationResultGenerator WithSuccessCount(int successCount)
/// Retuns the <see cref="ValidationResultGenerator"/> for chaining.
/// </summary>
/// <param name="duration"></param>
/// <returns><see cref="ValidationResultGenerator"/></returns>
/// <returns><see cref="ValidationResultGenerator"/>.</returns>
public ValidationResultGenerator WithTotalDuration(TimeSpan duration)
{
this.duration = duration;
Expand All @@ -56,7 +56,7 @@ public ValidationResultGenerator WithTotalDuration(TimeSpan duration)
/// Retuns the <see cref="ValidationResultGenerator"/> for chaining.
/// </summary>
/// <param name="nodeValidationResults"></param>
/// <returns><see cref="ValidationResultGenerator"/></returns>
/// <returns><see cref="ValidationResultGenerator"/>.</returns>
public ValidationResultGenerator WithValidationResults(IList<FileValidationResult> nodeValidationResults)
{
NodeValidationResults = nodeValidationResults ?? new List<FileValidationResult>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace Microsoft.Sbom.Api.Exceptions
{
/// <summary>
/// Exception during argument validation used to indicate when we don't have access to a path passed as argument
/// Exception during argument validation used to indicate when we don't have access to a path passed as argument.
/// </summary>
[Serializable]
public class AccessDeniedValidationArgException : ValidationArgException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Microsoft.Sbom.Api.Exceptions
{
/// <summary>
/// Thrown when the instantiated <see cref="IPackageInfoConverter"/>
/// cannot convert the <see cref="Microsoft.VisualStudio.Services.Governance.ComponentDetection.TypedComponent"/>
/// cannot convert the <see cref="Microsoft.VisualStudio.Services.Governance.ComponentDetection.TypedComponent"/>.
/// </summary>
/// <remarks>
/// Thrown out of public classes implementing IPackageInfoConverter so it must also be public.
Expand Down
Loading

0 comments on commit 591b098

Please sign in to comment.