Skip to content
This repository has been archived by the owner on Apr 8, 2023. It is now read-only.

Commit

Permalink
Contain nullable reference warnings
Browse files Browse the repository at this point in the history
Revert serilog sink to email as its broken
  • Loading branch information
benjaminsampica committed Jul 1, 2022
1 parent 0ba895b commit ea2a9b7
Show file tree
Hide file tree
Showing 19 changed files with 74 additions and 79 deletions.
1 change: 0 additions & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ jobs:
env:
ConnectionStrings.DefaultConnection: ${{ secrets.connectionstring }}
Email.Password: ${{ secrets.email_password }}
Email.AdminEmail: ${{ secrets.admin_email }}
- name: Create app_offline file
if: startsWith(github.ref, 'refs/tags/v')
shell: pwsh
Expand Down
2 changes: 1 addition & 1 deletion src/Server/DynamoLeagueBlazor.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.5" />
<PackageReference Include="Serilog.AspNetCore" Version="5.0.0" />
<PackageReference Include="Serilog.AspNetCore.Ingestion" Version="1.0.0-dev-00021" />
<PackageReference Include="Serilog.Sinks.Email" Version="2.4.0" />
<PackageReference Include="Serilog.Sinks.Trace" Version="3.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Server/Infrastructure/EmailSender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ public class EmailSettings
public string SenderName { get; set; } = null!;
public string Sender { get; set; } = null!;
public string Password { get; set; } = null!;
public string AdminEmail { get; set; }
public string AdminEmail { get; set; } = null!;
}
31 changes: 14 additions & 17 deletions src/Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,8 @@
.MinimumLevel.Override("System", LogEventLevel.Warning)
.MinimumLevel.Override("Duende", LogEventLevel.Error)
.Enrich.FromLogContext()
.Enrich.WithProperty("Environment", builder.Environment.EnvironmentName);

builder.Services.Configure<EmailSettings>(builder.Configuration.GetSection(EmailSettings.Email))
.AddSingleton(s => s.GetRequiredService<IOptions<EmailSettings>>().Value);

if (builder.Environment.IsProduction())
{
builder.Services.AddSingleton<IEmailSender, EmailSender>();

var emailSettings = builder.Services.BuildServiceProvider().GetRequiredService<EmailSettings>();
loggerConfiguration.WriteTo.Email(emailSettings.Sender, emailSettings.AdminEmail, mailServer: emailSettings.MailServer, restrictedToMinimumLevel: LogEventLevel.Error, mailSubject: "An error occured on Dynamo League.");
}
else
{
builder.Services.AddSingleton<IEmailSender, DevelopmentEmailSender>();
loggerConfiguration.WriteTo.Trace();
}
.Enrich.WithProperty("Environment", builder.Environment.EnvironmentName)
.WriteTo.File(".logs/log.log", rollingInterval: RollingInterval.Day);

Log.Logger = loggerConfiguration.CreateLogger();

Expand Down Expand Up @@ -99,6 +84,18 @@
builder.Services.AddTransient<IBidAmountValidator, BidAmountValidator>();
builder.Services.AddTransient<IPlayerHeadshotService, PlayerHeadshotService>();

builder.Services.Configure<EmailSettings>(builder.Configuration.GetSection(EmailSettings.Email))
.AddSingleton(s => s.GetRequiredService<IOptions<EmailSettings>>().Value);

if (builder.Environment.IsProduction())
{
builder.Services.AddSingleton<IEmailSender, EmailSender>();
}
else
{
builder.Services.AddSingleton<IEmailSender, DevelopmentEmailSender>();
}

var app = builder.Build();

// Configure the HTTP request pipeline.
Expand Down
3 changes: 1 addition & 2 deletions src/Server/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
"MailPort": 25,
"SenderName": "Dynamo League - Fantasy Football",
"Sender": "[email protected]",
"Password": "",
"AdminEmail": ""
"Password": ""
},
"IdentityServer": {
"Clients": {
Expand Down
10 changes: 5 additions & 5 deletions src/Shared/Features/Admin/AddPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ namespace DynamoLeagueBlazor.Shared.Features.Admin;

public class AddPlayerRequest
{
public string Name { get; set; }
public string Position { get; set; }
public string Name { get; set; } = null!;
public string Position { get; set; } = null!;
public int TeamId { get; set; }
public int ContractValue { get; set; }
}
Expand All @@ -21,7 +21,7 @@ public class TeamNameListResult
public class TeamNameItem
{
public int Id { get; set; }
public string Name { get; set; }
public string Name { get; set; } = null!;
}
}

Expand Down Expand Up @@ -54,8 +54,8 @@ public AddPlayerRequestValidator(IPlayerHeadshotService playerHeadshotService)

public class PlayerPreviewRequest
{
public string Name { get; set; }
public string Position { get; set; }
public string Name { get; set; } = null!;
public string Position { get; set; } = null!;
}

public class PlayerPreviewRequestValidator : AbstractValidator<PlayerPreviewRequest>
Expand Down
2 changes: 1 addition & 1 deletion src/Shared/Features/Admin/Users/Delete.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

public class DeleteUserRequest
{
public string UserId { get; set; }
public string UserId { get; set; } = null!;
}
6 changes: 3 additions & 3 deletions src/Shared/Features/Admin/Users/List.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ public class UserListResult

public class UserItem
{
public string Id { get; set; }
public string Team { get; set; }
public string Email { get; set; }
public string Id { get; set; } = null!;
public string Team { get; set; } = null!;
public string Email { get; set; } = null!;
public bool EmailConfirmed { get; set; }
}
}
4 changes: 2 additions & 2 deletions src/Shared/Features/AsyncAbstractValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace DynamoLeagueBlazor.Shared.Helpers;
/// </summary>
public abstract class AsyncAbstractValidator<T> : AbstractValidator<T>
{
private Task<ValidationResult> _validateTask;
private Task<ValidationResult> _validateTask = null!;

public override Task<ValidationResult> ValidateAsync(ValidationContext<T> context, CancellationToken cancellation = default)
=> _validateTask = base.ValidateAsync(context, cancellation);
Expand All @@ -25,6 +25,6 @@ public override ValidationResult Validate(ValidationContext<T> context)
}

public Task<ValidationResult> WaitForValidateAsync()
=> _validateTask ?? Task.FromResult<ValidationResult>(null);
=> _validateTask ?? Task.FromResult<ValidationResult>(null!);

}
6 changes: 3 additions & 3 deletions src/Shared/Features/Dashboard/TopOffenders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ public class TopOffendersResult

public class PlayerItem : IRankedItem
{
public string ImageUrl { get; set; }
public string Name { get; set; }
public string Amount { get; set; }
public string ImageUrl { get; set; } = null!;
public string Name { get; set; } = null!;
public string Amount { get; set; } = null!;
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/Shared/Features/Dashboard/TopTeamFines.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ public class TopTeamFinesResult

public class TeamItem : IRankedItem
{
public string ImageUrl { get; set; }
public string Name { get; set; }
public string Amount { get; set; }
public string ImageUrl { get; set; } = null!;
public string Name { get; set; } = null!;
public string Amount { get; set; } = null!;
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/Shared/Features/Fines/List.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ public class FineListResult
public class FineItem
{
public int Id { get; set; }
public string PlayerHeadShotUrl { get; set; }
public string PlayerName { get; set; }
public string TeamName { get; set; }
public string TeamLogoUrl { get; set; }
public string Reason { get; set; }
public string PlayerHeadShotUrl { get; set; } = null!;
public string PlayerName { get; set; } = null!;
public string TeamName { get; set; } = null!;
public string TeamLogoUrl { get; set; } = null!;
public string Reason { get; set; } = null!;
public decimal Amount { get; set; }
public string Status { get; set; }
public string Status { get; set; } = null!;
}
}

Expand Down
16 changes: 8 additions & 8 deletions src/Shared/Features/FreeAgents/Detail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

public class FreeAgentDetailResult
{
public string Name { get; set; }
public string Position { get; set; }
public string HeadShotUrl { get; set; }
public string Team { get; set; }
public string EndOfFreeAgency { get; set; }
public string Name { get; set; } = null!;
public string Position { get; set; } = null!;
public string HeadShotUrl { get; set; } = null!;
public string Team { get; set; } = null!;
public string EndOfFreeAgency { get; set; } = null!;

public IEnumerable<BidItem> Bids { get; set; } = Enumerable.Empty<BidItem>();

public class BidItem
{
public string Team { get; set; }
public string Amount { get; set; }
public string CreatedOn { get; set; }
public string Team { get; set; } = null!;
public string Amount { get; set; } = null!;
public string CreatedOn { get; set; } = null!;
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/Shared/Features/FreeAgents/List.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

public class FreeAgentListResult
{
public List<FreeAgentItem> FreeAgents { get; set; }
public List<FreeAgentItem> FreeAgents { get; set; } = new();

public class FreeAgentItem
{
public int Id { get; set; }
public string Name { get; set; }
public string Position { get; set; }
public string Team { get; set; }
public string HeadShotUrl { get; set; }
public string Name { get; set; } = null!;
public string Position { get; set; } = null!;
public string Team { get; set; } = null!;
public string HeadShotUrl { get; set; } = null!;
public DateTime BiddingEnds { get; set; }
public int HighestBid { get; set; }
public bool CurrentUserIsHighestBidder { get; set; }
Expand Down
8 changes: 4 additions & 4 deletions src/Shared/Features/OfferMatching/List.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ public class OfferMatchingListResult
public class OfferMatchingItem
{
public int Id { get; set; }
public string Name { get; set; }
public string Position { get; set; }
public string HeadShotUrl { get; set; }
public string OfferingTeam { get; set; }
public string Name { get; set; } = null!;
public string Position { get; set; } = null!;
public string HeadShotUrl { get; set; } = null!;
public string OfferingTeam { get; set; } = null!;
public int Offer { get; set; }
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Shared/Features/Players/AddFine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace DynamoLeagueBlazor.Shared.Features.Players;
public class AddFineRequest
{
public int PlayerId { get; set; }
public string FineReason { get; set; }
public string FineReason { get; set; } = null!;
}

public class AddFineRequestValidator : AbstractValidator<AddFineRequest>
Expand Down
8 changes: 4 additions & 4 deletions src/Shared/Features/Players/List.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ public class PlayerListResult
public class PlayerItem
{
public int Id { get; set; }
public string HeadShotUrl { get; set; }
public string Name { get; set; }
public string Position { get; set; }
public string Team { get; set; }
public string HeadShotUrl { get; set; } = null!;
public string Name { get; set; } = null!;
public string Position { get; set; } = null!;
public string Team { get; set; } = null!;
public int ContractValue { get; set; }
public int YearContractExpires { get; set; }
}
Expand Down
12 changes: 6 additions & 6 deletions src/Shared/Features/Teams/Detail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

public class TeamDetailResult
{
public string LogoUrl { get; set; }
public string Name { get; set; }
public string CapSpace { get; set; }
public string LogoUrl { get; set; } = null!;
public string Name { get; set; } = null!;
public string CapSpace { get; set; } = null!;
public List<PlayerItem> RosteredPlayers { get; set; } = new List<PlayerItem>();
public List<PlayerItem> UnrosteredPlayers { get; set; } = new List<PlayerItem>();
public List<PlayerItem> UnsignedPlayers { get; set; } = new List<PlayerItem>();
Expand All @@ -13,9 +13,9 @@ public class TeamDetailResult
public class PlayerItem
{
public int Id { get; set; }
public string HeadShotUrl { get; set; }
public string Name { get; set; }
public string Position { get; set; }
public string HeadShotUrl { get; set; } = null!;
public string Name { get; set; } = null!;
public string Position { get; set; } = null!;
public int ContractValue { get; set; }
public int? YearContractExpires { get; set; }
}
Expand Down
12 changes: 6 additions & 6 deletions src/Shared/Features/Teams/List.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ public class TeamListResult
public class TeamItem
{
public int Id { get; set; }
public string LogoUrl { get; set; }
public string Name { get; set; }
public string RosteredPlayerCount { get; set; }
public string UnrosteredPlayerCount { get; set; }
public string UnsignedPlayerCount { get; set; }
public string CapSpace { get; set; }
public string LogoUrl { get; set; } = null!;
public string Name { get; set; } = null!;
public string RosteredPlayerCount { get; set; } = null!;
public string UnrosteredPlayerCount { get; set; } = null!;
public string UnsignedPlayerCount { get; set; } = null!;
public string CapSpace { get; set; } = null!;
}
}

Expand Down

0 comments on commit ea2a9b7

Please sign in to comment.