Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,23 @@ public sealed override FixAllProvider GetFixAllProvider()
public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
{
var root = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false);

if (root is null)
{
return;
}

var diagnostic = context.Diagnostics.First();
var diagnosticSpan = diagnostic.Location.SourceSpan;

// Find the type declaration identified by the diagnostic.
var declaration = root.FindToken(diagnosticSpan.Start).Parent.AncestorsAndSelf().OfType<TypeDeclarationSyntax>().First();
var declaration = root.FindToken(diagnosticSpan.Start).Parent?.AncestorsAndSelf().OfType<TypeDeclarationSyntax>().First();

if (declaration is null)
{
return;
}

// Register a code action that will invoke the fix.
context.RegisterCodeFix(
CodeAction.Create(
Expand All @@ -50,7 +60,7 @@ private async Task<Document> AddAttribute(CodeFixContext context, TypeDeclaratio
var name = context.Diagnostics.First().Properties["Name"]!;

var attributes = typeDecl.AttributeLists.Add(
SyntaxFactory.AttributeList(SyntaxFactory.SingletonSeparatedList(CreateDependsOnAttribute(name, syntaxTree)))
SyntaxFactory.AttributeList(SyntaxFactory.SingletonSeparatedList(CreateDependsOnAttribute(name, syntaxTree!)))
.WithTrailingTrivia(SyntaxFactory.ElasticCarriageReturnLineFeed)
.NormalizeWhitespace());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ public async Task Empty_Source()
[TestMethod]
public async Task Good_Source()
{
var test = @"";

await VerifyCS.VerifyAnalyzerAsync(FixedModuleSource);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,24 @@ public Test()
{
var project = solution.GetProject(projectId);

if (project is null)
{
return solution;
}

var compilationOptions = project.CompilationOptions;

if (compilationOptions is null)
{
return solution;
}

var parseOptions = project.ParseOptions as CSharpParseOptions;

if (parseOptions is null)
{
return solution;
}

compilationOptions = compilationOptions.WithSpecificDiagnosticOptions(compilationOptions.SpecificDiagnosticOptions.SetItems(CSharpVerifierHelper.NullableWarnings));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,25 @@ public Test()
{
var project = solution.GetProject(projectId);

if (project is null)
{
return solution;
}

var compilationOptions = project.CompilationOptions;

if (compilationOptions is null)
{
return solution;
}

var parseOptions = project.ParseOptions as CSharpParseOptions;

if (parseOptions is null)
{
return solution;
}

compilationOptions = compilationOptions.WithSpecificDiagnosticOptions(compilationOptions.SpecificDiagnosticOptions.SetItems(CSharpVerifierHelper.NullableWarnings));

solution = solution.WithProjectCompilationOptions(projectId, compilationOptions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,24 @@ public Test()
{
var project = solution.GetProject(projectId);

if (project is null)
{
return solution;
}

var compilationOptions = project.CompilationOptions;

if (compilationOptions is null)
{
return solution;
}

var parseOptions = project.ParseOptions as CSharpParseOptions;

if (parseOptions is null)
{
return solution;
}

compilationOptions = compilationOptions.WithSpecificDiagnosticOptions(compilationOptions.SpecificDiagnosticOptions.SetItems(CSharpVerifierHelper.NullableWarnings));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private void AnalyzeMissingDependsOnAttributes(SyntaxNodeAnalysisContext context

if (!attributes.Any(x => IsDependsOnAttributeFor(x, namedTypeSymbol)))
{
var properties = new Dictionary<string, string>
var properties = new Dictionary<string, string?>
{
["Name"] = namedTypeSymbol.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat)
}.ToImmutableDictionary();
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="AnalyzerDescription" xml:space="preserve">
<value>Missing DependsOn Attribute</value>
<value>Missing DependsOn Attribute.</value>
<comment>An optional longer localizable description of the diagnostic.</comment>
</data>
<data name="AnalyzerMessageFormat" xml:space="preserve">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public static void RegisterAzurePipelineContext()

public static IServiceCollection RegisterAzurePipelineContext(this IServiceCollection services)
{
services.TryAddSingleton<IAzurePipeline, AzurePipeline>();
services.TryAddSingleton<AzurePipelineVariables>();
services.TryAddSingleton<AzurePipelineAgentVariables>();
services.TryAddTransient<IAzurePipeline, AzurePipeline>();
services.TryAddTransient<AzurePipelineVariables>();
services.TryAddTransient<AzurePipelineAgentVariables>();
return services;
}

Expand Down
1 change: 1 addition & 0 deletions ModularPipelines.Build/Modules/PackProjectsModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ await context.DotNet().Build(new DotNetOptions
{
TargetPath = projectFile.Path,
Configuration = Configuration.Release,
LogOutput = false
}, cancellationToken);

results.Add(await context.DotNet().Pack(new DotNetOptions
Expand Down
2 changes: 1 addition & 1 deletion ModularPipelines.Cmd/Extensions/CmdExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static void RegisterCmdContext()

public static IServiceCollection RegisterCmdContext(this IServiceCollection services)
{
services.TryAddSingleton<ICmd, Cmd>();
services.TryAddTransient<ICmd, Cmd>();

return services;
}
Expand Down
4 changes: 2 additions & 2 deletions ModularPipelines.DotNet/Extensions/DotNetExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public static void RegisterDotNetContext()

public static IServiceCollection RegisterDotNetContext(this IServiceCollection services)
{
services.TryAddSingleton<IDotNet, DotNet>();
services.TryAddSingleton<ITrxParser, TrxParser>();
services.TryAddTransient<IDotNet, DotNet>();
services.TryAddTransient<ITrxParser, TrxParser>();
return services;
}

Expand Down
24 changes: 12 additions & 12 deletions ModularPipelines.DotNet/UnitTestResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,38 @@ namespace ModularPipelines.DotNet;
public record UnitTestResult
{
[XmlAttribute("executionId")]
public string ExecutionId { get; init; }
public string? ExecutionId { get; init; }

[XmlAttribute("testId")]
public string TestId { get; init; }
public string? TestId { get; init; }

[XmlAttribute("testName")]
public string TestName { get; init; }
public string? TestName { get; init; }

[XmlAttribute("computerName")]
public string ComputerName { get; init; }
public string? ComputerName { get; init; }

[XmlAttribute("duration")]
public string Duration { get; init; }
public string? Duration { get; init; }

[XmlAttribute("startTime")]
public string StartTime { get; init; }
public string? StartTime { get; init; }

[XmlAttribute("endTime")]
public string EndTime { get; init; }
public string? EndTime { get; init; }

[XmlAttribute("testType")]
public string TestType { get; init; }
public string? TestType { get; init; }

[XmlAttribute("outcome")]
public string Outcome { get; init; }
public string? Outcome { get; init; }

[XmlAttribute("testListId")]
public string TestListId { get; init; }
public string? TestListId { get; init; }

[XmlAttribute("relativeResultsDirectory")]
public string RelativeResultsDirectory { get; init; }
public string? RelativeResultsDirectory { get; init; }

[XmlElement("Output")]
public TestOutput Output { get; init; }
public TestOutput? Output { get; init; }
}
10 changes: 5 additions & 5 deletions ModularPipelines.Git/Extensions/GitExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ public static void RegisterGitContext()

public static IServiceCollection RegisterGitContext(this IServiceCollection services)
{
services.TryAddSingleton<IGit, Git>();
services.TryAddSingleton<IGitOperations, GitOperations>();
services.TryAddSingleton<IGitInformation, GitInformation>();
services.TryAddTransient<IGit, Git>();
services.TryAddTransient<IGitOperations, GitOperations>();
services.TryAddTransient<IGitInformation, GitInformation>();
services.TryAddSingleton<StaticGitInformation>();
services.TryAddSingleton<GitCommandRunner>();
services.TryAddSingleton<IGitCommitMapper, GitCommitMapper>();
services.TryAddTransient<GitCommandRunner>();
services.TryAddTransient<IGitCommitMapper, GitCommitMapper>();
return services;
}

Expand Down
16 changes: 6 additions & 10 deletions ModularPipelines.Git/GitInformation.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Runtime.CompilerServices;
using ModularPipelines.Context;
using ModularPipelines.Git.Models;
using ModularPipelines.Git.Options;

Expand All @@ -10,32 +9,29 @@ internal class GitInformation : IGitInformation
private readonly StaticGitInformation _staticGitInformation;
private readonly GitCommandRunner _gitCommandRunner;
private readonly IGitCommitMapper _gitCommitMapper;
private readonly IModuleContext _context;

public GitInformation(StaticGitInformation staticGitInformation,
GitCommandRunner gitCommandRunner,
IGitCommitMapper gitCommitMapper,
IModuleContext context)
IGitCommitMapper gitCommitMapper)
{
_staticGitInformation = staticGitInformation;
_gitCommandRunner = gitCommandRunner;
_gitCommitMapper = gitCommitMapper;
_context = context;
}

public string BranchName => _staticGitInformation.BranchName;
public string DefaultBranchName => _staticGitInformation.DefaultBranchName;
public string? BranchName => _staticGitInformation.BranchName;
public string? DefaultBranchName => _staticGitInformation.DefaultBranchName;

public string Tag => _staticGitInformation.Tag;
public string? Tag => _staticGitInformation.Tag;

public GitCommit? PreviousCommit => _staticGitInformation.PreviousCommit;

public int CommitsOnBranch => _staticGitInformation.CommitsOnBranch;
public DateTimeOffset LastCommitDateTime => _staticGitInformation.LastCommitDateTime;

public string LastCommitSha => _staticGitInformation.LastCommitSha;
public string? LastCommitSha => _staticGitInformation.LastCommitSha;

public string LastCommitShortSha => _staticGitInformation.LastCommitShortSha;
public string? LastCommitShortSha => _staticGitInformation.LastCommitShortSha;


public IAsyncEnumerable<GitCommit> Commits(GitOptions? options = null, CancellationToken cancellationToken = default)
Expand Down
4 changes: 2 additions & 2 deletions ModularPipelines.Git/Models/GitAuthor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public record GitAuthor
{
public string Name { get; set; }
public string Email { get; set; }
public string? Name { get; set; }
public string? Email { get; set; }
public DateTime Date { get; set; }
}
8 changes: 4 additions & 4 deletions ModularPipelines.Git/Models/GitCommit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

public record GitCommit
{
public GitHash Hash { get; set; }
public GitAuthor Author { get; set; }
public GitAuthor Committer { get; set; }
public GitMessage Message { get; set; }
public GitHash? Hash { get; set; }
public GitAuthor? Author { get; set; }
public GitAuthor? Committer { get; set; }
public GitMessage? Message { get; set; }
}
4 changes: 2 additions & 2 deletions ModularPipelines.Git/Models/GitFileStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

public record GitFileStatus
{
public string Status { get; set; }
public string File { get; set; }
public string? Status { get; set; }
public string? File { get; set; }
}
4 changes: 2 additions & 2 deletions ModularPipelines.Git/Models/GitHash.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

public record GitHash
{
public string Long { get; set; }
public string Short { get; set; }
public string? Long { get; set; }
public string? Short { get; set; }
}
4 changes: 2 additions & 2 deletions ModularPipelines.Git/Models/GitMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

public record GitMessage
{
public string Subject { get; set; }
public string Body { get; set; }
public string? Subject { get; set; }
public string? Body { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static void RegisterMicrosoftTeamsContext()

public static IServiceCollection RegisterMicrosoftTeamsContext(this IServiceCollection services)
{
services.TryAddSingleton<IMicrosoftTeams, MicrosoftTeams>();
services.TryAddTransient<IMicrosoftTeams, MicrosoftTeams>();
return services;
}

Expand Down
6 changes: 3 additions & 3 deletions ModularPipelines.Node/Extensions/NodeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public static void RegisterNodeContext()

public static IServiceCollection RegisterNodeContext(this IServiceCollection services)
{
services.TryAddSingleton<INode, Node>();
services.TryAddSingleton<INvm, Nvm>();
services.TryAddSingleton<INpm, Npm>();
services.TryAddTransient<INode, Node>();
services.TryAddTransient<INvm, Nvm>();
services.TryAddTransient<INpm, Npm>();
return services;
}

Expand Down
3 changes: 1 addition & 2 deletions ModularPipelines.Node/Models/NpmRunOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

namespace ModularPipelines.Node.Models;

public record NpmRunOptions : CommandEnvironmentOptions
public record NpmRunOptions(string Target) : CommandEnvironmentOptions
{
public string Target { get; init; }
public IEnumerable<string>? Arguments { get; init; }
}
2 changes: 1 addition & 1 deletion ModularPipelines.NuGet/Extensions/NuGetExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static IServiceCollection RegisterNuGetContext(this IServiceCollection se
{
services.RegisterDotNetContext();

services.TryAddSingleton<INuGet, NuGet>();
services.TryAddTransient<INuGet, NuGet>();

return services;
}
Expand Down
Loading