Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Paquette committed Oct 9, 2023
1 parent 9d273d6 commit 98f18ec
Show file tree
Hide file tree
Showing 27 changed files with 115 additions and 111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private static IReadOnlyList<EmittableType> GetEmittableTypes(SyntaxTree syntaxT
var context = new ParserContextFixture().WithSyntaxTrees(syntaxTree).Create();
return Parser.GetEmittableTypesAndDiagnosticsForClass(context.ClassDeclarationSyntax, context.SemanticModel,
CancellationToken.None)
.Where(x => x.Diagnostic is not null)
.Where(x => x.EmittableType is not null)
.Select(x => x.EmittableType!)
.ToList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,14 @@ public static bool TryFrom(string value, out Code? typelyType, out ValidationErr
return isValid;
}

public static bool TryParse(string? value, out Code? valueObject) =>
public static bool TryParse(string? value, out Code valueObject) =>
TryParse(value, null, out valueObject);

public static bool TryParse(string? value, IFormatProvider? provider, out Code? valueObject)
public static bool TryParse(string? value, IFormatProvider? provider, out Code valueObject)
{
if(value is null)
{
valueObject = null;
valueObject = default!;
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ public static bool TryFrom(string value, out UserId? typelyType, out ValidationE
return isValid;
}

public static bool TryParse(string? value, out UserId? valueObject) =>
public static bool TryParse(string? value, out UserId valueObject) =>
TryParse(value, null, out valueObject);

public static bool TryParse(string? value, IFormatProvider? provider, out UserId? valueObject)
public static bool TryParse(string? value, IFormatProvider? provider, out UserId valueObject)
{
if(value is null)
{
valueObject = null;
valueObject = default!;
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public Votes(TimeSpan value)
});
}

if (!(value == new TimeSpan(2022,1,1)))
if (!(value == new TimeSpan(2022, 1, 1)))
{
return ValidationErrorFactory.Create(value, "Must", ErrorMessages.Must, "Presidency vote");
}
Expand All @@ -51,39 +51,39 @@ public Votes(TimeSpan value)
return ValidationErrorFactory.Create(value, "Must", ErrorMessages.Must, "Presidency vote");
}

if (value <= new TimeSpan(2022,1,1))
if (value <= new TimeSpan(2022, 1, 1))
{
return ValidationErrorFactory.Create(value, "GreaterThan", LocalizedMessages.CustomMessage, "Presidency vote",
new Dictionary<string, object?>
{
{ "ComparisonValue", new TimeSpan(2022,1,1) },
{ "ComparisonValue", new TimeSpan(2022, 1, 1) },
});
}

if (value < new TimeSpan(2022,1,1))
if (value < new TimeSpan(2022, 1, 1))
{
return ValidationErrorFactory.Create(value, "GreaterThanOrEqualTo", A.CustomLocalization.Value, "Presidency vote",
new Dictionary<string, object?>
{
{ "ComparisonValue", new TimeSpan(2022,1,1) },
{ "ComparisonValue", new TimeSpan(2022, 1, 1) },
});
}

if (value >= new TimeSpan(2022,1,1))
if (value >= new TimeSpan(2022, 1, 1))
{
return ValidationErrorFactory.Create(value, "LessThan", ErrorMessages.LessThan, "Presidency vote",
new Dictionary<string, object?>
{
{ "ComparisonValue", new TimeSpan(2022,1,1) },
{ "ComparisonValue", new TimeSpan(2022, 1, 1) },
});
}

if (value > new TimeSpan(2022,1,1))
if (value > new TimeSpan(2022, 1, 1))
{
return ValidationErrorFactory.Create(value, "LessThanOrEqualTo", ErrorMessages.LessThanOrEqualTo, "Presidency vote",
new Dictionary<string, object?>
{
{ "ComparisonValue", new TimeSpan(2022,1,1) },
{ "ComparisonValue", new TimeSpan(2022, 1, 1) },
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ public static bool TryFrom(ulong value, out Votes typelyType, out ValidationErro
return isValid;
}

public static bool TryParse(string? value, out Votes? valueObject) =>
public static bool TryParse(string? value, out Votes valueObject) =>
TryParse(value, null, out valueObject);

public static bool TryParse(string? value, IFormatProvider? provider, out Votes? valueObject)
public static bool TryParse(string? value, IFormatProvider? provider, out Votes valueObject)
{
if(ulong.TryParse(value, out var underlyingValue))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public void Create(ITypelyBuilder builder)
.WithNamespace("Election")
.NotEmpty().WithMessage("The value cannot be empty").WithErrorCode("ERR-001")
.AsFactory();

var vote = factory
.For("Votes")
.WithName("Presidency vote")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public void Create(ITypelyBuilder builder)
.WithNamespace("Election")
.NotEmpty().WithMessage("The value cannot be empty").WithErrorCode("ERR-001")
.AsFactory();

var vote = factory
.For("Votes")
.WithName("Presidency vote")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public void Create(ITypelyBuilder builder)
.WithNamespace("Election")
.NotEmpty().WithMessage("The value cannot be empty").WithErrorCode("ERR-001")
.AsFactory();

var vote = factory
.For("Votes")
.WithName("Presidency vote")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ public void Create(ITypelyBuilder builder)
.WithNamespace("Election")
.NotEmpty().WithMessage("The value cannot be empty").WithErrorCode("ERR-001")
.AsFactory();

var vote = factory
.For("Votes")
.WithName("Presidency vote")
.NotEqual(new DateOnly(2021, 1, 1));

vote.Must(x => x == new DateOnly(2022,1,1))
vote.Must(x => x == new DateOnly(2022, 1, 1))
.Must((x) => !x.Equals(10))
.GreaterThan(new DateOnly(2022,1,1)).WithMessage(() => LocalizedMessages.CustomMessage)
.GreaterThanOrEqualTo(new DateOnly(2022,1,1)).WithMessage(() => A.CustomLocalization.Value)
.LessThan(new DateOnly(2022,1,1))
.LessThanOrEqualTo(new DateOnly(2022,1,1));
.GreaterThan(new DateOnly(2022, 1, 1)).WithMessage(() => LocalizedMessages.CustomMessage)
.GreaterThanOrEqualTo(new DateOnly(2022, 1, 1)).WithMessage(() => A.CustomLocalization.Value)
.LessThan(new DateOnly(2022, 1, 1))
.LessThanOrEqualTo(new DateOnly(2022, 1, 1));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,19 @@ public void Create(ITypelyBuilder builder)
.WithNamespace("Election")
.NotEmpty().WithMessage("The value cannot be empty").WithErrorCode("ERR-001")
.AsFactory();

var vote = factory
.For("Votes")
.WithName("Presidency vote")
.NotEqual(new DateTimeOffset(new DateTime(2022,1,1)));
.NotEqual(new DateTimeOffset(new DateTime(2022, 1, 1)));

vote.Must(x => x == new DateTimeOffset(new DateTime(2022,1,1)))
vote.Must(x => x == new DateTimeOffset(new DateTime(2022, 1, 1)))
.Must((x) => !x.Equals(10))
.GreaterThan(new DateTimeOffset(new DateTime(2022,1,1))).WithMessage(() => LocalizedMessages.CustomMessage)
.GreaterThanOrEqualTo(new DateTimeOffset(new DateTime(2022,1,1))).WithMessage(() => A.CustomLocalization.Value)
.LessThan(new DateTimeOffset(new DateTime(2022,1,1)))
.LessThanOrEqualTo(new DateTimeOffset(new DateTime(2022,1,1)));
.GreaterThan(new DateTimeOffset(new DateTime(2022, 1, 1)))
.WithMessage(() => LocalizedMessages.CustomMessage)
.GreaterThanOrEqualTo(new DateTimeOffset(new DateTime(2022, 1, 1)))
.WithMessage(() => A.CustomLocalization.Value)
.LessThan(new DateTimeOffset(new DateTime(2022, 1, 1)))
.LessThanOrEqualTo(new DateTimeOffset(new DateTime(2022, 1, 1)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ public void Create(ITypelyBuilder builder)
.WithNamespace("Election")
.NotEmpty().WithMessage("The value cannot be empty").WithErrorCode("ERR-001")
.AsFactory();

var vote = factory
.For("Votes")
.WithName("Presidency vote")
.NotEqual(new DateTime(2021, 1, 1));

vote.Must(x => x == new DateTime(2022,1,1))
vote.Must(x => x == new DateTime(2022, 1, 1))
.Must((x) => !x.Equals(10))
.GreaterThan(new DateTime(2022,1,1)).WithMessage(() => LocalizedMessages.CustomMessage)
.GreaterThanOrEqualTo(new DateTime(2022,1,1)).WithMessage(() => A.CustomLocalization.Value)
.LessThan(new DateTime(2022,1,1))
.LessThanOrEqualTo(new DateTime(2022,1,1));
.GreaterThan(new DateTime(2022, 1, 1)).WithMessage(() => LocalizedMessages.CustomMessage)
.GreaterThanOrEqualTo(new DateTime(2022, 1, 1)).WithMessage(() => A.CustomLocalization.Value)
.LessThan(new DateTime(2022, 1, 1))
.LessThanOrEqualTo(new DateTime(2022, 1, 1));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public void Create(ITypelyBuilder builder)
.WithNamespace("Election")
.NotEmpty().WithMessage("The value cannot be empty").WithErrorCode("ERR-001")
.AsFactory();

var vote = factory
.For("Votes")
.WithName("Presidency vote")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ internal class DiagnosticsSpecification : ITypelySpecification
public void Create(ITypelyBuilder builder)
{
builder.OfString().For("Unsupported").UnsupportedExtension();

CreateTypeFromUnsupportedCall(builder);

var unsupported = CreateTypeFromUnsupportedCall(builder);
unsupported.NotEmpty();

builder.OfString().For("ShouldGenerate");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public void Create(ITypelyBuilder builder)
.WithNamespace("Election")
.NotEmpty().WithMessage("The value cannot be empty").WithErrorCode("ERR-001")
.AsFactory();

var vote = factory
.For("Votes")
.WithName("Presidency vote")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public void Create(ITypelyBuilder builder)
.WithNamespace("Election")
.NotEmpty().WithMessage("The value cannot be empty").WithErrorCode("ERR-001")
.AsFactory();

var vote = factory
.For("Votes")
.WithName("Presidency vote")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@ public void Create(ITypelyBuilder builder)
.WithNamespace("Election")
.NotEmpty().WithMessage("The value cannot be empty").WithErrorCode("ERR-001")
.AsFactory();

var vote = factory
.For("Votes")
.WithName("Presidency vote")
.NotEqual(Guid.Empty);

vote.Must(x => x == Guid.Parse("bf820b37-c090-4d51-8a69-07db3d2f42ea"))
.Must((x) => !x.Equals(10))
.GreaterThan(Guid.Parse("bf820b37-c090-4d51-8a69-07db3d2f42ea")).WithMessage(() => LocalizedMessages.CustomMessage)
.GreaterThanOrEqualTo(Guid.Parse("bf820b37-c090-4d51-8a69-07db3d2f42ea")).WithMessage(() => A.CustomLocalization.Value)
.GreaterThan(Guid.Parse("bf820b37-c090-4d51-8a69-07db3d2f42ea"))
.WithMessage(() => LocalizedMessages.CustomMessage)
.GreaterThanOrEqualTo(Guid.Parse("bf820b37-c090-4d51-8a69-07db3d2f42ea"))
.WithMessage(() => A.CustomLocalization.Value)
.LessThan(Guid.Parse("bf820b37-c090-4d51-8a69-07db3d2f42ea"))
.LessThanOrEqualTo(Guid.Parse("bf820b37-c090-4d51-8a69-07db3d2f42ea"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public void Create(ITypelyBuilder builder)
.WithNamespace("Election")
.NotEmpty().WithMessage("The value cannot be empty").WithErrorCode("ERR-001")
.AsFactory();

var vote = factory
.For("Votes")
.WithName("Presidency vote")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public void Create(ITypelyBuilder builder)
.WithNamespace("Election")
.NotEmpty().WithMessage("The value cannot be empty").WithErrorCode("ERR-001")
.AsFactory();

var vote = factory
.For("Votes")
.WithName("Presidency vote")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public void Create(ITypelyBuilder builder)
.WithNamespace("Election")
.NotEmpty().WithMessage("The value cannot be empty").WithErrorCode("ERR-001")
.AsFactory();

var vote = factory
.For("Votes")
.WithName("Presidency vote")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public void Create(ITypelyBuilder builder)
.WithNamespace("Election")
.NotEmpty().WithMessage("The value cannot be empty").WithErrorCode("ERR-001")
.AsFactory();

var vote = factory
.For("Votes")
.WithName("Presidency vote")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ public void Create(ITypelyBuilder builder)
.WithNamespace("Election")
.NotEmpty().WithMessage("The value cannot be empty").WithErrorCode("ERR-001")
.AsFactory();

var vote = factory
.For("Votes")
.WithName("Presidency vote")
.NotEqual(new TimeOnly(2021, 1, 1));

vote.Must(x => x == new TimeOnly(2022,1,1))
vote.Must(x => x == new TimeOnly(2022, 1, 1))
.Must((x) => !x.Equals(10))
.GreaterThan(new TimeOnly(2022,1,1)).WithMessage(() => LocalizedMessages.CustomMessage)
.GreaterThanOrEqualTo(new TimeOnly(2022,1,1)).WithMessage(() => A.CustomLocalization.Value)
.LessThan(new TimeOnly(2022,1,1))
.LessThanOrEqualTo(new TimeOnly(2022,1,1));
.GreaterThan(new TimeOnly(2022, 1, 1)).WithMessage(() => LocalizedMessages.CustomMessage)
.GreaterThanOrEqualTo(new TimeOnly(2022, 1, 1)).WithMessage(() => A.CustomLocalization.Value)
.LessThan(new TimeOnly(2022, 1, 1))
.LessThanOrEqualTo(new TimeOnly(2022, 1, 1));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ public void Create(ITypelyBuilder builder)
.WithNamespace("Election")
.NotEmpty().WithMessage("The value cannot be empty").WithErrorCode("ERR-001")
.AsFactory();

var vote = factory
.For("Votes")
.WithName("Presidency vote")
.NotEqual(new TimeSpan(2021, 1, 1));

vote.Must(x => x == new TimeSpan(2022,1,1))
vote.Must(x => x == new TimeSpan(2022, 1, 1))
.Must((x) => !x.Equals(10))
.GreaterThan(new TimeSpan(2022,1,1)).WithMessage(() => LocalizedMessages.CustomMessage)
.GreaterThanOrEqualTo(new TimeSpan(2022,1,1)).WithMessage(() => A.CustomLocalization.Value)
.LessThan(new TimeSpan(2022,1,1))
.LessThanOrEqualTo(new TimeSpan(2022,1,1));
.GreaterThan(new TimeSpan(2022, 1, 1)).WithMessage(() => LocalizedMessages.CustomMessage)
.GreaterThanOrEqualTo(new TimeSpan(2022, 1, 1)).WithMessage(() => A.CustomLocalization.Value)
.LessThan(new TimeSpan(2022, 1, 1))
.LessThanOrEqualTo(new TimeSpan(2022, 1, 1));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public void Create(ITypelyBuilder builder)
.WithNamespace("Election")
.NotEmpty().WithMessage("The value cannot be empty").WithErrorCode("ERR-001")
.AsFactory();

var vote = factory
.For("Votes")
.WithName("Presidency vote")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public void Create(ITypelyBuilder builder)
.WithNamespace("Election")
.NotEmpty().WithMessage("The value cannot be empty").WithErrorCode("ERR-001")
.AsFactory();

var vote = factory
.For("Votes")
.WithName("Presidency vote")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public void Create(ITypelyBuilder builder)
.WithNamespace("Election")
.NotEmpty().WithMessage("The value cannot be empty").WithErrorCode("ERR-001")
.AsFactory();

var vote = factory
.For("Votes")
.WithName("Presidency vote")
Expand Down
Loading

0 comments on commit 98f18ec

Please sign in to comment.