Compare commits

...

2 Commits

Author SHA1 Message Date
Anna 5e7c5e253e
chore: bump version to 1.1.1 2022-01-13 00:54:01 -05:00
Anna 738ab0c3bc
fix: allow actually specifying fallibility 2022-01-13 00:53:41 -05:00
4 changed files with 32 additions and 3 deletions

22
Siggingway/Fallibility.cs Executable file
View File

@ -0,0 +1,22 @@
namespace Siggingway;
/// <summary>
/// The fallibility of a signature.
/// </summary>
public enum Fallibility {
/// <summary>
/// The fallibility of the signature is determined by the field/property's
/// nullability.
/// </summary>
Auto,
/// <summary>
/// The signature is fallible.
/// </summary>
Fallible,
/// <summary>
/// The signature is infallible.
/// </summary>
Infallible,
}

View File

@ -35,7 +35,14 @@ public static class Siggingway {
wasWrapped = true;
}
var fallible = sig!.Fallible ?? info.IsNullable || wasWrapped;
var fallibility = sig!.Fallibility;
if (fallibility == Fallibility.Auto) {
fallibility = info.IsNullable || wasWrapped
? Fallibility.Fallible
: Fallibility.Infallible;
}
var fallible = fallibility == Fallibility.Fallible;
void Invalid(string message, bool prepend = true) {
var errorMsg = prepend

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>1.1.0</Version>
<Version>1.1.1</Version>
<TargetFramework>net5.0-windows</TargetFramework>
<LangVersion>preview</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>

View File

@ -53,7 +53,7 @@ public sealed class SignatureAttribute : Attribute {
/// exceptions instead. If fallibility is not specified, it is inferred
/// based on if the field/property is nullable.
/// </summary>
public bool? Fallible;
public Fallibility Fallibility = Fallibility.Auto;
/// <summary>
/// Create a <see cref="SignatureAttribute"/> with the given signature.