Compare commits
2 Commits
fd96155290
...
5e7c5e253e
Author | SHA1 | Date |
---|---|---|
Anna | 5e7c5e253e | |
Anna | 738ab0c3bc |
|
@ -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,
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue