Skip to content

Commit

Permalink
Doing some cleanup of all the Warnings that litter the build - Part 3 (
Browse files Browse the repository at this point in the history
  • Loading branch information
Stelzi79 authored Sep 12, 2023
1 parent 6177cf8 commit 50b5d3e
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 51 deletions.
13 changes: 8 additions & 5 deletions src/TagzApp.Providers.Blazot/Events/AuthEvents.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
namespace TagzApp.Providers.Blazot.Events;

internal interface IAuthEvents
internal interface IAuthEvents
{
event EventHandler AccessTokenUpdated;
event EventHandler AccessTokenUpdated;

void NotifyAccessTokenUpdated();
void NotifyAccessTokenUpdated();
}

internal class AuthEvents : IAuthEvents
{
public event EventHandler AccessTokenUpdated;
// TODO: Check CS8618: Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
public event EventHandler AccessTokenUpdated;
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.

public void NotifyAccessTokenUpdated() => AccessTokenUpdated.Invoke(this, EventArgs.Empty);
public void NotifyAccessTokenUpdated() => AccessTokenUpdated.Invoke(this, EventArgs.Empty);
}
16 changes: 11 additions & 5 deletions src/TagzApp.Providers.Blazot/Models/Author.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
namespace TagzApp.Providers.Blazot.Models;

// TODO: Check CS8618: Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
public class Author
{
public string UserName { get; set; }
public string DisplayName { get; set; }
public bool IsSubscriber { get; set; }
public int? SubscriptionLevel { get; set; }
public string ProfileImageUrl { get; set; }

public string UserName { get; set; }

public string DisplayName { get; set; }
public bool IsSubscriber { get; set; }
public int? SubscriptionLevel { get; set; }
public string ProfileImageUrl { get; set; }
}
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
75 changes: 40 additions & 35 deletions src/TagzApp.Providers.Blazot/Models/Transmission.cs
Original file line number Diff line number Diff line change
@@ -1,38 +1,43 @@
namespace TagzApp.Providers.Blazot.Models;

public class Transmission
{
/// <summary>
/// The unique identifier for the transmission.
/// </summary>
public Guid TransmissionId { get; set; }

/// <summary>
/// The unique identifier for the parent transmission that this transmission is a response to.
/// </summary>
public Guid? ParentItemId { get; set; }

/// <summary>
/// The UTC date/time this transmission was transmitted.
/// </summary>
public DateTime DateTransmitted { get; set; }

/// <summary>
/// The transmission text.
/// </summary>
public string Body { get; set; }

/// <summary>
/// The author object.
/// </summary>
public Author Author { get; set; }

/// <summary>
/// Video or images within this transmission.
/// </summary>
public List<Media> Media { get; set; }

public WebLink WebLink { get; set; }

public Transmission RelayedTransmission { get; set; }
// TODO: Check CS8618: Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
public class Transmission
{
/// <summary>
/// The unique identifier for the transmission.
/// </summary>
public Guid TransmissionId { get; set; }

/// <summary>
/// The unique identifier for the parent transmission that this transmission is a response to.
/// </summary>
public Guid? ParentItemId { get; set; }

/// <summary>
/// The UTC date/time this transmission was transmitted.
/// </summary>
public DateTime DateTransmitted { get; set; }

/// <summary>
/// The transmission text.
/// </summary>

public string Body { get; set; }


/// <summary>
/// The author object.
/// </summary>
public Author Author { get; set; }

/// <summary>
/// Video or images within this transmission.
/// </summary>
public List<Media> Media { get; set; }

public WebLink WebLink { get; set; }

public Transmission RelayedTransmission { get; set; }
}
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
14 changes: 10 additions & 4 deletions src/TagzApp.Providers.Blazot/Models/WebLink.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
namespace TagzApp.Providers.Blazot.Models;

// TODO: Check CS8618: Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
public class WebLink
{
public string LinkUrl { get; set; }
public string ImageUrl { get; set; }
public string Title { get; set; }
public string Description { get; set; }

public string LinkUrl { get; set; }

public string ImageUrl { get; set; }
public string Title { get; set; }
public string Description { get; set; }
}
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
9 changes: 7 additions & 2 deletions src/TagzApp.Providers.Mastodon/MastodonProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ public async Task<IEnumerable<Content>> GetContentForHashtag(Hashtag tag, DateTi

NewestId = messages!.OrderByDescending(m => m.id).First().id;

var baseServerAddress = _HttpClient.BaseAddress.Host.ToString();
var baseServerAddress = _HttpClient.BaseAddress?.Host.ToString();

#pragma warning disable CS8604 // Possible null reference argument.
return messages!.Select(m => new Content
{
Provider = Id,
Expand All @@ -72,8 +73,12 @@ public async Task<IEnumerable<Content>> GetContentForHashtag(Hashtag tag, DateTi
},
Text = m.content,
HashtagSought = tag.Text,
PreviewCard = m.card is null ? m.media_attachments.Any() ? (Common.Models.Card)Message.GetMediaAttachment(m.media_attachments.First().ToString()) : null : (Common.Models.Card)m.card
// TODO: Check for CS8604 -- Possible null reference argument in m.media_attachments! Possibly it is connected with the missing Null annotations in Messages.cs! This whole assignment makes the compiler "mad" in several parts with multiple different Warnings. At a first glance I wasn't clear how to fix these warnings!
PreviewCard = m.card is null ? m.media_attachments.Any()
? (Common.Models.Card)Message.GetMediaAttachment(m.media_attachments.First().ToString())
: null : (Common.Models.Card)m.card!
}).ToArray();
#pragma warning restore CS8604 // Possible null reference argument.

}

Expand Down

0 comments on commit 50b5d3e

Please sign in to comment.