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
8 changes: 6 additions & 2 deletions src/Mocha/src/Mocha.Abstractions/DeclarationLocation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@ namespace Mocha;
/// the entire declaration from its start to its end.
/// </summary>
/// <param name="File">
/// The source file path, relative to the project directory using forward slashes,
/// or the file name alone when a project-relative path is not available.
/// Name of the declaring source file.
/// </param>
/// <param name="Directory">
/// Directory of the declaring source file relative to the repository root, empty when the file is
/// at the repository root, or null when the build does not provide source root information.
/// </param>
/// <param name="StartLine">The 1-based line number where the declaration starts.</param>
/// <param name="StartColumn">The 1-based column number where the declaration starts.</param>
/// <param name="EndLine">The 1-based line number where the declaration ends.</param>
/// <param name="EndColumn">The 1-based column number where the declaration ends.</param>
public sealed record DeclarationLocation(
string File,
string? Directory,
int StartLine,
int StartColumn,
Comment on lines 19 to 23
int EndLine,
Expand Down
6 changes: 3 additions & 3 deletions src/Mocha/src/Mocha.Analyzers/MediatorGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,14 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
static (options, _) =>
{
options.GlobalOptions.TryGetValue("build_property.MochaEmitSourceMetadata", out var emit);
options.GlobalOptions.TryGetValue("build_property.ProjectDir", out var projectDir);
options.GlobalOptions.TryGetValue("build_property.RepositoryUrl", out var repositoryUrl);
options.GlobalOptions.TryGetValue("build_property.SourceRevisionId", out var commit);
options.GlobalOptions.TryGetValue("build_property._MochaSourceRoots", out var sourceRoots);
return new SourceMetadataOptionsInfo(
!string.Equals(emit, "false", StringComparison.OrdinalIgnoreCase),
string.IsNullOrWhiteSpace(projectDir) ? null : projectDir,
string.IsNullOrWhiteSpace(repositoryUrl) ? null : repositoryUrl,
string.IsNullOrWhiteSpace(commit) ? null : commit);
string.IsNullOrWhiteSpace(commit) ? null : commit,
string.IsNullOrWhiteSpace(sourceRoots) ? null : sourceRoots);
});

context.RegisterSourceOutput(
Expand Down
6 changes: 3 additions & 3 deletions src/Mocha/src/Mocha.Analyzers/MessagingGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,14 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
var sourceMetadataOptions = context.AnalyzerConfigOptionsProvider.Select(static (options, _) =>
{
options.GlobalOptions.TryGetValue("build_property.MochaEmitSourceMetadata", out var emit);
options.GlobalOptions.TryGetValue("build_property.ProjectDir", out var projectDir);
options.GlobalOptions.TryGetValue("build_property.RepositoryUrl", out var repositoryUrl);
options.GlobalOptions.TryGetValue("build_property.SourceRevisionId", out var commit);
options.GlobalOptions.TryGetValue("build_property._MochaSourceRoots", out var sourceRoots);
return new SourceMetadataOptionsInfo(
!string.Equals(emit, "false", StringComparison.OrdinalIgnoreCase),
string.IsNullOrWhiteSpace(projectDir) ? null : projectDir,
string.IsNullOrWhiteSpace(repositoryUrl) ? null : repositoryUrl,
string.IsNullOrWhiteSpace(commit) ? null : commit);
string.IsNullOrWhiteSpace(commit) ? null : commit,
string.IsNullOrWhiteSpace(sourceRoots) ? null : sourceRoots);
});

var jsonSerializableInfos = context
Expand Down
1 change: 1 addition & 0 deletions src/Mocha/src/Mocha.Analyzers/Mocha.Analyzers.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@

<ItemGroup>
<None Include="buildTransitive\Mocha.Analyzers.props" Pack="true" PackagePath="buildTransitive" Visible="false" />
<None Include="buildTransitive\Mocha.Analyzers.targets" Pack="true" PackagePath="buildTransitive" Visible="false" />
</ItemGroup>
</Project>
21 changes: 11 additions & 10 deletions src/Mocha/src/Mocha.Analyzers/Models/SourceMetadataOptionsInfo.cs
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
namespace Mocha.Analyzers;

/// <summary>
/// Carries the evaluated <c>MochaEmitSourceMetadata</c>, <c>ProjectDir</c>, <c>RepositoryUrl</c>,
/// and <c>SourceRevisionId</c> MSBuild properties to source generators.
/// Carries the evaluated <c>MochaEmitSourceMetadata</c>, <c>RepositoryUrl</c>,
/// <c>SourceRevisionId</c>, and <c>_MochaSourceRoots</c> MSBuild properties to source generators.
/// </summary>
/// <param name="Emit">
/// A value indicating whether <c>SourceMetadata</c> assignments are emitted into generated
/// registration code.
/// </param>
/// <param name="ProjectDir">
/// The MSBuild project directory used to relativize declaration file paths, or <see langword="null"/>
/// when unavailable.
/// </param>
/// <param name="RepositoryUrl">
/// The source repository URL supplied by the build, or <see langword="null"/> when unavailable.
/// </param>
/// <param name="Commit">
/// The commit identifier supplied by the build, or <see langword="null"/> when unavailable.
/// </param>
/// <param name="SourceRoots">
/// The flattened SourceLink source roots supplied by the build as a single string, or
/// <see langword="null"/> when unavailable. Each record is
/// <c>Identity&gt;MappedPath&gt;SourceControl</c> and records are separated by <c>|</c>.
/// </param>
public sealed record SourceMetadataOptionsInfo(
bool Emit,
string? ProjectDir,
string? RepositoryUrl,
string? Commit) : SyntaxInfo
string? Commit,
string? SourceRoots) : SyntaxInfo
{
/// <summary>
/// Gets the default options: metadata emission enabled and no project directory, repository URL,
/// or commit available.
/// Gets the default options: metadata emission enabled and no repository URL, commit, or source
/// roots available.
/// </summary>
public static SourceMetadataOptionsInfo Default { get; } = new(true, null, null, null);

Expand Down
Loading
Loading