-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### Added - Diagnostics for - replacing the default Build method - replacing the default constructor - a builder without the build method error - Possibility to replace default Build method
- Loading branch information
Showing
14 changed files
with
251 additions
and
53 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
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
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using Microsoft.CodeAnalysis; | ||
|
||
namespace Buildenator.Diagnostics; | ||
|
||
public sealed class BuildenatorDiagnostic | ||
{ | ||
public BuildenatorDiagnostic(DiagnosticDescriptor descriptor, Location location, params object?[]? messageArgs) | ||
{ | ||
Descriptor = descriptor; | ||
Location = location; | ||
MessageArgs = messageArgs; | ||
} | ||
|
||
public DiagnosticDescriptor Descriptor { get; } | ||
public Location Location { get; } | ||
public object?[]? MessageArgs { get; } | ||
|
||
public static implicit operator Diagnostic(BuildenatorDiagnostic buildenatorDiagnostic) | ||
=> Diagnostic.Create( | ||
buildenatorDiagnostic.Descriptor, | ||
buildenatorDiagnostic.Location, | ||
buildenatorDiagnostic.MessageArgs); | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
Buildenator/Diagnostics/BuildenatorDiagnosticDescriptors.cs
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,47 @@ | ||
using Buildenator.Configuration; | ||
using Microsoft.CodeAnalysis; | ||
|
||
namespace Buildenator.Diagnostics; | ||
|
||
internal static class BuildenatorDiagnosticDescriptors | ||
{ | ||
internal static readonly DiagnosticDescriptor AbstractDiagnostic = new( | ||
"BDN001", | ||
"Cannot generate a builder for an abstract class", | ||
"Cannot generate a builder for the {0} abstract class", | ||
"Buildenator", | ||
DiagnosticSeverity.Error, | ||
true); | ||
|
||
internal static readonly DiagnosticDescriptor NoPublicConstructorsDiagnostic = new( | ||
"BDN002", | ||
"Build method in the builder is missing for a class with no public constructor", | ||
"Cannot generate a \"public {0} " + DefaultConstants.BuildMethodName + "() {/* content */}\" method for the {0} class that does not have public constructor. You have to add it by yourself.", | ||
"Buildenator", | ||
DiagnosticSeverity.Error, | ||
true); | ||
|
||
internal static readonly DiagnosticDescriptor BuildMethodOverridenDiagnostic = new( | ||
"BDN003", | ||
"You overriden the default " + DefaultConstants.BuildMethodName + "() method", | ||
"You overriden the default " + DefaultConstants.BuildMethodName + "() method. if it's not on purpose, please remove it.", | ||
"Buildenator", | ||
DiagnosticSeverity.Info, | ||
true); | ||
|
||
internal static readonly DiagnosticDescriptor DefaultConstructorOverridenDiagnostic = new( | ||
"BDN004", | ||
"You overriden the default constructor method", | ||
"You overriden the default constructor method. If it's not on purpose, please remove it.", | ||
"Buildenator", | ||
DiagnosticSeverity.Info, | ||
true); | ||
|
||
internal static readonly DiagnosticDescriptor DefaultParametersSetupOverridenDiagnostic = new( | ||
"BDN005", | ||
"You overriden the default method for setting up properties", | ||
"You overriden the default method {0} for setting up properties. If it's not on purpose, please remove it.", | ||
"Buildenator", | ||
DiagnosticSeverity.Info, | ||
true); | ||
} |
Oops, something went wrong.