Skip to content

Commit

Permalink
Some formatting and build fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Hathcock committed Sep 11, 2023
1 parent 735185e commit d3283ad
Show file tree
Hide file tree
Showing 78 changed files with 2,534 additions and 2,015 deletions.
8 changes: 4 additions & 4 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"version": 1,
"isRoot": true,
"tools": {
"dotnet-format": {
"version": "5.1.225507",
"csharpier": {
"version": "0.25.0",
"commands": [
"dotnet-format"
"dotnet-csharpier"
]
}
}
}
}
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ dotnet_diagnostic.CA1725.severity = suggestion
dotnet_diagnostic.CA1805.severity = suggestion
dotnet_diagnostic.CA1816.severity = suggestion
dotnet_diagnostic.CA1822.severity = suggestion
dotnet_diagnostic.CA1824.severity = none
dotnet_diagnostic.CA1825.severity = error
dotnet_diagnostic.CA1826.severity = silent
dotnet_diagnostic.CA1827.severity = error
Expand Down
41 changes: 26 additions & 15 deletions build/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
const string Format = "format";
const string Publish = "publish";

Target(Clean,
Target(
Clean,
ForEach("publish", "**/bin", "**/obj"),
dir =>
{
Expand All @@ -33,18 +34,23 @@ void RemoveDirectory(string d)
{
RemoveDirectory(d);
}
});
}
);


Target(Format, () =>
{
Run("dotnet", "tool restore");
Run("dotnet", "format --check");
});
Target(
Format,
() =>
{
Run("dotnet", "tool restore");
Run("dotnet", "format --check");
}
);

Target(Build, DependsOn(Format), () => Run("dotnet", "build . -c Release"));

Target(Test, DependsOn(Build),
Target(
Test,
DependsOn(Build),
() =>
{
IEnumerable<string> GetFiles(string d)
Expand All @@ -56,16 +62,21 @@ IEnumerable<string> GetFiles(string d)
{
Run("dotnet", $"test {file} -c Release --no-restore --no-build --verbosity=normal");
}
});
}
);

Target(Publish, DependsOn(Test),
Target(
Publish,
DependsOn(Test),
ForEach("src/Conduit"),
project =>
{
Run("dotnet",
$"publish {project} -c Release -f net5.0 -o ./publish --no-restore --no-build --verbosity=normal");
});
Run(
"dotnet",
$"publish {project} -c Release -f net5.0 -o ./publish --no-restore --no-build --verbosity=normal"
);
}
);

Target("default", DependsOn(Publish), () => Console.WriteLine("Done!"));
await RunTargetsAndExitAsync(args);

50 changes: 25 additions & 25 deletions src/Conduit/Domain/Article.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,42 @@
using System.Linq;
using System.Text.Json.Serialization;

namespace Conduit.Domain
namespace Conduit.Domain;

public class Article
{
public class Article
{
[JsonIgnore]
public int ArticleId { get; set; }
[JsonIgnore]
public int ArticleId { get; set; }

public string? Slug { get; set; }
public string? Slug { get; set; }

public string? Title { get; set; }
public string? Title { get; set; }

public string? Description { get; set; }
public string? Description { get; set; }

public string? Body { get; set; }
public string? Body { get; set; }

public Person? Author { get; set; }
public Person? Author { get; set; }

public List<Comment> Comments { get; set; } = new();
public List<Comment> Comments { get; set; } = new();

[NotMapped]
public bool Favorited => ArticleFavorites?.Any() ?? false;
[NotMapped]
public bool Favorited => ArticleFavorites?.Any() ?? false;

[NotMapped]
public int FavoritesCount => ArticleFavorites?.Count ?? 0;
[NotMapped]
public int FavoritesCount => ArticleFavorites?.Count ?? 0;

[NotMapped]
public List<string> TagList => ArticleTags.Where(x => x.TagId is not null).Select(x => x.TagId!).ToList();
[NotMapped]
public List<string> TagList =>
ArticleTags.Where(x => x.TagId is not null).Select(x => x.TagId!).ToList();

[JsonIgnore]
public List<ArticleTag> ArticleTags { get; set; } = new();
[JsonIgnore]
public List<ArticleTag> ArticleTags { get; set; } = new();

[JsonIgnore]
public List<ArticleFavorite> ArticleFavorites { get; set; } = new();
[JsonIgnore]
public List<ArticleFavorite> ArticleFavorites { get; set; } = new();

public DateTime CreatedAt { get; set; }
public DateTime CreatedAt { get; set; }

public DateTime UpdatedAt { get; set; }
}
}
public DateTime UpdatedAt { get; set; }
}
17 changes: 8 additions & 9 deletions src/Conduit/Domain/ArticleFavorite.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
namespace Conduit.Domain
namespace Conduit.Domain;

public class ArticleFavorite
{
public class ArticleFavorite
{
public int ArticleId { get; set; }
public Article? Article { get; set; }
public int ArticleId { get; set; }
public Article? Article { get; set; }

public int PersonId { get; set; }
public Person? Person { get; set; }
}
}
public int PersonId { get; set; }
public Person? Person { get; set; }
}
17 changes: 8 additions & 9 deletions src/Conduit/Domain/ArticleTag.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
namespace Conduit.Domain
namespace Conduit.Domain;

public class ArticleTag
{
public class ArticleTag
{
public int ArticleId { get; set; }
public Article? Article { get; set; }
public int ArticleId { get; set; }
public Article? Article { get; set; }

public string? TagId { get; set; }
public Tag? Tag { get; set; }
}
}
public string? TagId { get; set; }
public Tag? Tag { get; set; }
}
33 changes: 16 additions & 17 deletions src/Conduit/Domain/Comment.cs
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
using System;
using System.Text.Json.Serialization;

namespace Conduit.Domain
namespace Conduit.Domain;

public class Comment
{
public class Comment
{
[JsonPropertyName("id")]
public int CommentId { get; set; }
[JsonPropertyName("id")]
public int CommentId { get; set; }

public string? Body { get; set; }
public string? Body { get; set; }

public Person? Author { get; set; }
public Person? Author { get; set; }

[JsonIgnore]
public int AuthorId { get; set; }
[JsonIgnore]
public int AuthorId { get; set; }

[JsonIgnore]
public Article? Article { get; set; }
[JsonIgnore]
public Article? Article { get; set; }

[JsonIgnore]
public int ArticleId { get; set; }
[JsonIgnore]
public int ArticleId { get; set; }

public DateTime CreatedAt { get; set; }
public DateTime CreatedAt { get; set; }

public DateTime UpdatedAt { get; set; }
}
}
public DateTime UpdatedAt { get; set; }
}
17 changes: 8 additions & 9 deletions src/Conduit/Domain/FollowedPeople.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
namespace Conduit.Domain
namespace Conduit.Domain;

public class FollowedPeople
{
public class FollowedPeople
{
public int ObserverId { get; set; }
public Person? Observer { get; set; }
public int ObserverId { get; set; }
public Person? Observer { get; set; }

public int TargetId { get; set; }
public Person? Target { get; set; }
}
}
public int TargetId { get; set; }
public Person? Target { get; set; }
}
41 changes: 20 additions & 21 deletions src/Conduit/Domain/Person.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,33 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace Conduit.Domain
namespace Conduit.Domain;

public class Person
{
public class Person
{
[JsonIgnore]
public int PersonId { get; set; }
[JsonIgnore]
public int PersonId { get; set; }

public string? Username { get; set; }
public string? Username { get; set; }

public string? Email { get; set; }
public string? Email { get; set; }

public string? Bio { get; set; }
public string? Bio { get; set; }

public string? Image { get; set; }
public string? Image { get; set; }

[JsonIgnore]
public List<ArticleFavorite> ArticleFavorites { get; set; } = new();
[JsonIgnore]
public List<ArticleFavorite> ArticleFavorites { get; set; } = new();

[JsonIgnore]
public List<FollowedPeople> Following { get; set; } = new();
[JsonIgnore]
public List<FollowedPeople> Following { get; set; } = new();

[JsonIgnore]
public List<FollowedPeople> Followers { get; set; } = new();
[JsonIgnore]
public List<FollowedPeople> Followers { get; set; } = new();

[JsonIgnore]
public byte[] Hash { get; set; } = Array.Empty<byte>();
[JsonIgnore]
public byte[] Hash { get; set; } = Array.Empty<byte>();

[JsonIgnore]
public byte[] Salt { get; set; } = Array.Empty<byte>();
}
}
[JsonIgnore]
public byte[] Salt { get; set; } = Array.Empty<byte>();
}
13 changes: 6 additions & 7 deletions src/Conduit/Domain/Tag.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
using System.Collections.Generic;

namespace Conduit.Domain
namespace Conduit.Domain;

public class Tag
{
public class Tag
{
public string? TagId { get; set; }
public string? TagId { get; set; }

public List<ArticleTag> ArticleTags { get; set; } = new();
}
}
public List<ArticleTag> ArticleTags { get; set; } = new();
}
7 changes: 3 additions & 4 deletions src/Conduit/Features/Articles/ArticleEnvelope.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Conduit.Domain;

namespace Conduit.Features.Articles
{
public record ArticleEnvelope(Article Article);
}
namespace Conduit.Features.Articles;

public record ArticleEnvelope(Article Article);
18 changes: 9 additions & 9 deletions src/Conduit/Features/Articles/ArticleExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
using Conduit.Domain;
using Microsoft.EntityFrameworkCore;

namespace Conduit.Features.Articles
namespace Conduit.Features.Articles;

public static class ArticleExtensions
{
public static class ArticleExtensions
{
public static IQueryable<Article> GetAllData(this DbSet<Article> articles) => articles
.Include(x => x.Author)
.Include(x => x.ArticleFavorites)
.Include(x => x.ArticleTags)
.AsNoTracking();
}
public static IQueryable<Article> GetAllData(this DbSet<Article> articles) =>
articles
.Include(x => x.Author)
.Include(x => x.ArticleFavorites)
.Include(x => x.ArticleTags)
.AsNoTracking();
}
Loading

0 comments on commit d3283ad

Please sign in to comment.