diff --git a/src/TagzApp.Providers.Blazot/Events/AuthEvents.cs b/src/TagzApp.Providers.Blazot/Events/AuthEvents.cs index 3adcfcd8..61e4ecc4 100644 --- a/src/TagzApp.Providers.Blazot/Events/AuthEvents.cs +++ b/src/TagzApp.Providers.Blazot/Events/AuthEvents.cs @@ -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); } diff --git a/src/TagzApp.Providers.Blazot/Models/Author.cs b/src/TagzApp.Providers.Blazot/Models/Author.cs index 822770dd..eb4679d7 100644 --- a/src/TagzApp.Providers.Blazot/Models/Author.cs +++ b/src/TagzApp.Providers.Blazot/Models/Author.cs @@ -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. \ No newline at end of file diff --git a/src/TagzApp.Providers.Blazot/Models/Transmission.cs b/src/TagzApp.Providers.Blazot/Models/Transmission.cs index e6971eb9..a965b5fb 100644 --- a/src/TagzApp.Providers.Blazot/Models/Transmission.cs +++ b/src/TagzApp.Providers.Blazot/Models/Transmission.cs @@ -1,38 +1,43 @@ namespace TagzApp.Providers.Blazot.Models; - public class Transmission - { - /// - /// The unique identifier for the transmission. - /// - public Guid TransmissionId { get; set; } - - /// - /// The unique identifier for the parent transmission that this transmission is a response to. - /// - public Guid? ParentItemId { get; set; } - - /// - /// The UTC date/time this transmission was transmitted. - /// - public DateTime DateTransmitted { get; set; } - - /// - /// The transmission text. - /// - public string Body { get; set; } - - /// - /// The author object. - /// - public Author Author { get; set; } - - /// - /// Video or images within this transmission. - /// - public List 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 +{ + /// + /// The unique identifier for the transmission. + /// + public Guid TransmissionId { get; set; } + + /// + /// The unique identifier for the parent transmission that this transmission is a response to. + /// + public Guid? ParentItemId { get; set; } + + /// + /// The UTC date/time this transmission was transmitted. + /// + public DateTime DateTransmitted { get; set; } + + /// + /// The transmission text. + /// + + public string Body { get; set; } + + + /// + /// The author object. + /// + public Author Author { get; set; } + + /// + /// Video or images within this transmission. + /// + public List 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. \ No newline at end of file diff --git a/src/TagzApp.Providers.Blazot/Models/WebLink.cs b/src/TagzApp.Providers.Blazot/Models/WebLink.cs index ee724410..e453049e 100644 --- a/src/TagzApp.Providers.Blazot/Models/WebLink.cs +++ b/src/TagzApp.Providers.Blazot/Models/WebLink.cs @@ -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. \ No newline at end of file diff --git a/src/TagzApp.Providers.Mastodon/MastodonProvider.cs b/src/TagzApp.Providers.Mastodon/MastodonProvider.cs index 1d4414e4..b8c27f98 100644 --- a/src/TagzApp.Providers.Mastodon/MastodonProvider.cs +++ b/src/TagzApp.Providers.Mastodon/MastodonProvider.cs @@ -53,8 +53,9 @@ public async Task> 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, @@ -72,8 +73,12 @@ public async Task> 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. }