Skip to content

Commit

Permalink
Revert non-PR .NET 8 commits
Browse files Browse the repository at this point in the history
  • Loading branch information
cobya committed Sep 16, 2024
1 parent 48299d7 commit 7528c8f
Show file tree
Hide file tree
Showing 267 changed files with 1,205 additions and 1,154 deletions.
2 changes: 1 addition & 1 deletion .azdo/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ extends:
displayName: Install .NET
inputs:
packageType: 'sdk'
version: '8.0.x'
version: '6.0.x'

# https://eng.ms/docs/cloud-ai-platform/devdiv/one-engineering-system-1es/1es-docs/1es-security-configuration/configuration-guides/pat-burndown-guidance#workarounds-for-tasks-that-do-not-yet-support-wif-service-connection
- task: AzureCLI@2
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://raw.githubusercontent.com/devcontainers/spec/main/schemas/devContainer.base.schema.json",
"name": "Component Detection",
"image": "mcr.microsoft.com/vscode/devcontainers/dotnet:8.0",
"image": "mcr.microsoft.com/vscode/devcontainers/dotnet:6.0",
"runArgs": ["--init"],
"extensions": [
"eamodio.gitlens",
Expand Down
18 changes: 0 additions & 18 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -679,24 +679,6 @@ dotnet_diagnostic.CA1848.severity = suggestion
# JSON002: Probable JSON string detected
dotnet_diagnostic.JSON002.severity = suggestion

# IDE0290: Use primary constructor
dotnet_diagnostic.IDE0290.severity = suggestion

# IDE0305: Simplify collection initialization
dotnet_diagnostic.IDE0305.severity = suggestion

# SYSLIB1045: Convert to 'GeneratedRegexAttribute'.
dotnet_diagnostic.SYSLIB1045.severity = suggestion

# CA1859: Use concrete types when possible for improved performance
dotnet_diagnostic.CA1859.severity = suggestion

# CA1851: Possible multiple enumerations of 'IEnumerable' collection
dotnet_diagnostic.CA1851.severity = suggestion

# CA1861: Avoid constant arrays as arguments
dotnet_diagnostic.CA1861.severity = suggestion

# Workaround for https://github.com/dotnet/roslyn-analyzers/issues/5628
[Program.cs]
dotnet_diagnostic.ca1812.severity = none
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>

<PropertyGroup Label="Build">
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>latest</LangVersion>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
Expand Down
27 changes: 14 additions & 13 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
<PackageVersion Include="CommandLineParser" Version="2.9.1" />
<PackageVersion Include="Docker.DotNet" Version="3.125.15" />
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
<PackageVersion Include="FluentAssertions.Analyzers" Version="0.32.0" />
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageVersion Include="FluentAssertions.Analyzers" Version="0.26.0" />
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="7.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="7.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageVersion Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.11.20" />
<PackageVersion Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.8.14" />
<PackageVersion Include="DotNet.Glob" Version="2.1.1" />
<PackageVersion Include="MinVer" Version="5.0.0" />
<PackageVersion Include="Moq" Version="4.18.4" />
Expand All @@ -33,25 +33,26 @@
<PackageVersion Include="Polly" Version="8.4.0" />
<PackageVersion Include="SemanticVersioning" Version="2.0.2" />
<PackageVersion Include="Serilog" Version="4.0.0" />
<PackageVersion Include="Serilog.Extensions.Logging" Version="8.0.0" />
<PackageVersion Include="Serilog.Extensions.Logging" Version="7.0.0" />
<PackageVersion Include="Serilog.Sinks.Async" Version="1.5.0" />
<PackageVersion Include="Serilog.Sinks.Console" Version="5.0.1" />
<PackageVersion Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageVersion Include="Serilog.Sinks.Map" Version="1.0.2" />
<PackageVersion Include="Spectre.Console" Version="0.49.1" />
<PackageVersion Include="Spectre.Console.Cli" Version="0.49.1" />
<PackageVersion Include="Spectre.Console" Version="0.48.0" />
<PackageVersion Include="Spectre.Console.Cli" Version="0.48.0" />
<PackageVersion Include="Spectre.Console.Cli.Extensions.DependencyInjection" Version="0.2.0" />
<PackageVersion Include="Spectre.Console.Testing" Version="0.49.1" />
<PackageVersion Include="Spectre.Console.Testing" Version="0.48.0" />
<PackageVersion Include="StyleCop.Analyzers" Version="1.2.0-beta.556" />
<PackageVersion Include="System.Memory" Version="4.5.5" />
<PackageVersion Include="System.Reactive" Version="6.0.1" />
<PackageVersion Include="System.Runtime.Loader" Version="4.3.0" />
<PackageVersion Include="System.Text.Json" Version="8.0.4" />
<PackageVersion Include="System.Threading.Tasks.Dataflow" Version="8.0.0" />
<PackageVersion Include="System.Text.Json" Version="6.0.9" />
<PackageVersion Include="System.Threading.Tasks.Dataflow" Version="7.0.0" />
<PackageVersion Include="Tomlyn.Signed" Version="0.17.0" />
<PackageVersion Include="yamldotnet" Version="15.1.6" />
<PackageVersion Include="Faker.net" Version="2.0.163" />
<PackageVersion Include="Valleysoft.DockerfileModel" Version="1.1.1" />

<!-- Fix security alerts -->
<PackageVersion Include="System.Formats.Asn1" Version="6.0.1" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.401",
"version": "6.0.422",
"rollForward": "latestMinor"
}
}
12 changes: 9 additions & 3 deletions src/Microsoft.ComponentDetection.Common/AsyncExecution.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Microsoft.ComponentDetection.Common;
namespace Microsoft.ComponentDetection.Common;

using System;
using System.Threading;
Expand All @@ -21,7 +21,10 @@ public static class AsyncExecution
/// <exception cref="TimeoutException">Thrown when the execution does not complete within the timeout.</exception>
public static async Task<T> ExecuteWithTimeoutAsync<T>(Func<Task<T>> toExecute, TimeSpan timeout, CancellationToken cancellationToken)
{
ArgumentNullException.ThrowIfNull(toExecute);
if (toExecute == null)
{
throw new ArgumentNullException(nameof(toExecute));
}

var work = Task.Run(toExecute);

Expand All @@ -45,7 +48,10 @@ public static async Task<T> ExecuteWithTimeoutAsync<T>(Func<Task<T>> toExecute,
/// <exception cref="TimeoutException">Thrown when the execution does not complete within the timeout.</exception>
public static async Task ExecuteVoidWithTimeoutAsync(Action toExecute, TimeSpan timeout, CancellationToken cancellationToken)
{
ArgumentNullException.ThrowIfNull(toExecute);
if (toExecute == null)
{
throw new ArgumentNullException(nameof(toExecute));
}

var work = Task.Run(toExecute, cancellationToken);
var completedInTime = await Task.Run(() => work.Wait(timeout));
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.ComponentDetection.Common/Column.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Microsoft.ComponentDetection.Common;
namespace Microsoft.ComponentDetection.Common;

public class Column
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public class CommandLineInvocationService : ICommandLineInvocationService
/// <inheritdoc/>
public async Task<bool> CanCommandBeLocatedAsync(string command, IEnumerable<string> additionalCandidateCommands = null, DirectoryInfo workingDirectory = null, params string[] parameters)
{
additionalCandidateCommands ??= [];
parameters ??= [];
additionalCandidateCommands ??= Enumerable.Empty<string>();
parameters ??= Array.Empty<string>();
var allCommands = new[] { command }.Concat(additionalCandidateCommands);
if (!this.commandLocatableCache.TryGetValue(command, out var validCommand))
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Microsoft.ComponentDetection.Common;
namespace Microsoft.ComponentDetection.Common;

using System.Collections.Generic;
using Microsoft.ComponentDetection.Contracts.TypedComponent;
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.ComponentDetection.Common/ComponentStream.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Microsoft.ComponentDetection.Common;
namespace Microsoft.ComponentDetection.Common;

using System.IO;
using Microsoft.ComponentDetection.Contracts;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Microsoft.ComponentDetection.Common;
namespace Microsoft.ComponentDetection.Common;

using System;
using System.Collections;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Microsoft.ComponentDetection.Common;
namespace Microsoft.ComponentDetection.Common;

using System;
using System.Collections.Generic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Microsoft.ComponentDetection.Common.DependencyGraph;

public class ComponentRecorder : IComponentRecorder
{
private readonly ConcurrentBag<SingleFileComponentRecorder> singleFileRecorders = [];
private readonly ConcurrentBag<SingleFileComponentRecorder> singleFileRecorders = new ConcurrentBag<SingleFileComponentRecorder>();

private readonly bool enableManualTrackingOfExplicitReferences;

Expand All @@ -38,7 +38,7 @@ public IEnumerable<DetectedComponent> GetDetectedComponents()
IEnumerable<DetectedComponent> detectedComponents;
if (this.singleFileRecorders == null)
{
return [];
return Enumerable.Empty<DetectedComponent>();
}

detectedComponents = this.singleFileRecorders
Expand Down Expand Up @@ -68,7 +68,7 @@ public IEnumerable<string> GetSkippedComponents()
{
if (this.singleFileRecorders == null)
{
return [];
return Enumerable.Empty<string>();
}

return this.singleFileRecorders
Expand Down Expand Up @@ -162,22 +162,25 @@ public void RegisterUsage(
bool? isDevelopmentDependency = null,
DependencyScope? dependencyScope = null)
{
ArgumentNullException.ThrowIfNull(detectedComponent);
if (detectedComponent == null)
{
throw new ArgumentNullException(paramName: nameof(detectedComponent));
}

if (detectedComponent.Component == null)
{
throw new ArgumentException(Resources.MissingComponentId);
}

#if DEBUG
if (detectedComponent.DependencyRoots?.Count == 0)
if (detectedComponent.DependencyRoots?.Any() ?? false)
{
this.logger?.LogWarning("Detector should not populate DetectedComponent.DependencyRoots!");
this.logger.LogWarning("Detector should not populate DetectedComponent.DependencyRoots!");
}

if (detectedComponent.DevelopmentDependency.HasValue)
{
this.logger?.LogWarning("Detector should not populate DetectedComponent.DevelopmentDependency!");
this.logger.LogWarning("Detector should not populate DetectedComponent.DevelopmentDependency!");
}
#endif

Expand All @@ -192,7 +195,10 @@ public void RegisterUsage(

public void RegisterPackageParseFailure(string skippedComponent)
{
ArgumentNullException.ThrowIfNull(skippedComponent);
if (skippedComponent == null)
{
throw new ArgumentNullException(paramName: nameof(skippedComponent));
}

_ = this.skippedComponentsInternal[skippedComponent] = default;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Collections.Immutable;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using Microsoft.ComponentDetection.Contracts;
using Microsoft.ComponentDetection.Contracts.BcdeModels;

Expand All @@ -14,8 +13,6 @@ namespace Microsoft.ComponentDetection.Common.DependencyGraph;

internal class DependencyGraph : IDependencyGraph
{
private static readonly CompositeFormat MissingNodeFormat = CompositeFormat.Parse(Resources.MissingNodeInDependencyGraph);

private readonly ConcurrentDictionary<string, ComponentRefNode> componentNodes;

private readonly bool enableManualTrackingOfExplicitReferences;
Expand All @@ -30,11 +27,14 @@ public DependencyGraph(bool enableManualTrackingOfExplicitReferences)

public void AddComponent(ComponentRefNode componentNode, string parentComponentId = null)
{
ArgumentNullException.ThrowIfNull(componentNode);
if (componentNode == null)
{
throw new ArgumentNullException(nameof(componentNode));
}

if (string.IsNullOrWhiteSpace(componentNode.Id))
{
throw new ArgumentNullException(nameof(componentNode), "Invalid component node id");
throw new ArgumentNullException(nameof(componentNode.Id), "Invalid component node id");
}

this.componentNodes.AddOrUpdate(componentNode.Id, componentNode, (key, currentNode) =>
Expand Down Expand Up @@ -77,10 +77,10 @@ public ICollection<string> GetExplicitReferencedDependencyIds(string componentId

if (!this.componentNodes.TryGetValue(componentId, out var componentRef))
{
throw new ArgumentException(string.Format(null, MissingNodeFormat, componentId), paramName: nameof(componentId));
throw new ArgumentException(string.Format(Resources.MissingNodeInDependencyGraph, componentId), paramName: nameof(componentId));
}

IList<string> explicitReferencedDependencyIds = [];
IList<string> explicitReferencedDependencyIds = new List<string>();

this.GetExplicitReferencedDependencies(componentRef, explicitReferencedDependencyIds, new HashSet<string>());

Expand Down Expand Up @@ -129,7 +129,7 @@ public ICollection<string> GetAncestors(string componentId)
if (!this.componentNodes.TryGetValue(componentId, out var componentRef))
{
// this component isn't in the graph, so it has no ancestors
return [];
return new List<string>();
}

// store the component id and the depth we found it at
Expand Down Expand Up @@ -189,7 +189,7 @@ private void AddDependency(string componentId, string parentComponentId)

if (!this.componentNodes.TryGetValue(parentComponentId, out var parentComponentRefNode))
{
throw new ArgumentException(string.Format(null, MissingNodeFormat, parentComponentId), nameof(parentComponentId));
throw new ArgumentException(string.Format(Resources.MissingNodeInDependencyGraph, parentComponentId), nameof(parentComponentId));
}

parentComponentRefNode.DependencyIds.Add(componentId);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Microsoft.ComponentDetection.Common;
namespace Microsoft.ComponentDetection.Common;

using Microsoft.ComponentDetection.Contracts.BcdeModels;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Microsoft.ComponentDetection.Common;
namespace Microsoft.ComponentDetection.Common;

using System.Collections.Generic;
using System.Diagnostics;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
// short-identifier := /[a-f0-9]{6,64}/
namespace Microsoft.ComponentDetection.Common;

using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.ComponentDetection.Contracts;

public static class DockerReferenceUtility
Expand Down Expand Up @@ -122,7 +120,6 @@ public static (string Domain, string Remainder) SplitDockerDomain(string name)
return (domain, remainder);
}

[SuppressMessage("Globalization", "CA1308:Normalize strings to uppercase", Justification = "Explicitly checks for character case.")]
public static DockerReference ParseFamiliarName(string name)
{
if (DockerRegex.AnchoredIdentifierRegexp.IsMatch(name))
Expand All @@ -143,7 +140,7 @@ public static DockerReference ParseFamiliarName(string name)
remoteName = remainder;
}

if (!string.Equals(remoteName.ToLowerInvariant(), remoteName, StringComparison.InvariantCulture))
if (remoteName.ToLower() != remoteName)
{
throw new ReferenceNameContainsUppercaseException(name);
}
Expand Down
20 changes: 10 additions & 10 deletions src/Microsoft.ComponentDetection.Common/DockerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public async Task<ContainerDetails> InspectImageAsync(string image, Cancellation
CreatedAt = imageInspectResponse.Created,
BaseImageDigest = baseImageDigest,
BaseImageRef = baseImageRef,
Layers = layers ?? [],
Layers = layers ?? Enumerable.Empty<DockerLayer>(),
};
}
catch (Exception e)
Expand Down Expand Up @@ -212,19 +212,19 @@ private static async Task<CreateContainerResponse> CreateContainerAsync(
NetworkDisabled = true,
HostConfig = new HostConfig
{
CapDrop =
[
CapDrop = new List<string>
{
"all",
],
SecurityOpt =
[
},
SecurityOpt = new List<string>
{
"no-new-privileges",
],
Binds =
[
},
Binds = new List<string>
{
$"{Path.GetTempPath()}:/tmp",
"/var/run/docker.sock:/var/run/docker.sock",
],
},
},
};
return await Client.Containers.CreateContainerAsync(parameters, cancellationToken);
Expand Down
Loading

0 comments on commit 7528c8f

Please sign in to comment.