-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update Draco.ProjectSystem.csproj * Restore added * Minor fixes * Update Draco.LanguageServer.csproj
- Loading branch information
1 parent
1133427
commit e42ac24
Showing
7 changed files
with
143 additions
and
58 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace Draco.ProjectSystem; | ||
|
||
/// <summary> | ||
/// Factory for creating build results. | ||
/// </summary> | ||
internal static class BuildResult | ||
{ | ||
/// <summary> | ||
/// Creates a successful build result. | ||
/// </summary> | ||
/// <typeparam name="T">The result type of a successful build.</typeparam> | ||
/// <param name="value">The result of the build.</param> | ||
/// <param name="log">The log of the build.</param> | ||
/// <returns>A successful build result.</returns> | ||
public static BuildResult<T> Success<T>(T value, string? log = null) => new(true, value, log); | ||
|
||
/// <summary> | ||
/// Creates a failed build result. | ||
/// </summary> | ||
/// <typeparam name="T">The result type of a successful build.</typeparam> | ||
/// <param name="log">The log of the build.</param> | ||
/// <returns>A failed build result.</returns> | ||
public static BuildResult<T> Failure<T>(string? log = null) => new(false, default, log); | ||
} | ||
|
||
/// <summary> | ||
/// The result of a build. | ||
/// </summary> | ||
/// <typeparam name="T">The result type of a successful build.</typeparam> | ||
public readonly struct BuildResult<T>(bool success, T? value, string? log = null) | ||
{ | ||
/// <summary> | ||
/// True, if the build succeeded. | ||
/// </summary> | ||
[MemberNotNullWhen(true, nameof(Value))] | ||
public bool Success { get; } = success; | ||
|
||
/// <summary> | ||
/// The result of the build. | ||
/// </summary> | ||
public T? Value { get; } = value; | ||
|
||
/// <summary> | ||
/// The log of the build. | ||
/// </summary> | ||
public string Log { get; } = log ?? string.Empty; | ||
} |
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,12 @@ | ||
namespace Draco.ProjectSystem; | ||
|
||
/// <summary> | ||
/// A unit type representing the absence of a value. | ||
/// </summary> | ||
public readonly record struct Unit | ||
{ | ||
/// <summary> | ||
/// A default instance of the unit type. | ||
/// </summary> | ||
public static readonly Unit Default = default; | ||
} |