-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
107 additions
and
378 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,6 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace AssemblyMetadata.Generators; | ||
|
||
[ExcludeFromCodeCoverage] | ||
public class AssemblyConstant : IEquatable<AssemblyConstant> | ||
{ | ||
public AssemblyConstant(string name, string value) | ||
{ | ||
Name = name; | ||
Value = value; | ||
} | ||
|
||
public string Name { get; } | ||
|
||
public string Value { get; } | ||
|
||
public bool Equals(AssemblyConstant other) | ||
{ | ||
if (ReferenceEquals(null, other)) | ||
return false; | ||
|
||
if (ReferenceEquals(this, other)) | ||
return true; | ||
|
||
return Name == other.Name | ||
&& Value == other.Value; | ||
} | ||
|
||
public override bool Equals(object value) => value is AssemblyConstant assemblyContant && Equals(assemblyContant); | ||
|
||
public override int GetHashCode() => HashCode.Seed.Combine(Name).Combine(Value); | ||
|
||
public static bool operator ==(AssemblyConstant left, AssemblyConstant right) => Equals(left, right); | ||
|
||
public static bool operator !=(AssemblyConstant left, AssemblyConstant right) => !Equals(left, right); | ||
|
||
public override string ToString() => $"Name: {Name}; Value: {Value}"; | ||
} | ||
public record AssemblyConstant( | ||
string Name, | ||
string Value | ||
); |
3 changes: 3 additions & 0 deletions
3
src/AssemblyMetadata.Generators/AssemblyMetadata.Generators.targets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
<Project> | ||
<ItemGroup> | ||
<CompilerVisibleProperty Include="AssemblyName" /> | ||
<CompilerVisibleProperty Include="DefineConstants" /> | ||
<CompilerVisibleProperty Include="RootNamespace" /> | ||
<CompilerVisibleProperty Include="ThisAssemblyNamespace" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,8 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
using Microsoft.CodeAnalysis; | ||
|
||
namespace AssemblyMetadata.Generators; | ||
|
||
[ExcludeFromCodeCoverage] | ||
public class GeneratorContext : IEquatable<GeneratorContext> | ||
{ | ||
public GeneratorContext(IEnumerable<Diagnostic> diagnostics, IEnumerable<AssemblyConstant> constants) | ||
{ | ||
Diagnostics = new EquatableArray<Diagnostic>(diagnostics); | ||
Constants = new EquatableArray<AssemblyConstant>(constants); | ||
} | ||
|
||
public EquatableArray<Diagnostic> Diagnostics { get; } | ||
|
||
public EquatableArray<AssemblyConstant> Constants { get; } | ||
|
||
public bool Equals(GeneratorContext other) | ||
{ | ||
if (ReferenceEquals(null, other)) | ||
return false; | ||
|
||
if (ReferenceEquals(this, other)) | ||
return true; | ||
|
||
return Diagnostics.Equals(other.Diagnostics) | ||
&& Constants.Equals(other.Constants); | ||
} | ||
|
||
public override bool Equals(object value) => value is GeneratorContext context && Equals(context); | ||
|
||
public override int GetHashCode() => HashCode.Seed.CombineAll(Diagnostics).CombineAll(Constants); | ||
|
||
public static bool operator ==(GeneratorContext left, GeneratorContext right) => Equals(left, right); | ||
|
||
public static bool operator !=(GeneratorContext left, GeneratorContext right) => !Equals(left, right); | ||
} | ||
public record GeneratorContext( | ||
EquatableArray<Diagnostic> Diagnostics, | ||
EquatableArray<AssemblyConstant> Constants | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace AssemblyMetadata.Generators; | ||
|
||
public record GlobalOptions( | ||
string? AssemblyName, | ||
string? DefineConstants, | ||
string? RootNamespace, | ||
string? ThisAssemblyNamespace | ||
); |
Oops, something went wrong.