diff --git a/Benchmarks/Boxed.Mapping.Benchmark/MapArrayBenchmark.cs b/Benchmarks/Boxed.Mapping.Benchmark/MapArrayBenchmark.cs index c95214f6..833c1225 100644 --- a/Benchmarks/Boxed.Mapping.Benchmark/MapArrayBenchmark.cs +++ b/Benchmarks/Boxed.Mapping.Benchmark/MapArrayBenchmark.cs @@ -23,7 +23,7 @@ public class MapArrayBenchmark private readonly IMapper automapper; private readonly IMapper boilerplateMapper; private readonly Random random; - private MapFrom[] mapFrom; + private MapFrom[] mapFrom = default!; public MapArrayBenchmark() { diff --git a/Benchmarks/Boxed.Mapping.Benchmark/MapListBenchmark.cs b/Benchmarks/Boxed.Mapping.Benchmark/MapListBenchmark.cs index c98079f5..9bac3017 100644 --- a/Benchmarks/Boxed.Mapping.Benchmark/MapListBenchmark.cs +++ b/Benchmarks/Boxed.Mapping.Benchmark/MapListBenchmark.cs @@ -24,7 +24,7 @@ public class MapListBenchmark private readonly IMapper automapper; private readonly IMapper boilerplateMapper; private readonly Random random; - private List mapFrom; + private List mapFrom = default!; public MapListBenchmark() { diff --git a/Benchmarks/Boxed.Mapping.Benchmark/MapObjectBenchmark.cs b/Benchmarks/Boxed.Mapping.Benchmark/MapObjectBenchmark.cs index 13ec5a46..f32d2bb5 100644 --- a/Benchmarks/Boxed.Mapping.Benchmark/MapObjectBenchmark.cs +++ b/Benchmarks/Boxed.Mapping.Benchmark/MapObjectBenchmark.cs @@ -23,7 +23,7 @@ public class MapObjectBenchmark private readonly IMapper automapper; private readonly IMapper boilerplateMapper; private readonly Random random; - private MapFrom mapFrom; + private MapFrom mapFrom = default!; public MapObjectBenchmark() { diff --git a/Benchmarks/Boxed.Mapping.Benchmark/Models/MapFrom.cs b/Benchmarks/Boxed.Mapping.Benchmark/Models/MapFrom.cs index bfca8ad6..514d38d3 100644 --- a/Benchmarks/Boxed.Mapping.Benchmark/Models/MapFrom.cs +++ b/Benchmarks/Boxed.Mapping.Benchmark/Models/MapFrom.cs @@ -12,6 +12,6 @@ public class MapFrom public long LongFrom { get; set; } - public string StringFrom { get; set; } + public string? StringFrom { get; set; } } } diff --git a/Benchmarks/Boxed.Mapping.Benchmark/Models/MapTo.cs b/Benchmarks/Boxed.Mapping.Benchmark/Models/MapTo.cs index 0f400891..5873734b 100644 --- a/Benchmarks/Boxed.Mapping.Benchmark/Models/MapTo.cs +++ b/Benchmarks/Boxed.Mapping.Benchmark/Models/MapTo.cs @@ -12,6 +12,6 @@ public class MapTo public long LongTo { get; set; } - public string StringTo { get; set; } + public string? StringTo { get; set; } } } diff --git a/Directory.Build.props b/Directory.Build.props index 614f4952..63b828f8 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -4,6 +4,7 @@ latest true latest + enable en-GB true diff --git a/Source/Boxed.AspNetCore.TagHelpers/HrefSubresourceIntegrityTagHelper.cs b/Source/Boxed.AspNetCore.TagHelpers/HrefSubresourceIntegrityTagHelper.cs index c9941995..e3123b16 100644 --- a/Source/Boxed.AspNetCore.TagHelpers/HrefSubresourceIntegrityTagHelper.cs +++ b/Source/Boxed.AspNetCore.TagHelpers/HrefSubresourceIntegrityTagHelper.cs @@ -34,7 +34,7 @@ public HrefSubresourceIntegrityTagHelper( /// [HtmlAttributeName(SubresourceIntegrityHrefAttributeName)] - public override string Source { get; set; } + public override string? Source { get; set; } /// protected override string UrlAttributeName => HrefAttributeName; diff --git a/Source/Boxed.AspNetCore.TagHelpers/HtmlHelperExtensions.cs b/Source/Boxed.AspNetCore.TagHelpers/HtmlHelperExtensions.cs index fc71a311..6d28d4c8 100644 --- a/Source/Boxed.AspNetCore.TagHelpers/HtmlHelperExtensions.cs +++ b/Source/Boxed.AspNetCore.TagHelpers/HtmlHelperExtensions.cs @@ -15,7 +15,7 @@ public static class HtmlHelperExtensions /// The HTML helper. /// The type of referrer allowed to be sent. /// The referrer meta tag. - public static HtmlString ReferrerMeta(this IHtmlHelper htmlHelper, ReferrerMode referrerMode) + public static HtmlString? ReferrerMeta(this IHtmlHelper htmlHelper, ReferrerMode referrerMode) { if (htmlHelper is null) { diff --git a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/Media/OpenGraphMedia.cs b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/Media/OpenGraphMedia.cs index e941a46f..57f6813b 100644 --- a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/Media/OpenGraphMedia.cs +++ b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/Media/OpenGraphMedia.cs @@ -12,7 +12,7 @@ public abstract class OpenGraphMedia /// Initializes a new instance of the class. /// /// The media URL. - /// Thrown if is null. + /// Thrown if is null. public OpenGraphMedia(Uri mediaUrl) { if (mediaUrl is null) @@ -39,7 +39,7 @@ public OpenGraphMedia(Uri mediaUrl) /// Gets or sets the MIME type of the media e.g. media/jpeg. This is optional if your media URL ends with a file extension, /// otherwise it is recommended. /// - public string Type { get; set; } + public string? Type { get; set; } /// /// Gets the absolute HTTP media URL which should represent your object within the graph. @@ -49,7 +49,7 @@ public OpenGraphMedia(Uri mediaUrl) /// /// Gets the absolute HTTPS media URL which should represent your object within the graph. /// - public Uri UrlSecure { get; } + public Uri? UrlSecure { get; } /// /// Appends a HTML-encoded string representing this instance to the containing the Open Graph meta tags. diff --git a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphBooksAuthor.cs b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphBooksAuthor.cs index c60a727a..9938048d 100644 --- a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphBooksAuthor.cs +++ b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphBooksAuthor.cs @@ -25,7 +25,7 @@ public class OpenGraphBooksAuthor : OpenGraphMetadata /// Gets or sets the URL's to the pages about the books written by the author. This URL must contain books.book meta tags . /// [HtmlAttributeName(BookUrlsAttributeName)] - public IEnumerable BookUrls { get; set; } + public IEnumerable? BookUrls { get; set; } /// /// Gets or sets the authors gender. @@ -37,7 +37,7 @@ public class OpenGraphBooksAuthor : OpenGraphMetadata /// Gets or sets the URL's to the pages about the genres of books the author typically writes. This URL must contain books.genre meta tags . /// [HtmlAttributeName(GenreUrlsAttributeName)] - public IEnumerable GenreUrls { get; set; } + public IEnumerable? GenreUrls { get; set; } /// /// Gets the namespace of this open graph type. @@ -48,7 +48,7 @@ public class OpenGraphBooksAuthor : OpenGraphMetadata /// Gets or sets the official site URL of the author. /// [HtmlAttributeName(OfficialSiteUrlAttributeName)] - public Uri OfficialSiteUrl { get; set; } + public Uri? OfficialSiteUrl { get; set; } /// /// Gets the type of your object. Depending on the type you specify, other properties may also be required. diff --git a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphBooksBook.cs b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphBooksBook.cs index 01c139ed..cae30c25 100644 --- a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphBooksBook.cs +++ b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphBooksBook.cs @@ -32,13 +32,13 @@ public class OpenGraphBooksBook : OpenGraphMetadata /// Gets or sets the URL's to the pages about the authors of the book. This URL must contain books.author meta tags . /// [HtmlAttributeName(AuthorUrlsAttributeName)] - public IEnumerable AuthorUrls { get; set; } + public IEnumerable? AuthorUrls { get; set; } /// /// Gets or sets the URL's to the pages about the genres of the book. This URL must contain books.genre meta tags . /// [HtmlAttributeName(GenreUrlsAttributeName)] - public IEnumerable GenreUrls { get; set; } + public IEnumerable? GenreUrls { get; set; } /// /// Gets or sets the initial release date of the book. @@ -50,13 +50,13 @@ public class OpenGraphBooksBook : OpenGraphMetadata /// Gets or sets the books unique ISBN number. /// [HtmlAttributeName(ISBNAttributeName)] - public string ISBN { get; set; } + public string? ISBN { get; set; } /// /// Gets or sets the language of the book in the format language_TERRITORY. /// [HtmlAttributeName(LanguageAttributeName)] - public string Language { get; set; } + public string? Language { get; set; } /// /// Gets the namespace of this open graph type. @@ -73,7 +73,7 @@ public class OpenGraphBooksBook : OpenGraphMetadata /// Gets or sets the rating of the book. /// [HtmlAttributeName(RatingAttributeName)] - public OpenGraphRating Rating { get; set; } + public OpenGraphRating? Rating { get; set; } /// /// Gets or sets the release date of the book. @@ -85,7 +85,7 @@ public class OpenGraphBooksBook : OpenGraphMetadata /// Gets or sets the URL to a sample of the book. /// [HtmlAttributeName(SampleUrlAttributeName)] - public Uri SampleUrl { get; set; } + public Uri? SampleUrl { get; set; } /// /// Gets the type of your object. Depending on the type you specify, other properties may also be required. diff --git a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphBooksGenre.cs b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphBooksGenre.cs index 44ac9986..ddbfed76 100644 --- a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphBooksGenre.cs +++ b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphBooksGenre.cs @@ -25,19 +25,19 @@ public class OpenGraphBooksGenre : OpenGraphMetadata /// Gets or sets the URL's to the pages about the authors who wrote the books. This URL must contain books.book meta tags . /// [HtmlAttributeName(AuthorUrlsAttributeName)] - public IEnumerable AuthorUrls { get; set; } + public IEnumerable? AuthorUrls { get; set; } /// /// Gets or sets the URL's to the pages about the books written by the author. This URL must contain books.book meta tags . /// [HtmlAttributeName(BookUrlsAttributeName)] - public IEnumerable BookUrls { get; set; } + public IEnumerable? BookUrls { get; set; } /// /// Gets or sets the canonical name of the genre. Only one of the following names is allowed Adventure, Children's Fiction, Drama, Erotica, Essays, Fantasy, Gay & Lesbian, Graphic Novels, Historical Fiction, Horror, Fiction & Literature, Mystery, Mythology & Folklore, Poetry, Religious & Inspiratonal, Rhetoric & Critcism, Romance, Satire & Humor, Science Fiction, Thrillers & Suspense, Westerns, Women's Fiction, Young Adult Fiction, Biography & Memoir, Current Affairs & Politics, Genealogy, Geography, History, History of the Ancient World, History of Africa, History of Asia, History of Europe, History of North America, History of South America, Travel, Bibliographies, Children's Non-fiction, Computer Science, Encyclopedias, General Collections, Gift Books, Information Sciences, Journalism & Publishing, Magazines & Journals, Manuscripts & Rare Books, Epistemology, Ethics, Logic, Metaphysics, Philosophy, Parapsychology & Occultism, Psychology, Self-help, Bible, Comparative Religions, Natural Theory, Theology, Business, Customs & Etiquette, Economics, Education, Finance, Gay & Lesbian Non-Fiction, Gender Studies, Law, Political Science, Social Sciences, Social Services, Statistics, True Crime, English & Old English, French, German, Greek, Italian, Language, Latin, Linguistics, Other Languages, Portugese, Spanish, Astronomy, Chemistry, Earth Sciences, Life Sciences, Mathematics, Paleontology & Paleozoology, Physics, Plants Sciences, Zoology, Agriculture, Chemical Engineering, Engineering & Opera?ons, Management, Manufacturing, Medical Sciences, Technology, Cooking & Cookbooks, Gardening, Home Decorating, Home Economics, Parenting, Pets, Architecture, Design, Drawing, Fine Art, Gardening, Graphic Art, Music, Painting, Performing Arts, Photography, Sculpture, Games, Fitness, Health and Sports. /// [HtmlAttributeName(CanonicalNameAttributeName)] - public string CanonicalName { get; set; } + public string? CanonicalName { get; set; } /// /// Gets the namespace of this open graph type. diff --git a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphBusiness.cs b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphBusiness.cs index 7e413490..7d6180f9 100644 --- a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphBusiness.cs +++ b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphBusiness.cs @@ -28,13 +28,13 @@ public class OpenGraphBusiness : OpenGraphMetadata /// Gets or sets the contact data for the business. /// [HtmlAttributeName(ContactDataAttributeName)] - public OpenGraphContactData ContactData { get; set; } + public OpenGraphContactData? ContactData { get; set; } /// /// Gets or sets the location of the business. /// [HtmlAttributeName(LocationAttributeName)] - public OpenGraphLocation Location { get; set; } + public OpenGraphLocation? Location { get; set; } /// /// Gets the namespace of this open graph type. @@ -45,7 +45,7 @@ public class OpenGraphBusiness : OpenGraphMetadata /// Gets or sets the opening hours of the business. /// [HtmlAttributeName(OpeningHoursAttributeName)] - public IEnumerable OpeningHours { get; set; } + public IEnumerable? OpeningHours { get; set; } /// /// Gets the type of your object. Depending on the type you specify, other properties may also be required. @@ -65,15 +65,15 @@ public override void ToString(StringBuilder stringBuilder) base.ToString(stringBuilder); - stringBuilder.AppendMetaPropertyContentIfNotNull("business:contact_data:street_address", this.ContactData.StreetAddress); - stringBuilder.AppendMetaPropertyContentIfNotNull("business:contact_data:locality", this.ContactData.Locality); - stringBuilder.AppendMetaPropertyContentIfNotNull("business:contact_data:region", this.ContactData.Region); - stringBuilder.AppendMetaPropertyContentIfNotNull("business:contact_data:postal_code", this.ContactData.PostalCode); - stringBuilder.AppendMetaPropertyContentIfNotNull("business:contact_data:country_name", this.ContactData.Country); - stringBuilder.AppendMetaPropertyContentIfNotNull("business:contact_data:email", this.ContactData.Email); - stringBuilder.AppendMetaPropertyContentIfNotNull("business:contact_data:phone_number", this.ContactData.Phone); - stringBuilder.AppendMetaPropertyContentIfNotNull("business:contact_data:fax_number", this.ContactData.Fax); - stringBuilder.AppendMetaPropertyContentIfNotNull("business:contact_data:website", this.ContactData.Website); + stringBuilder.AppendMetaPropertyContentIfNotNull("business:contact_data:street_address", this.ContactData?.StreetAddress); + stringBuilder.AppendMetaPropertyContentIfNotNull("business:contact_data:locality", this.ContactData?.Locality); + stringBuilder.AppendMetaPropertyContentIfNotNull("business:contact_data:region", this.ContactData?.Region); + stringBuilder.AppendMetaPropertyContentIfNotNull("business:contact_data:postal_code", this.ContactData?.PostalCode); + stringBuilder.AppendMetaPropertyContentIfNotNull("business:contact_data:country_name", this.ContactData?.Country); + stringBuilder.AppendMetaPropertyContentIfNotNull("business:contact_data:email", this.ContactData?.Email); + stringBuilder.AppendMetaPropertyContentIfNotNull("business:contact_data:phone_number", this.ContactData?.Phone); + stringBuilder.AppendMetaPropertyContentIfNotNull("business:contact_data:fax_number", this.ContactData?.Fax); + stringBuilder.AppendMetaPropertyContentIfNotNull("business:contact_data:website", this.ContactData?.Website); if (this.OpeningHours is not null) { @@ -85,9 +85,9 @@ public override void ToString(StringBuilder stringBuilder) } } - stringBuilder.AppendMetaPropertyContent("place:location:latitude", this.Location.Latitude); - stringBuilder.AppendMetaPropertyContent("place:location:longitude", this.Location.Longitude); - stringBuilder.AppendMetaPropertyContentIfNotNull("place:location:altitude", this.Location.Altitude); + stringBuilder.AppendMetaPropertyContent("place:location:latitude", this.Location?.Latitude); + stringBuilder.AppendMetaPropertyContent("place:location:longitude", this.Location?.Longitude); + stringBuilder.AppendMetaPropertyContentIfNotNull("place:location:altitude", this.Location?.Altitude); } /// diff --git a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphFitnessCourse.cs b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphFitnessCourse.cs index 84b50300..83ba1f40 100644 --- a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphFitnessCourse.cs +++ b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphFitnessCourse.cs @@ -36,31 +36,31 @@ public class OpenGraphFitnessCourse : OpenGraphMetadata /// Gets or sets the energy used during the course. /// [HtmlAttributeName(CustomUnitEnergyAttributeName)] - public OpenGraphQuantity CustomUnitEnergy { get; set; } + public OpenGraphQuantity? CustomUnitEnergy { get; set; } /// /// Gets or sets the distance of the course. /// [HtmlAttributeName(DistanceAttributeName)] - public OpenGraphQuantity Distance { get; set; } + public OpenGraphQuantity? Distance { get; set; } /// /// Gets or sets the duration taken on the course. /// [HtmlAttributeName(DurationAttributeName)] - public OpenGraphQuantity Duration { get; set; } + public OpenGraphQuantity? Duration { get; set; } /// /// Gets or sets a string value displayed in stories if the associated action's end_time has not passed, such as an encouragement to friends to cheer the user on. The value is not rendered once the course has been completed. /// [HtmlAttributeName(LiveTextAttributeName)] - public string LiveText { get; set; } + public string? LiveText { get; set; } /// /// Gets or sets the metrics about the course. /// [HtmlAttributeName(MetricsAttributeName)] - public IEnumerable Metrics { get; set; } + public IEnumerable? Metrics { get; set; } /// /// Gets the namespace of this open graph type. @@ -71,19 +71,19 @@ public class OpenGraphFitnessCourse : OpenGraphMetadata /// Gets or sets the pace achieved on the course. /// [HtmlAttributeName(PaceAttributeName)] - public OpenGraphQuantity Pace { get; set; } + public OpenGraphQuantity? Pace { get; set; } /// /// Gets or sets the split times during the course. /// [HtmlAttributeName(SplitsAttributeName)] - public IEnumerable Splits { get; set; } + public IEnumerable? Splits { get; set; } /// /// Gets or sets the speed achieved on the course. /// [HtmlAttributeName(SpeedAttributeName)] - public OpenGraphQuantity Speed { get; set; } + public OpenGraphQuantity? Speed { get; set; } /// /// Gets the type of your object. Depending on the type you specify, other properties may also be required. diff --git a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphPlace.cs b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphPlace.cs index 3bbc411c..84ac1721 100644 --- a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphPlace.cs +++ b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphPlace.cs @@ -23,7 +23,7 @@ public class OpenGraphPlace : OpenGraphMetadata /// Gets or sets the location of the place. /// [HtmlAttributeName(LocationAttributeName)] - public OpenGraphLocation Location { get; set; } + public OpenGraphLocation? Location { get; set; } /// /// Gets the namespace of this open graph type. @@ -48,9 +48,9 @@ public override void ToString(StringBuilder stringBuilder) base.ToString(stringBuilder); - stringBuilder.AppendMetaPropertyContent("place:location:latitude", this.Location.Latitude); - stringBuilder.AppendMetaPropertyContent("place:location:longitude", this.Location.Longitude); - stringBuilder.AppendMetaPropertyContentIfNotNull("place:location:altitude", this.Location.Altitude); + stringBuilder.AppendMetaPropertyContent("place:location:latitude", this.Location?.Latitude); + stringBuilder.AppendMetaPropertyContent("place:location:longitude", this.Location?.Longitude); + stringBuilder.AppendMetaPropertyContentIfNotNull("place:location:altitude", this.Location?.Altitude); } /// diff --git a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphProduct.cs b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphProduct.cs index e5bd0646..db9f15e2 100644 --- a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphProduct.cs +++ b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphProduct.cs @@ -64,19 +64,19 @@ public class OpenGraphProduct : OpenGraphMetadata /// Gets or sets the brand of the product or its original manufacturer. /// [HtmlAttributeName(BrandAttributeName)] - public string Brand { get; set; } + public string? Brand { get; set; } /// /// Gets or sets the category for the product. /// [HtmlAttributeName(CategoryAttributeName)] - public string Category { get; set; } + public string? Category { get; set; } /// /// Gets or sets the colour of the product. /// [HtmlAttributeName(ColourAttributeName)] - public string Colour { get; set; } + public string? Colour { get; set; } /// /// Gets or sets the condition of the item, one of 'new', 'refurbished', or 'used'. @@ -88,7 +88,7 @@ public class OpenGraphProduct : OpenGraphMetadata /// Gets or sets an International Article Number, or European Article Number (EAN), for the product. /// [HtmlAttributeName(EANAttributeName)] - public string EAN { get; set; } + public string? EAN { get; set; } /// /// Gets or sets a time representing when the product expired (or will expire). @@ -106,19 +106,19 @@ public class OpenGraphProduct : OpenGraphMetadata /// Gets or sets a International Standard Book Number (ISBN) for the product, intended for when it is a book. /// [HtmlAttributeName(ISBNAttributeName)] - public string ISBN { get; set; } + public string? ISBN { get; set; } /// /// Gets or sets the manufacturers part number for the product. /// [HtmlAttributeName(ManufacturerPartNumberAttributeName)] - public string ManufacturerPartNumber { get; set; } + public string? ManufacturerPartNumber { get; set; } /// /// Gets or sets a description of the material used to make the product. /// [HtmlAttributeName(MaterialAttributeName)] - public string Material { get; set; } + public string? Material { get; set; } /// /// Gets the namespace of this open graph type. @@ -129,37 +129,37 @@ public class OpenGraphProduct : OpenGraphMetadata /// Gets or sets the original prices of the product. /// [HtmlAttributeName(OriginalPricesAttributeName)] - public IEnumerable OriginalPrices { get; set; } + public IEnumerable? OriginalPrices { get; set; } /// /// Gets or sets a description of the pattern used on the product. /// [HtmlAttributeName(PatternAttributeName)] - public string Pattern { get; set; } + public string? Pattern { get; set; } /// /// Gets or sets a title to be used to describe multiple items of this product. /// [HtmlAttributeName(PluralTitleAttributeName)] - public string PluralTitle { get; set; } + public string? PluralTitle { get; set; } /// /// Gets or sets the pre-tax prices of the product. /// [HtmlAttributeName(PretaxPricesAttributeName)] - public IEnumerable PretaxPrices { get; set; } + public IEnumerable? PretaxPrices { get; set; } /// /// Gets or sets the prices of the product. /// [HtmlAttributeName(PricesAttributeName)] - public IEnumerable Prices { get; set; } + public IEnumerable? Prices { get; set; } /// /// Gets or sets a URL link to find out more about the product. /// [HtmlAttributeName(ProductLinkUrlAttributeName)] - public Uri ProductLinkUrl { get; set; } + public Uri? ProductLinkUrl { get; set; } /// /// Gets or sets the maximum number of times a person can purchase the product. @@ -171,55 +171,55 @@ public class OpenGraphProduct : OpenGraphMetadata /// Gets or sets the URL to the page about the retailer of the product. This URL must contain profile meta tags . /// [HtmlAttributeName(RetailerUrlAttributeName)] - public Uri RetailerUrl { get; set; } + public Uri? RetailerUrl { get; set; } /// /// Gets or sets the retailer's category for the product. /// [HtmlAttributeName(RetailerCategoryAttributeName)] - public string RetailerCategory { get; set; } + public string? RetailerCategory { get; set; } /// /// Gets or sets the retailer's part number for the product. /// [HtmlAttributeName(RetailerPartNumberAttributeName)] - public string RetailerPartNumber { get; set; } + public string? RetailerPartNumber { get; set; } /// /// Gets or sets the name of the retailer of the product. /// [HtmlAttributeName(RetailerTitleAttributeName)] - public string RetailerTitle { get; set; } + public string? RetailerTitle { get; set; } /// /// Gets or sets the sale price of the product. /// [HtmlAttributeName(SalePriceAttributeName)] - public OpenGraphCurrency SalePrice { get; set; } + public OpenGraphCurrency? SalePrice { get; set; } /// /// Gets or sets the date range for which the sale price is valid. /// [HtmlAttributeName(SalePriceDatesAttributeName)] - public OpenGraphDateTimeRange SalePriceDates { get; set; } + public OpenGraphDateTimeRange? SalePriceDates { get; set; } /// /// Gets or sets the shipping cost of the product. /// [HtmlAttributeName(ShippingCostAttributeName)] - public IEnumerable ShippingCost { get; set; } + public IEnumerable? ShippingCost { get; set; } /// /// Gets or sets the shipping weight of the product. /// [HtmlAttributeName(ShippingWeightAttributeName)] - public OpenGraphQuantity ShippingWeight { get; set; } + public OpenGraphQuantity? ShippingWeight { get; set; } /// /// Gets or sets a size describing the product(such as 'S', 'M', 'L'). /// [HtmlAttributeName(SizeAttributeName)] - public string Size { get; set; } + public string? Size { get; set; } /// /// Gets or sets the target gender for the product. @@ -236,13 +236,13 @@ public class OpenGraphProduct : OpenGraphMetadata /// Gets or sets a Universal Product Code(UPC) for the product. /// [HtmlAttributeName(TargetGenderAttributeName)] - public string UPC { get; set; } + public string? UPC { get; set; } /// /// Gets or sets the weight of the product. /// [HtmlAttributeName(WeightAttributeName)] - public OpenGraphQuantity Weight { get; set; } + public OpenGraphQuantity? Weight { get; set; } /// /// Appends a HTML-encoded string representing this instance to the containing the Open Graph meta tags. diff --git a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphProductGroup.cs b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphProductGroup.cs index 8bfbb6e5..6d8247c6 100644 --- a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphProductGroup.cs +++ b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphProductGroup.cs @@ -24,7 +24,7 @@ public class OpenGraphProductGroup : OpenGraphMetadata /// Gets or sets the retailer's ID for the product group. /// [HtmlAttributeName(RetailerGroupIdAttributeName)] - public string RetailerGroupId { get; set; } + public string? RetailerGroupId { get; set; } /// /// Gets the type of your object. Depending on the type you specify, other properties may also be required. @@ -42,4 +42,4 @@ public override void ToString(StringBuilder stringBuilder) stringBuilder.AppendMetaPropertyContentIfNotNull("product:retailer_group_id", this.RetailerGroupId); } } -} \ No newline at end of file +} diff --git a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphProductItem.cs b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphProductItem.cs index 61a1e550..6c5e1165 100644 --- a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphProductItem.cs +++ b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphProductItem.cs @@ -54,19 +54,19 @@ public class OpenGraphProductItem : OpenGraphMetadata /// Gets or sets the brand of the item or its original manufacturer. /// [HtmlAttributeName(BrandAttributeName)] - public string Brand { get; set; } + public string? Brand { get; set; } /// /// Gets or sets the category for the item. /// [HtmlAttributeName(CategoryAttributeName)] - public string Category { get; set; } + public string? Category { get; set; } /// /// Gets or sets the colour of the item. /// [HtmlAttributeName(ColourAttributeName)] - public string Colour { get; set; } + public string? Colour { get; set; } /// /// Gets or sets the condition of the item, one of 'new', 'refurbished', or 'used'. @@ -84,25 +84,25 @@ public class OpenGraphProductItem : OpenGraphMetadata /// Gets or sets the URL to the page about the product group. This URL must contain profile meta tags . /// [HtmlAttributeName(GroupUrlAttributeName)] - public Uri GroupUrl { get; set; } + public Uri? GroupUrl { get; set; } /// /// Gets or sets the Global Trade Item Number (GTIN), which encompasses UPC, EAN, JAN, and ISBN. /// [HtmlAttributeName(GTINAttributeName)] - public string GTIN { get; set; } + public string? GTIN { get; set; } /// /// Gets or sets the manufacturers part number for the item. /// [HtmlAttributeName(ManufacturerPartNumberAttributeName)] - public string ManufacturerPartNumber { get; set; } + public string? ManufacturerPartNumber { get; set; } /// /// Gets or sets a description of the material used to make the item. /// [HtmlAttributeName(MaterialAttributeName)] - public string Material { get; set; } + public string? Material { get; set; } /// /// Gets the namespace of this open graph type. @@ -113,61 +113,61 @@ public class OpenGraphProductItem : OpenGraphMetadata /// Gets or sets a description of the pattern used on the item. /// [HtmlAttributeName(PatternAttributeName)] - public string Pattern { get; set; } + public string? Pattern { get; set; } /// /// Gets or sets the prices of the item. /// [HtmlAttributeName(PricesAttributeName)] - public IEnumerable Prices { get; set; } + public IEnumerable? Prices { get; set; } /// /// Gets or sets the retailer's category for the item. /// [HtmlAttributeName(RetailerCategoryAttributeName)] - public string RetailerCategory { get; set; } + public string? RetailerCategory { get; set; } /// /// Gets or sets the retailer product group ID for this item. /// [HtmlAttributeName(RetailerGroupIdAttributeName)] - public string RetailerGroupId { get; set; } + public string? RetailerGroupId { get; set; } /// /// Gets or sets the retailer's ID for the item. /// [HtmlAttributeName(RetailerItemIdAttributeName)] - public string RetailerItemId { get; set; } + public string? RetailerItemId { get; set; } /// /// Gets or sets the sale price of the item. /// [HtmlAttributeName(SalePriceAttributeName)] - public OpenGraphCurrency SalePrice { get; set; } + public OpenGraphCurrency? SalePrice { get; set; } /// /// Gets or sets the date range for which the sale price is valid. /// [HtmlAttributeName(SalePriceDatesAttributeName)] - public OpenGraphDateTimeRange SalePriceDates { get; set; } + public OpenGraphDateTimeRange? SalePriceDates { get; set; } /// /// Gets or sets the shipping cost of the item. /// [HtmlAttributeName(ShippingCostAttributeName)] - public IEnumerable ShippingCost { get; set; } + public IEnumerable? ShippingCost { get; set; } /// /// Gets or sets the shipping weight of the item. /// [HtmlAttributeName(ShippingWeightAttributeName)] - public OpenGraphQuantity ShippingWeight { get; set; } + public OpenGraphQuantity? ShippingWeight { get; set; } /// /// Gets or sets a size describing the item (such as 'S', 'M', 'L'). /// [HtmlAttributeName(SizeAttributeName)] - public string Size { get; set; } + public string? Size { get; set; } /// /// Gets or sets the target gender for the item. @@ -210,10 +210,13 @@ public override void ToString(StringBuilder stringBuilder) stringBuilder.AppendMetaPropertyContentIfNotNull("product:material", this.Material); stringBuilder.AppendMetaPropertyContentIfNotNull("product:pattern", this.Pattern); - foreach (var price in this.Prices) + if (this.Prices is not null) { - stringBuilder.AppendMetaPropertyContent("product:price:amount", price.Amount); - stringBuilder.AppendMetaPropertyContent("product:price:currency", price.Currency); + foreach (var price in this.Prices) + { + stringBuilder.AppendMetaPropertyContent("product:price:amount", price.Amount); + stringBuilder.AppendMetaPropertyContent("product:price:currency", price.Currency); + } } stringBuilder.AppendMetaPropertyContentIfNotNull("product:retailer_category", this.RetailerCategory); diff --git a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphRestaurant.cs b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphRestaurant.cs index c17ba8e9..c4e0cf58 100644 --- a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphRestaurant.cs +++ b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphRestaurant.cs @@ -26,25 +26,25 @@ public class OpenGraphRestaurant : OpenGraphMetadata /// Gets or sets a collection of categories describing this restaurant's food. /// [HtmlAttributeName(CategoriesAttributeName)] - public IEnumerable Categories { get; set; } + public IEnumerable? Categories { get; set; } /// /// Gets or sets the contact information for the restaurant. /// [HtmlAttributeName(ContactInfoAttributeName)] - public OpenGraphContactData ContactInfo { get; set; } + public OpenGraphContactData? ContactInfo { get; set; } /// /// Gets or sets the location of the place. /// [HtmlAttributeName(LocationAttributeName)] - public OpenGraphLocation Location { get; set; } + public OpenGraphLocation? Location { get; set; } /// /// Gets or sets the URL's to the pages about the menus. This URL must contain restaurant.menu meta tags . /// [HtmlAttributeName(MenuUrlsAttributeName)] - public IEnumerable MenuUrls { get; set; } + public IEnumerable? MenuUrls { get; set; } /// /// Gets the namespace of this open graph type. @@ -75,9 +75,9 @@ public override void ToString(StringBuilder stringBuilder) base.ToString(stringBuilder); - stringBuilder.AppendMetaPropertyContent("place:location:latitude", this.Location.Latitude); - stringBuilder.AppendMetaPropertyContent("place:location:longitude", this.Location.Longitude); - stringBuilder.AppendMetaPropertyContentIfNotNull("place:location:altitude", this.Location.Altitude); + stringBuilder.AppendMetaPropertyContent("place:location:latitude", this.Location?.Latitude); + stringBuilder.AppendMetaPropertyContent("place:location:longitude", this.Location?.Longitude); + stringBuilder.AppendMetaPropertyContentIfNotNull("place:location:altitude", this.Location?.Altitude); if (this.Categories is not null) { diff --git a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphRestaurantMenu.cs b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphRestaurantMenu.cs index f9e7df29..490d58d3 100644 --- a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphRestaurantMenu.cs +++ b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphRestaurantMenu.cs @@ -29,13 +29,13 @@ public class OpenGraphRestaurantMenu : OpenGraphMetadata /// Gets or sets the URL to the page about the restaurant who wrote the menu. This URL must contain profile meta tags . /// [HtmlAttributeName(RestaurantUrlAttributeName)] - public Uri RestaurantUrl { get; set; } + public Uri? RestaurantUrl { get; set; } /// /// Gets or sets the URL's to the pages about the menu sections. This URL must contain restaurant.section meta tags . /// [HtmlAttributeName(SectionUrlsAttributeName)] - public IEnumerable SectionUrls { get; set; } + public IEnumerable? SectionUrls { get; set; } /// /// Gets the type of your object. Depending on the type you specify, other properties may also be required. diff --git a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphRestaurantMenuItem.cs b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphRestaurantMenuItem.cs index b673b774..58b740fb 100644 --- a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphRestaurantMenuItem.cs +++ b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphRestaurantMenuItem.cs @@ -29,7 +29,7 @@ public class OpenGraphRestaurantMenuItem : OpenGraphMetadata /// Gets or sets the URL to the page about the section this menu item is from. This URL must contain profile meta tags . /// [HtmlAttributeName(SectionUrlAttributeName)] - public Uri SectionUrl { get; set; } + public Uri? SectionUrl { get; set; } /// /// Gets the type of your object. Depending on the type you specify, other properties may also be required. @@ -40,7 +40,7 @@ public class OpenGraphRestaurantMenuItem : OpenGraphMetadata /// Gets or sets the variations of this menu item. /// [HtmlAttributeName(VariationsAttributeName)] - public IEnumerable Variations { get; set; } + public IEnumerable? Variations { get; set; } /// /// Appends a HTML-encoded string representing this instance to the containing the Open Graph meta tags. diff --git a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphRestaurantMenuSection.cs b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphRestaurantMenuSection.cs index 3efa3614..ec82c408 100644 --- a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphRestaurantMenuSection.cs +++ b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Facebook/OpenGraphRestaurantMenuSection.cs @@ -24,13 +24,13 @@ public class OpenGraphRestaurantMenuSection : OpenGraphMetadata /// Gets or sets the URL's to the pages about the menu items. This URL must contain restaurant.menuitem meta tags . /// [HtmlAttributeName(ItemUrlsAttributeName)] - public IEnumerable ItemUrls { get; set; } + public IEnumerable? ItemUrls { get; set; } /// /// Gets or sets the URL to the page about the menu this section is from. This URL must contain profile meta tags . /// [HtmlAttributeName(MenuUrlAttributeName)] - public Uri MenuUrl { get; set; } + public Uri? MenuUrl { get; set; } /// /// Gets the namespace of this open graph type. diff --git a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/OpenGraphMetadata.cs b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/OpenGraphMetadata.cs index ca42f509..0d60367d 100644 --- a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/OpenGraphMetadata.cs +++ b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/OpenGraphMetadata.cs @@ -97,18 +97,18 @@ public abstract class OpenGraphMetadata : TagHelper /// Gets or sets the collection of alternate locales this page is available in. /// [HtmlAttributeName(AlternateLocalesAttributeName)] - public IEnumerable AlternateLocales { get; set; } + public IEnumerable? AlternateLocales { get; set; } /// /// Gets the audio files which should represent your object within the graph. Use the Media property to add an audio file. /// - public IEnumerable Audio => this.Media?.OfType(); + public IEnumerable? Audio => this.Media?.OfType(); /// /// Gets or sets a one to two sentence description of your object. Only set this value if it is different from the ]]> meta tag. Right now Facebook only displays the first 300 characters of a description. /// [HtmlAttributeName(DescriptionAttributeName)] - public string Description { get; set; } + public string? Description { get; set; } /// /// Gets or sets the word that appears before this object's title in a sentence. An enum of (a, an, the, "", auto). @@ -122,7 +122,7 @@ public abstract class OpenGraphMetadata : TagHelper /// Use this or , not both. is the preferred method. /// [HtmlAttributeName(FacebookAdministratorsAttributeName)] - public IEnumerable FacebookAdministrators { get; set; } + public IEnumerable? FacebookAdministrators { get; set; } /// /// Gets or sets the Facebook application identifier that identifies your website to Facebook. @@ -130,37 +130,37 @@ public abstract class OpenGraphMetadata : TagHelper /// create a developer account, go to the apps tab to create a new app, which will give you this ID. /// [HtmlAttributeName(FacebookApplicationIdAttributeName)] - public string FacebookApplicationId { get; set; } + public string? FacebookApplicationId { get; set; } /// /// Gets or sets the unique identifier of the Facebook profile for the current object. /// [HtmlAttributeName(FacebookProfileIdAttributeName)] - public string FacebookProfileId { get; set; } + public string? FacebookProfileId { get; set; } /// /// Gets the images which should represent your object within the graph. Use the Media property to add an image. /// - public IEnumerable Images => this.Media?.OfType(); + public IEnumerable? Images => this.Media?.OfType(); /// /// Gets or sets the locale these tags are marked up in. Of the format language_TERRITORY. Default is en_US. /// [HtmlAttributeName(LocaleAttributeName)] - public string Locale { get; set; } + public string? Locale { get; set; } /// /// Gets or sets the main image which should represent your object within the graph. This is a required property. /// [HtmlAttributeName(MainImageAttributeName)] - public OpenGraphImage MainImage { get; set; } + public OpenGraphImage? MainImage { get; set; } /// /// Gets or sets the images, videos or audio which should represent your object within the graph. /// [HtmlAttributeName(MediaAttributeName)] #pragma warning disable CA2227 // Collection properties should be read only - public ICollection Media { get; set; } + public ICollection? Media { get; set; } #pragma warning restore CA2227 // Collection properties should be read only /// @@ -175,20 +175,20 @@ public abstract class OpenGraphMetadata : TagHelper /// Open Graph standard but is used by Facebook. /// [HtmlAttributeName(SeeAlsoAttributeName)] - public IEnumerable SeeAlso { get; set; } + public IEnumerable? SeeAlso { get; set; } /// /// Gets or sets the name of the site. if your object is part of a larger web site, the name which should be displayed /// for the overall site. e.g. "IMDb". /// [HtmlAttributeName(SiteNameAttributeName)] - public string SiteName { get; set; } + public string? SiteName { get; set; } /// /// Gets or sets the title of your object as it should appear within the graph, e.g. "The Rock". /// [HtmlAttributeName(TitleAttributeName)] - public string Title { get; set; } + public string? Title { get; set; } /// /// Gets the type of your object. Depending on the type you specify, other properties may also be required. @@ -200,12 +200,12 @@ public abstract class OpenGraphMetadata : TagHelper /// e.g. "http://www.imdb.com/title/tt0117500/". Leave as null to get the URL of the current page. /// [HtmlAttributeName(UrlAttributeName)] - public Uri Url { get; set; } + public Uri? Url { get; set; } /// /// Gets the videos which should represent your object within the graph. Use the Media property to add a video file. /// - public IEnumerable Videos => this.Media?.OfType(); + public IEnumerable? Videos => this.Media?.OfType(); /// /// Gets or sets the view context. Workaround for context.Items not working across _Layout.cshtml and @@ -217,7 +217,7 @@ public abstract class OpenGraphMetadata : TagHelper /// [HtmlAttributeNotBound] [ViewContext] - public ViewContext ViewContext { get; set; } + public ViewContext ViewContext { get; set; } = default!; /// /// Gets the space delimited namespaces to be added to the prefix attribute of the head element in the HTML @@ -312,7 +312,7 @@ public virtual void ToString(StringBuilder stringBuilder) stringBuilder.AppendMetaPropertyContent("og:url", this.Url); // Add image, video and audio tags. - this.MainImage.ToString(stringBuilder); + this.MainImage?.ToString(stringBuilder); if (this.Media is not null) { foreach (var media in this.Media) diff --git a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphArticle.cs b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphArticle.cs index 41185333..a9dd5551 100644 --- a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphArticle.cs +++ b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphArticle.cs @@ -29,7 +29,7 @@ public class OpenGraphArticle : OpenGraphMetadata /// Gets or sets the URL's to the pages about the author who wrote the article. This URL must contain profile meta tags . /// [HtmlAttributeName(AuthorUrlsAttributeName)] - public IEnumerable AuthorUrls { get; set; } + public IEnumerable? AuthorUrls { get; set; } /// /// Gets or sets the expiration time, after which the article is out of date. @@ -59,19 +59,19 @@ public class OpenGraphArticle : OpenGraphMetadata /// This particular property is not part of the Open Graph standard but is documented by Facebook. /// [HtmlAttributeName(PublisherUrlAttributeName)] - public Uri PublisherUrl { get; set; } + public Uri? PublisherUrl { get; set; } /// /// Gets or sets the high-level section or category name e.g. Technology. /// [HtmlAttributeName(SectionAttributeName)] - public string Section { get; set; } + public string? Section { get; set; } /// /// Gets or sets the tag words associated with the article. /// [HtmlAttributeName(TagsAttributeName)] - public IEnumerable Tags { get; set; } + public IEnumerable? Tags { get; set; } /// /// Gets the type of your object. Depending on the type you specify, other properties may also be required. diff --git a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphBook.cs b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphBook.cs index 85571214..cc2d8d31 100644 --- a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphBook.cs +++ b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphBook.cs @@ -25,13 +25,13 @@ public class OpenGraphBook : OpenGraphMetadata /// Gets or sets the URL to the page about the author who wrote the book. This URL must contain profile meta tags . /// [HtmlAttributeName(AuthorUrlAttributeName)] - public Uri AuthorUrl { get; set; } + public Uri? AuthorUrl { get; set; } /// /// Gets or sets the books unique ISBN number. /// [HtmlAttributeName(ISBNAttributeName)] - public string ISBN { get; set; } + public string? ISBN { get; set; } /// /// Gets the namespace of this open graph type. @@ -48,7 +48,7 @@ public class OpenGraphBook : OpenGraphMetadata /// Gets or sets the tag words associated with the book. /// [HtmlAttributeName(TagsAttributeName)] - public IEnumerable Tags { get; set; } + public IEnumerable? Tags { get; set; } /// /// Gets the type of your object, e.g. "video.movie". Depending on the type you specify, other properties may also be required. diff --git a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphMusicAlbum.cs b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphMusicAlbum.cs index 7fd1dcf9..7ffdca5d 100644 --- a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphMusicAlbum.cs +++ b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphMusicAlbum.cs @@ -34,7 +34,7 @@ public class OpenGraphMusicAlbum : OpenGraphMetadata /// Gets or sets the URL's to the pages about the musicians who wrote the song. This URL must contain profile meta tags . /// [HtmlAttributeName(MusicianUrlsAttributeName)] - public IEnumerable MusicianUrls { get; set; } + public IEnumerable? MusicianUrls { get; set; } /// /// Gets or sets the release date of the album. @@ -64,7 +64,7 @@ public class OpenGraphMusicAlbum : OpenGraphMetadata /// Gets or sets the URL's to the pages about the songs on this album. This URL must contain profile meta tags . /// [HtmlAttributeName(SongUrlsAttributeName)] - public IEnumerable SongUrls { get; set; } + public IEnumerable? SongUrls { get; set; } /// /// Gets the type of your object. Depending on the type you specify, other properties may also be required. diff --git a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphMusicPlaylist.cs b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphMusicPlaylist.cs index fa5a8653..9f0c3074 100644 --- a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphMusicPlaylist.cs +++ b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphMusicPlaylist.cs @@ -28,7 +28,7 @@ public class OpenGraphMusicPlaylist : OpenGraphMetadata /// Gets or sets the URL to the page about the creator of the playlist. This URL must contain profile meta tags . /// [HtmlAttributeName(CreatorUrlAttributeName)] - public Uri CreatorUrl { get; set; } + public Uri? CreatorUrl { get; set; } /// /// Gets the namespace of this open graph type. @@ -51,7 +51,7 @@ public class OpenGraphMusicPlaylist : OpenGraphMetadata /// Gets or sets the URL's to the pages about the songs on this playlist. This URL must contain profile meta tags . /// [HtmlAttributeName(SongUrlsAttributeName)] - public IEnumerable SongUrls { get; set; } + public IEnumerable? SongUrls { get; set; } /// /// Gets the type of your object. Depending on the type you specify, other properties may also be required. @@ -74,7 +74,7 @@ public override void ToString(StringBuilder stringBuilder) stringBuilder.AppendMetaPropertyContentIfNotNull("music:song", this.SongUrls); // The number of songs on the playlist. This is a Facebook specific property. - stringBuilder.AppendMetaPropertyContentIfNotNull("music:song_count", this.SongUrls.Count()); + stringBuilder.AppendMetaPropertyContentIfNotNull("music:song_count", this.SongUrls?.Count()); stringBuilder.AppendMetaPropertyContent("music:song:disc", this.SongDisc); stringBuilder.AppendMetaPropertyContent("music:song:track", this.SongTrack); diff --git a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphMusicRadioStation.cs b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphMusicRadioStation.cs index 668a16f5..6b4aab19 100644 --- a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphMusicRadioStation.cs +++ b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphMusicRadioStation.cs @@ -22,7 +22,7 @@ public class OpenGraphMusicRadioStation : OpenGraphMetadata /// Gets or sets the URL to the page about the creator of the radio station. This URL must contain profile meta tags . /// [HtmlAttributeName(CreatorUrlAttributeName)] - public Uri CreatorUrl { get; set; } + public Uri? CreatorUrl { get; set; } /// /// Gets the namespace of this open graph type. diff --git a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphMusicSong.cs b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphMusicSong.cs index 95b7f5ef..43313c82 100644 --- a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphMusicSong.cs +++ b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphMusicSong.cs @@ -42,7 +42,7 @@ public class OpenGraphMusicSong : OpenGraphMetadata /// Gets or sets the URL's to the pages about the album the song comes from. This URL's must contain profile meta tags . /// [HtmlAttributeName(AlbumUrlsAttributeName)] - public IEnumerable AlbumUrls { get; set; } + public IEnumerable? AlbumUrls { get; set; } /// /// Gets or sets the duration of the song in seconds. @@ -55,7 +55,7 @@ public class OpenGraphMusicSong : OpenGraphMetadata /// Open Graph standard. /// [HtmlAttributeName(ISRCAttributeName)] - public string ISRC { get; set; } + public string? ISRC { get; set; } /// /// Gets the namespace of this open graph type. @@ -66,7 +66,7 @@ public class OpenGraphMusicSong : OpenGraphMetadata /// Gets or sets the URL's to the pages about the musicians who wrote the song. This URL's must contain profile meta tags . /// [HtmlAttributeName(MusicianUrlsAttributeName)] - public IEnumerable MusicianUrls { get; set; } + public IEnumerable? MusicianUrls { get; set; } /// /// Gets or sets the release date of the song. This is a Facebook specific property and is not specified in the Open Graph standard. diff --git a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphProfile.cs b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphProfile.cs index 76194f89..2651e60a 100644 --- a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphProfile.cs +++ b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphProfile.cs @@ -25,7 +25,7 @@ public class OpenGraphProfile : OpenGraphMetadata /// Gets or sets the name normally given to an individual by a parent or self-chosen. /// [HtmlAttributeName(FirstNameAttributeName)] - public string FirstName { get; set; } + public string? FirstName { get; set; } /// /// Gets or sets the gender. @@ -37,7 +37,7 @@ public class OpenGraphProfile : OpenGraphMetadata /// Gets or sets the name inherited from a family or marriage and by which the individual is commonly known. /// [HtmlAttributeName(LastNameAttributeName)] - public string LastName { get; set; } + public string? LastName { get; set; } /// /// Gets the namespace of this open graph type. @@ -53,7 +53,7 @@ public class OpenGraphProfile : OpenGraphMetadata /// Gets or sets the short unique string to identify them. /// [HtmlAttributeName(UsernameAttributeName)] - public string Username { get; set; } + public string? Username { get; set; } /// /// Appends a HTML-encoded string representing this instance to the containing the Open Graph meta tags. diff --git a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphVideoEpisode.cs b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphVideoEpisode.cs index f88d32aa..709ce3e1 100644 --- a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphVideoEpisode.cs +++ b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphVideoEpisode.cs @@ -30,13 +30,13 @@ public class OpenGraphVideoEpisode : OpenGraphMetadata /// Gets or sets the actors in the episode. /// [HtmlAttributeName(ActorsAttributeName)] - public IEnumerable Actors { get; set; } + public IEnumerable? Actors { get; set; } /// /// Gets or sets the URL's to the pages about the directors. This URL's must contain profile meta tags . /// [HtmlAttributeName(DirectorUrlsAttributeName)] - public IEnumerable DirectorUrls { get; set; } + public IEnumerable? DirectorUrls { get; set; } /// /// Gets or sets the duration of the episode in seconds. @@ -59,13 +59,13 @@ public class OpenGraphVideoEpisode : OpenGraphMetadata /// Gets or sets the URL to the page about the television series. This URL's must contain television show meta tags . /// [HtmlAttributeName(SeriesUrlAttributeName)] - public Uri SeriesUrl { get; set; } + public Uri? SeriesUrl { get; set; } /// /// Gets or sets the tag words associated with the episode. /// [HtmlAttributeName(TagsAttributeName)] - public IEnumerable Tags { get; set; } + public IEnumerable? Tags { get; set; } /// /// Gets the type of your object. Depending on the type you specify, other properties may also be required. @@ -76,7 +76,7 @@ public class OpenGraphVideoEpisode : OpenGraphMetadata /// Gets or sets the URL's to the pages about the writers. This URL's must contain profile meta tags . /// [HtmlAttributeName(WriterUrlsAttributeName)] - public IEnumerable WriterUrls { get; set; } + public IEnumerable? WriterUrls { get; set; } /// /// Appends a HTML-encoded string representing this instance to the containing the Open Graph meta tags. diff --git a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphVideoMovie.cs b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphVideoMovie.cs index b50124c6..880b40c7 100644 --- a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphVideoMovie.cs +++ b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphVideoMovie.cs @@ -29,13 +29,13 @@ public class OpenGraphVideoMovie : OpenGraphMetadata /// Gets or sets the actors in the movie. /// [HtmlAttributeName(ActorsAttributeName)] - public IEnumerable Actors { get; set; } + public IEnumerable? Actors { get; set; } /// /// Gets or sets the URL's to the pages about the directors. This URL's must contain profile meta tags . /// [HtmlAttributeName(DirectorUrlsAttributeName)] - public IEnumerable DirectorUrls { get; set; } + public IEnumerable? DirectorUrls { get; set; } /// /// Gets or sets the duration of the movie in seconds. @@ -58,7 +58,7 @@ public class OpenGraphVideoMovie : OpenGraphMetadata /// Gets or sets the tag words associated with the movie. /// [HtmlAttributeName(TagsAttributeName)] - public IEnumerable Tags { get; set; } + public IEnumerable? Tags { get; set; } /// /// Gets the type of your object. Depending on the type you specify, other properties may also be required. @@ -69,7 +69,7 @@ public class OpenGraphVideoMovie : OpenGraphMetadata /// Gets or sets the URL's to the pages about the writers. This URL's must contain profile meta tags . /// [HtmlAttributeName(WriterUrlsAttributeName)] - public IEnumerable WriterUrls { get; set; } + public IEnumerable? WriterUrls { get; set; } /// /// Appends a HTML-encoded string representing this instance to the containing the Open Graph meta tags. diff --git a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphVideoOther.cs b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphVideoOther.cs index 87fc03fa..d15c333a 100644 --- a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphVideoOther.cs +++ b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphVideoOther.cs @@ -29,13 +29,13 @@ public class OpenGraphVideoOther : OpenGraphMetadata /// Gets or sets the actors in the video. /// [HtmlAttributeName(ActorsAttributeName)] - public IEnumerable Actors { get; set; } + public IEnumerable? Actors { get; set; } /// /// Gets or sets the URL's to the pages about the directors. This URL's must contain profile meta tags . /// [HtmlAttributeName(DirectorUrlsAttributeName)] - public IEnumerable DirectorUrls { get; set; } + public IEnumerable? DirectorUrls { get; set; } /// /// Gets or sets the duration of the video in seconds. @@ -58,7 +58,7 @@ public class OpenGraphVideoOther : OpenGraphMetadata /// Gets or sets the tag words associated with the video. /// [HtmlAttributeName(TagsAttributeName)] - public IEnumerable Tags { get; set; } + public IEnumerable? Tags { get; set; } /// /// Gets the type of your object. Depending on the type you specify, other properties may also be required. @@ -69,7 +69,7 @@ public class OpenGraphVideoOther : OpenGraphMetadata /// Gets or sets the URL's to the pages about the writers. This URL's must contain profile meta tags . /// [HtmlAttributeName(WriterUrlsAttributeName)] - public IEnumerable WriterUrls { get; set; } + public IEnumerable? WriterUrls { get; set; } /// /// Appends a HTML-encoded string representing this instance to the containing the Open Graph meta tags. diff --git a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphVideoTvShow.cs b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphVideoTvShow.cs index 328f9cad..edfbec24 100644 --- a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphVideoTvShow.cs +++ b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/ObjectTypes/Standard/OpenGraphVideoTvShow.cs @@ -29,13 +29,13 @@ public class OpenGraphVideoTvShow : OpenGraphMetadata /// Gets or sets the actors in the television show. /// [HtmlAttributeName(ActorsAttributeName)] - public IEnumerable Actors { get; set; } + public IEnumerable? Actors { get; set; } /// /// Gets or sets the URL's to the pages about the directors. This URL's must contain profile meta tags . /// [HtmlAttributeName(DirectorUrlsAttributeName)] - public IEnumerable DirectorUrls { get; set; } + public IEnumerable? DirectorUrls { get; set; } /// /// Gets or sets the duration of the television show in seconds. @@ -58,7 +58,7 @@ public class OpenGraphVideoTvShow : OpenGraphMetadata /// Gets or sets the tag words associated with the television show. /// [HtmlAttributeName(TagsAttributeName)] - public IEnumerable Tags { get; set; } + public IEnumerable? Tags { get; set; } /// /// Gets the type of your object. Depending on the type you specify, other properties may also be required. @@ -69,7 +69,7 @@ public class OpenGraphVideoTvShow : OpenGraphMetadata /// Gets or sets the URL's to the pages about the writers. This URL's must contain profile meta tags . /// [HtmlAttributeName(WriterUrlsAttributeName)] - public IEnumerable WriterUrls { get; set; } + public IEnumerable? WriterUrls { get; set; } /// /// Appends a HTML-encoded string representing this instance to the containing the Open Graph meta tags. diff --git a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/OpenGraphPrefixTagHelper.cs b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/OpenGraphPrefixTagHelper.cs index 69416f8d..0f71d2ef 100644 --- a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/OpenGraphPrefixTagHelper.cs +++ b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/OpenGraphPrefixTagHelper.cs @@ -10,7 +10,7 @@ namespace Boxed.AspNetCore.TagHelpers.OpenGraph /// Adds the open graph prefix attribute to the head tag. The prefix is different depending on the type of open /// graph object being used. /// - /// + /// [HtmlTargetElement("head", Attributes = EnabledAttributeName)] public class OpenGraphPrefixTagHelper : TagHelper { @@ -36,7 +36,7 @@ public class OpenGraphPrefixTagHelper : TagHelper /// [HtmlAttributeNotBound] [ViewContext] - public ViewContext ViewContext { get; set; } + public ViewContext ViewContext { get; set; } = default!; /// /// Asynchronously executes the with the given and diff --git a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/Structs/OpenGraphActor.cs b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/Structs/OpenGraphActor.cs index 9e71875a..fb27da9d 100644 --- a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/Structs/OpenGraphActor.cs +++ b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/Structs/OpenGraphActor.cs @@ -33,6 +33,6 @@ public OpenGraphActor(Uri actorUrl, string role) /// /// Gets or sets the role the actor played. /// - public string Role { get; set; } + public string? Role { get; set; } } } diff --git a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/Structs/OpenGraphContactData.cs b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/Structs/OpenGraphContactData.cs index a19eaf85..41eb1cc1 100644 --- a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/Structs/OpenGraphContactData.cs +++ b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/Structs/OpenGraphContactData.cs @@ -14,7 +14,7 @@ public class OpenGraphContactData /// The city (or locality) line of the postal address for this business. /// The postcode (or ZIP code) of the postal address for this business. /// The country of the postal address for this business. - /// streetAddress or locality or postalCode or country is null.. + /// streetAddress or locality or postalCode or country is null.. public OpenGraphContactData(string streetAddress, string locality, string postalCode, string country) { this.Country = country ?? throw new ArgumentNullException(nameof(country)); @@ -31,12 +31,12 @@ public OpenGraphContactData(string streetAddress, string locality, string postal /// /// Gets or sets the email address to contact this business. /// - public string Email { get; set; } + public string? Email { get; set; } /// /// Gets or sets a fax number to contact this business. /// - public string Fax { get; set; } + public string? Fax { get; set; } /// /// Gets the city (or locality) line of the postal address for this business. @@ -46,7 +46,7 @@ public OpenGraphContactData(string streetAddress, string locality, string postal /// /// Gets or sets a telephone number to contact this business. /// - public string Phone { get; set; } + public string? Phone { get; set; } /// /// Gets the postcode (or ZIP code) of the postal address for this business. @@ -56,7 +56,7 @@ public OpenGraphContactData(string streetAddress, string locality, string postal /// /// Gets or sets the state (or region) line of the postal address for this business. /// - public string Region { get; set; } + public string? Region { get; set; } /// /// Gets the number and street of the postal address for this business. @@ -66,6 +66,6 @@ public OpenGraphContactData(string streetAddress, string locality, string postal /// /// Gets or sets a website for this business. /// - public string Website { get; set; } + public string? Website { get; set; } } } diff --git a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/Structs/OpenGraphFitnessActivityDataPoint.cs b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/Structs/OpenGraphFitnessActivityDataPoint.cs index f7a13944..5c70fcde 100644 --- a/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/Structs/OpenGraphFitnessActivityDataPoint.cs +++ b/Source/Boxed.AspNetCore.TagHelpers/OpenGraph/Structs/OpenGraphFitnessActivityDataPoint.cs @@ -15,27 +15,27 @@ public class OpenGraphFitnessActivityDataPoint /// /// Gets or sets the energy used during a distinct part of the course. /// - public OpenGraphQuantity CustomUnitEnergy { get; set; } + public OpenGraphQuantity? CustomUnitEnergy { get; set; } /// /// Gets or sets the distance covered during a distinct part of the course. /// - public OpenGraphQuantity Distance { get; set; } + public OpenGraphQuantity? Distance { get; set; } /// /// Gets or sets the location of a distinct part of the course. /// - public OpenGraphLocation Location { get; set; } + public OpenGraphLocation? Location { get; set; } /// /// Gets or sets the pace achieved during distinct parts of the course. /// - public OpenGraphQuantity Pace { get; set; } + public OpenGraphQuantity? Pace { get; set; } /// /// Gets or sets the speed achieved during a distinct part of the course. /// - public OpenGraphQuantity Speed { get; set; } + public OpenGraphQuantity? Speed { get; set; } /// /// Gets or sets the number of steps taken during a distinct part of the course. diff --git a/Source/Boxed.AspNetCore.TagHelpers/SrcSubresourceIntegrityTagHelper.cs b/Source/Boxed.AspNetCore.TagHelpers/SrcSubresourceIntegrityTagHelper.cs index 14553749..56591399 100644 --- a/Source/Boxed.AspNetCore.TagHelpers/SrcSubresourceIntegrityTagHelper.cs +++ b/Source/Boxed.AspNetCore.TagHelpers/SrcSubresourceIntegrityTagHelper.cs @@ -34,7 +34,7 @@ public SrcSubresourceIntegrityTagHelper( /// [HtmlAttributeName(SubresourceIntegritySrcAttributeName)] - public override string Source { get; set; } + public override string? Source { get; set; } /// protected override string UrlAttributeName => SrcAttributeName; diff --git a/Source/Boxed.AspNetCore.TagHelpers/StringBuilderExtensions.cs b/Source/Boxed.AspNetCore.TagHelpers/StringBuilderExtensions.cs index 5b795eb3..49dd1d29 100644 --- a/Source/Boxed.AspNetCore.TagHelpers/StringBuilderExtensions.cs +++ b/Source/Boxed.AspNetCore.TagHelpers/StringBuilderExtensions.cs @@ -34,11 +34,11 @@ public static void AppendMetaNameContent(this StringBuilder stringBuilder, st /// The string builder. /// The name value of the meta tag. /// The content value of the meta tag. - public static void AppendMetaNameContentIfNotNull(this StringBuilder stringBuilder, string name, T content) + public static void AppendMetaNameContentIfNotNull(this StringBuilder stringBuilder, string name, T? content) { if (content is not null) { - AppendMetaNameContent(stringBuilder, name, content); + AppendMetaNameContent(stringBuilder, name, content); } } @@ -112,11 +112,11 @@ public static void AppendMetaPropertyContent( public static void AppendMetaPropertyContentIfNotNull( this StringBuilder stringBuilder, string property, - T content) + T? content) { if (content is not null) { - AppendMetaPropertyContent(stringBuilder, property, content); + AppendMetaPropertyContent(stringBuilder, property, content); } } @@ -150,7 +150,7 @@ public static void AppendMetaPropertyContentIfNotNull( public static void AppendMetaPropertyContentIfNotNull( this StringBuilder stringBuilder, string property, - IEnumerable content) + IEnumerable? content) { if (content is not null) { diff --git a/Source/Boxed.AspNetCore.TagHelpers/SubresourceIntegrityTagHelper.cs b/Source/Boxed.AspNetCore.TagHelpers/SubresourceIntegrityTagHelper.cs index def377f9..3a235168 100644 --- a/Source/Boxed.AspNetCore.TagHelpers/SubresourceIntegrityTagHelper.cs +++ b/Source/Boxed.AspNetCore.TagHelpers/SubresourceIntegrityTagHelper.cs @@ -80,7 +80,7 @@ public SubresourceIntegrityTagHelper( /// /// The source file. /// - public virtual string Source { get; set; } + public virtual string? Source { get; set; } /// /// Gets the name of the attribute which contains the URL to the resource. @@ -246,7 +246,7 @@ private string GetSubresourceIntegrityFromContentFile( { var filePath = Path.Combine( this.webHostEnvironment.ContentRootPath, - this.urlHelper.Content(contentPath).TrimStart('/')); + this.urlHelper.Content(contentPath)?.TrimStart('/') ?? string.Empty); var bytes = this.ReadAllBytes(filePath); return GetSpaceDelimetedSri(bytes, hashAlgorithms); } @@ -280,7 +280,7 @@ private string GetEncodedStringValue(object attributeValue) } } - return attributeValue.ToString(); + return attributeValue.ToString()!; } } } diff --git a/Source/Boxed.AspNetCore.TagHelpers/Twitter/Cards/TwitterCardApp.cs b/Source/Boxed.AspNetCore.TagHelpers/Twitter/Cards/TwitterCardApp.cs index 2fd61113..e0c98dd7 100644 --- a/Source/Boxed.AspNetCore.TagHelpers/Twitter/Cards/TwitterCardApp.cs +++ b/Source/Boxed.AspNetCore.TagHelpers/Twitter/Cards/TwitterCardApp.cs @@ -29,7 +29,7 @@ public class TwitterCardApp : TwitterCard /// must set this value to the two-letter country code for the App Store that contains your application. /// [HtmlAttributeName(CountryAttributeName)] - public string Country { get; set; } + public string? Country { get; set; } /// /// Gets or sets the description that concisely summarizes the content of the page, as @@ -39,13 +39,13 @@ public class TwitterCardApp : TwitterCard /// Facebook's Open Graph og:description, do not use this unless you want a different description. /// [HtmlAttributeName(DescriptionAttributeName)] - public string Description { get; set; } + public string? Description { get; set; } /// /// Gets or sets the numeric representation of your app ID in Google Play (.i.e. "com.android.app"). /// [HtmlAttributeName(GooglePlayAttributeName)] - public string GooglePlay { get; set; } + public string? GooglePlay { get; set; } /// /// Gets or sets your google play app’s custom URL scheme (you must include "://" after your @@ -53,28 +53,28 @@ public class TwitterCardApp : TwitterCard /// [HtmlAttributeName(GooglePlayCustomUrlSchemeAttributeName)] #pragma warning disable CA1056 // Uri properties should not be strings - public string GooglePlayCustomUrlScheme { get; set; } + public string? GooglePlayCustomUrlScheme { get; set; } #pragma warning restore CA1056 // Uri properties should not be strings /// /// Gets or sets numeric representation of your iPad app ID in the App Store (.i.e. "307234931"). /// [HtmlAttributeName(IPadAttributeName)] - public string IPad { get; set; } + public string? IPad { get; set; } /// /// Gets or sets your iPad app’s custom URL scheme (you must include "://" after your scheme name). /// [HtmlAttributeName(IPadCustomUrlSchemeAttributeName)] #pragma warning disable CA1056 // Uri properties should not be strings - public string IPadCustomUrlScheme { get; set; } + public string? IPadCustomUrlScheme { get; set; } #pragma warning restore CA1056 // Uri properties should not be strings /// /// Gets or sets numeric representation of your iPhone app ID in the App Store (.i.e. “307234931”). /// [HtmlAttributeName(IPhoneAttributeName)] - public string IPhone { get; set; } + public string? IPhone { get; set; } /// /// Gets or sets your iPhone app’s custom URL scheme (you must include "://" after your @@ -82,7 +82,7 @@ public class TwitterCardApp : TwitterCard /// [HtmlAttributeName(IPhoneCustomUrlSchemeAttributeName)] #pragma warning disable CA1056 // Uri properties should not be strings - public string IPhoneCustomUrlScheme { get; set; } + public string? IPhoneCustomUrlScheme { get; set; } #pragma warning restore CA1056 // Uri properties should not be strings /// @@ -137,4 +137,4 @@ protected override void Validate() } } } -} \ No newline at end of file +} diff --git a/Source/Boxed.AspNetCore.TagHelpers/Twitter/Cards/TwitterCardPlayer.cs b/Source/Boxed.AspNetCore.TagHelpers/Twitter/Cards/TwitterCardPlayer.cs index ddc03a72..8f10b0cd 100644 --- a/Source/Boxed.AspNetCore.TagHelpers/Twitter/Cards/TwitterCardPlayer.cs +++ b/Source/Boxed.AspNetCore.TagHelpers/Twitter/Cards/TwitterCardPlayer.cs @@ -30,7 +30,7 @@ public class TwitterCardPlayer : TwitterCard /// Facebook's Open Graph og:description, do not use this unless you want a different description. /// [HtmlAttributeName(DescriptionAttributeName)] - public string Description { get; set; } + public string? Description { get; set; } /// /// Gets or sets the image to be displayed in place of the player on platforms that don’t @@ -39,14 +39,14 @@ public class TwitterCardPlayer : TwitterCard /// image) will cause the player card not to render. Image must be less than 1MB in size. /// [HtmlAttributeName(ImageAttributeName)] - public TwitterImage Image { get; set; } + public TwitterImage? Image { get; set; } /// /// Gets or sets the video player. If the iframe is wider than 435px, the iframe player will /// be resized to fit a max width of 435px, maintaining the original aspect ratio. /// [HtmlAttributeName(PlayerAttributeName)] - public TwitterPlayer Player { get; set; } + public TwitterPlayer? Player { get; set; } /// /// Gets or sets the title of the summary. Title should be concise and will be truncated at @@ -54,7 +54,7 @@ public class TwitterCardPlayer : TwitterCard /// you want a different title. /// [HtmlAttributeName(TitleAttributeName)] - public string Title { get; set; } + public string? Title { get; set; } /// /// Gets the type of the Twitter card. @@ -78,13 +78,13 @@ public override void ToString(StringBuilder stringBuilder) stringBuilder.AppendMetaNameContentIfNotNull("twitter:site:Id", this.SiteId); stringBuilder.AppendMetaNameContentIfNotNull("twitter:title", this.Title); stringBuilder.AppendMetaNameContentIfNotNull("twitter:description", this.Description); - stringBuilder.AppendMetaNameContent("twitter:image", this.Image.ImageUrl); - stringBuilder.AppendMetaNameContentIfNotNull("twitter:image:height", this.Image.Height); - stringBuilder.AppendMetaNameContentIfNotNull("twitter:image:width", this.Image.Width); - stringBuilder.AppendMetaNameContent("twitter:player", this.Player.PlayerUrl); - stringBuilder.AppendMetaNameContent("twitter:player:width", this.Player.Width); - stringBuilder.AppendMetaNameContent("twitter:player:height", this.Player.Height); - stringBuilder.AppendMetaNameContentIfNotNull("twitter:player:stream", this.Player.StreamUrl); + stringBuilder.AppendMetaNameContent("twitter:image", this.Image?.ImageUrl); + stringBuilder.AppendMetaNameContentIfNotNull("twitter:image:height", this.Image?.Height); + stringBuilder.AppendMetaNameContentIfNotNull("twitter:image:width", this.Image?.Width); + stringBuilder.AppendMetaNameContent("twitter:player", this.Player?.PlayerUrl); + stringBuilder.AppendMetaNameContent("twitter:player:width", this.Player?.Width); + stringBuilder.AppendMetaNameContent("twitter:player:height", this.Player?.Height); + stringBuilder.AppendMetaNameContentIfNotNull("twitter:player:stream", this.Player?.StreamUrl); } /// @@ -135,4 +135,4 @@ protected override void Validate() } } } -} \ No newline at end of file +} diff --git a/Source/Boxed.AspNetCore.TagHelpers/Twitter/Cards/TwitterCardSummary.cs b/Source/Boxed.AspNetCore.TagHelpers/Twitter/Cards/TwitterCardSummary.cs index 6a8d7f13..5d3600da 100644 --- a/Source/Boxed.AspNetCore.TagHelpers/Twitter/Cards/TwitterCardSummary.cs +++ b/Source/Boxed.AspNetCore.TagHelpers/Twitter/Cards/TwitterCardSummary.cs @@ -27,7 +27,7 @@ public class TwitterCardSummary : TwitterCard /// Facebook's Open Graph og:description, do not use this unless you want a different description. /// [HtmlAttributeName(DescriptionAttributeName)] - public string Description { get; set; } + public string? Description { get; set; } /// /// Gets or sets the URL to a unique image representing the content of the page. Do not use a @@ -40,7 +40,7 @@ public class TwitterCardSummary : TwitterCard /// is recommended to get supply a smaller image that fits Twitters needs. /// [HtmlAttributeName(ImageAttributeName)] - public TwitterImage Image { get; set; } + public TwitterImage? Image { get; set; } /// /// Gets or sets the title of the summary. Title should be concise and will be truncated at @@ -48,7 +48,7 @@ public class TwitterCardSummary : TwitterCard /// you want a different title. /// [HtmlAttributeName(TitleAttributeName)] - public string Title { get; set; } + public string? Title { get; set; } /// /// Gets the type of the Twitter card. diff --git a/Source/Boxed.AspNetCore.TagHelpers/Twitter/Structs/TwitterPlayer.cs b/Source/Boxed.AspNetCore.TagHelpers/Twitter/Structs/TwitterPlayer.cs index a3c97447..60664cbd 100644 --- a/Source/Boxed.AspNetCore.TagHelpers/Twitter/Structs/TwitterPlayer.cs +++ b/Source/Boxed.AspNetCore.TagHelpers/Twitter/Structs/TwitterPlayer.cs @@ -89,7 +89,7 @@ public TwitterPlayer(Uri playerUrl, int width, int height, string streamContentT /// (MIME Type Registration for MP4). /// /// The type of the stream content. - public string StreamContentType { get; set; } + public string? StreamContentType { get; set; } /// /// Gets or sets the URL to a raw stream that will be rendered in Twitter’s mobile applications directly. If @@ -98,7 +98,7 @@ public TwitterPlayer(Uri playerUrl, int width, int height, string streamContentT /// to 640 x 480 at 30 fps. Audio: AAC, Low Complexity Profile(LC). /// /// The URL to a raw stream that will be rendered in Twitter’s mobile applications directly.. - public Uri StreamUrl { get; set; } + public Uri? StreamUrl { get; set; } /// /// Gets the width of the iFrame player in pixels. @@ -106,4 +106,4 @@ public TwitterPlayer(Uri playerUrl, int width, int height, string streamContentT /// The width of the iFrame player in pixels.. public int Width { get; } } -} \ No newline at end of file +} diff --git a/Source/Boxed.AspNetCore.TagHelpers/Twitter/TwitterCard.cs b/Source/Boxed.AspNetCore.TagHelpers/Twitter/TwitterCard.cs index 0fa21bb3..35aecae2 100644 --- a/Source/Boxed.AspNetCore.TagHelpers/Twitter/TwitterCard.cs +++ b/Source/Boxed.AspNetCore.TagHelpers/Twitter/TwitterCard.cs @@ -40,20 +40,20 @@ public abstract class TwitterCard : TagHelper /// /// The Twitter user ID of content creator. [HtmlAttributeName(CreatorIdAttributeName)] - public string CreatorId { get; set; } + public string? CreatorId { get; set; } /// /// Gets or sets the Twitter @username of content creator e.g. @RehanSaeedUK. /// [HtmlAttributeName(CreatorUsernameAttributeName)] - public string CreatorUsername { get; set; } + public string? CreatorUsername { get; set; } /// /// Gets or sets the Site's Twitter site Id. Either twitter:site or twitter:site:id is required. /// /// The twitter Id for the site. [HtmlAttributeName(SiteIdAttributName)] - public string SiteId { get; set; } + public string? SiteId { get; set; } /// /// Gets or sets the twitter site username. e.g. @Microsoft. @@ -62,7 +62,7 @@ public abstract class TwitterCard : TagHelper /// The Site's Twitter @username the card should be attributed to. Required for Twitter Card analytics. /// [HtmlAttributeName(SiteUsernameAttributeName)] - public string SiteUsername { get; set; } + public string? SiteUsername { get; set; } /// /// Gets the type of the Twitter card. @@ -135,4 +135,4 @@ protected virtual void Validate() { } } -} \ No newline at end of file +} diff --git a/Source/Boxed.AspNetCore/ApplicationBuilderExtensions.cs b/Source/Boxed.AspNetCore/ApplicationBuilderExtensions.cs index b4ee06b7..0d74335a 100644 --- a/Source/Boxed.AspNetCore/ApplicationBuilderExtensions.cs +++ b/Source/Boxed.AspNetCore/ApplicationBuilderExtensions.cs @@ -25,7 +25,7 @@ public static IApplicationBuilder UseHttpException(this IApplicationBuilder appl /// The same application builder. public static IApplicationBuilder UseHttpException( this IApplicationBuilder application, - Action configureOptions) + Action? configureOptions) { if (application is null) { diff --git a/Source/Boxed.AspNetCore/Cursor.cs b/Source/Boxed.AspNetCore/Cursor.cs index 2de754bb..3f854d84 100644 --- a/Source/Boxed.AspNetCore/Cursor.cs +++ b/Source/Boxed.AspNetCore/Cursor.cs @@ -17,7 +17,7 @@ public static class Cursor /// The type of the cursor value. /// The cursor. /// The cursor value. - public static T FromCursor(string cursor) + public static T? FromCursor(string cursor) { if (string.IsNullOrEmpty(cursor)) { @@ -54,7 +54,7 @@ public static T FromCursor(string cursor) /// The get cursor property. /// The first and last cursor in the collection. /// is null. - public static (string FirstCursor, string LastCursor) GetFirstAndLastCursor( + public static (string? FirstCursor, string? LastCursor) GetFirstAndLastCursor( IEnumerable enumerable, Func getCursorProperty) { @@ -93,7 +93,7 @@ public static string ToCursor(T value) return Base64Encode(dateTimeOffset.ToString("o", CultureInfo.InvariantCulture)); } - return Base64Encode(value.ToString()); + return Base64Encode(value.ToString()!); } private static string Base64Decode(string value) => Encoding.UTF8.GetString(Convert.FromBase64String(value)); diff --git a/Source/Boxed.AspNetCore/DistributedCacheExtensions.cs b/Source/Boxed.AspNetCore/DistributedCacheExtensions.cs index 05494bd4..6abb390d 100644 --- a/Source/Boxed.AspNetCore/DistributedCacheExtensions.cs +++ b/Source/Boxed.AspNetCore/DistributedCacheExtensions.cs @@ -23,10 +23,10 @@ public static class DistributedCacheExtensions /// The value of type or null if the key was not found. /// or is /// null. - public static async Task GetAsJsonAsync( + public static async Task GetAsJsonAsync( this IDistributedCache cache, string key, - JsonSerializerOptions jsonSerializerOptions = null, + JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) { if (cache is null) @@ -61,8 +61,8 @@ public static Task SetAsJsonAsync( this IDistributedCache cache, string key, T value, - DistributedCacheEntryOptions options = null, - JsonSerializerOptions jsonSerializerOptions = null, + DistributedCacheEntryOptions? options = null, + JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) where T : class { @@ -80,7 +80,7 @@ public static Task SetAsJsonAsync( return cache.SetAsync(key, bytes, options, cancellationToken); } - private static T Deserialize(byte[] bytes, JsonSerializerOptions jsonSerializerOptions) + private static T? Deserialize(byte[] bytes, JsonSerializerOptions? jsonSerializerOptions) { var utf8JsonReader = new Utf8JsonReader(bytes); return JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); diff --git a/Source/Boxed.AspNetCore/Filters/NoTrailingSlashAttribute.cs b/Source/Boxed.AspNetCore/Filters/NoTrailingSlashAttribute.cs index d9630cef..8552e77f 100644 --- a/Source/Boxed.AspNetCore/Filters/NoTrailingSlashAttribute.cs +++ b/Source/Boxed.AspNetCore/Filters/NoTrailingSlashAttribute.cs @@ -39,7 +39,7 @@ public void OnResourceExecuting(ResourceExecutingContext context) var path = context.HttpContext.Request.Path; if (path.HasValue) { - if (path.Value[^1] == SlashCharacter) + if (path.Value![^1] == SlashCharacter) { this.HandleTrailingSlashRequest(context); } diff --git a/Source/Boxed.AspNetCore/RedirectToCanonicalUrlRule.cs b/Source/Boxed.AspNetCore/RedirectToCanonicalUrlRule.cs index 43d15316..dfa8125e 100644 --- a/Source/Boxed.AspNetCore/RedirectToCanonicalUrlRule.cs +++ b/Source/Boxed.AspNetCore/RedirectToCanonicalUrlRule.cs @@ -1,6 +1,7 @@ namespace Boxed.AspNetCore { using System; + using System.Diagnostics.CodeAnalysis; using Boxed.AspNetCore.Filters; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Extensions; @@ -90,7 +91,7 @@ public void ApplyRule(RewriteContext context) /// The . /// The canonical URL. /// true if the URL is canonical, otherwise false. - protected virtual bool TryGetCanonicalUrl(RewriteContext context, out Uri canonicalUrl) + protected virtual bool TryGetCanonicalUrl(RewriteContext context, [NotNullWhen(false)] out Uri? canonicalUrl) { if (context is null) { @@ -100,13 +101,13 @@ protected virtual bool TryGetCanonicalUrl(RewriteContext context, out Uri canoni var isCanonical = true; var request = context.HttpContext.Request; - var hasPath = request.Path.HasValue && (request.Path.Value.Length > 1); + var hasPath = request.Path.HasValue && (request.Path.Value!.Length > 1); // If we are not dealing with the home page. Note, the home page is a special case and it doesn't matter // if there is a trailing slash or not. Both will be treated as the same by search engines. if (hasPath) { - var hasTrailingSlash = request.Path.Value[^1] == SlashCharacter; + var hasTrailingSlash = request.Path.Value![^1] == SlashCharacter; if (this.AppendTrailingSlash) { @@ -132,7 +133,7 @@ protected virtual bool TryGetCanonicalUrl(RewriteContext context, out Uri canoni { if (this.LowercaseUrls && !this.HasAttribute(context)) { - foreach (var character in request.Path.Value) + foreach (var character in request.Path.Value!) { if (char.IsUpper(character)) { @@ -146,7 +147,7 @@ protected virtual bool TryGetCanonicalUrl(RewriteContext context, out Uri canoni if (request.QueryString.HasValue && !this.HasAttribute(context)) { - foreach (var character in request.QueryString.Value) + foreach (var character in request.QueryString.Value!) { if (char.IsUpper(character)) { @@ -212,7 +213,7 @@ protected virtual bool HasAttribute(RewriteContext context) } var endpoint = context.HttpContext.GetEndpoint(); - return endpoint.Metadata.GetMetadata() is not null; + return endpoint?.Metadata?.GetMetadata() is not null; } } } diff --git a/Source/Boxed.DotnetNewTest/AssemblyResolver.cs b/Source/Boxed.DotnetNewTest/AssemblyResolver.cs index 8ecd8ea8..2b7eb212 100644 --- a/Source/Boxed.DotnetNewTest/AssemblyResolver.cs +++ b/Source/Boxed.DotnetNewTest/AssemblyResolver.cs @@ -36,7 +36,7 @@ public AssemblyResolver(string path) new PackageCompilationAssemblyResolver(), }); - this.loadContext = AssemblyLoadContext.GetLoadContext(this.Assembly); + this.loadContext = AssemblyLoadContext.GetLoadContext(this.Assembly)!; this.loadContext.Resolving += this.OnResolving; } @@ -48,7 +48,7 @@ public AssemblyResolver(string path) /// public void Dispose() => this.loadContext.Resolving -= this.OnResolving; - private Assembly OnResolving(AssemblyLoadContext context, AssemblyName name) + private Assembly? OnResolving(AssemblyLoadContext context, AssemblyName name) { bool NamesMatch(RuntimeLibrary runtime) => string.Equals(runtime.Name, name.Name, StringComparison.OrdinalIgnoreCase); diff --git a/Source/Boxed.DotnetNewTest/DirectoryExtensions.cs b/Source/Boxed.DotnetNewTest/DirectoryExtensions.cs index 719495a6..6ad53c67 100644 --- a/Source/Boxed.DotnetNewTest/DirectoryExtensions.cs +++ b/Source/Boxed.DotnetNewTest/DirectoryExtensions.cs @@ -98,7 +98,7 @@ public static string GetShortTempDirectoryPath() => /// /// The directory for the currently executing assembly. public static string GetCurrentDirectory() => - Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!; /// /// Tries to delete the specified directory. diff --git a/Source/Boxed.DotnetNewTest/DotnetNew.cs b/Source/Boxed.DotnetNewTest/DotnetNew.cs index cc39d712..dfadf1b0 100644 --- a/Source/Boxed.DotnetNewTest/DotnetNew.cs +++ b/Source/Boxed.DotnetNewTest/DotnetNew.cs @@ -99,9 +99,9 @@ await ProcessExtensions } } - private static string GetFilePath(Assembly assembly, string projectName) + private static string? GetFilePath(Assembly assembly, string projectName) { - string projectFilePath = null; + string? projectFilePath = null; for (var directory = new DirectoryInfo(assembly.Location); directory.Parent is not null; directory = directory.Parent) { @@ -120,7 +120,7 @@ private static string GetFilePath(Assembly assembly, string projectName) return projectFilePath; } - private static bool IsInObjDirectory(DirectoryInfo directoryInfo) + private static bool IsInObjDirectory(DirectoryInfo? directoryInfo) { if (directoryInfo is null) { diff --git a/Source/Boxed.DotnetNewTest/ProcessExtensions.StartAsync.cs b/Source/Boxed.DotnetNewTest/ProcessExtensions.StartAsync.cs index c9b40e32..e0ecc3ef 100644 --- a/Source/Boxed.DotnetNewTest/ProcessExtensions.StartAsync.cs +++ b/Source/Boxed.DotnetNewTest/ProcessExtensions.StartAsync.cs @@ -171,16 +171,16 @@ private static Task ReadAsync( TextWriter textWriter, CancellationToken cancellationToken = default) { - var taskCompletionSource = new TaskCompletionSource(); + var taskCompletionSource = new TaskCompletionSource(); - DataReceivedEventHandler handler = null; + DataReceivedEventHandler handler = null!; handler = new DataReceivedEventHandler( (sender, e) => { if (e.Data is null) { removeHandler(handler); - taskCompletionSource.TrySetResult(null); + taskCompletionSource.SetResult(); } else { diff --git a/Source/Boxed.DotnetNewTest/ProcessExtensions.cs b/Source/Boxed.DotnetNewTest/ProcessExtensions.cs index ac62407b..a5aabebf 100644 --- a/Source/Boxed.DotnetNewTest/ProcessExtensions.cs +++ b/Source/Boxed.DotnetNewTest/ProcessExtensions.cs @@ -24,13 +24,13 @@ public static Task StartAndWaitForExitAsync(this Process process) throw new ArgumentNullException(nameof(process)); } - var taskCompletionSource = new TaskCompletionSource(); + var taskCompletionSource = new TaskCompletionSource(); process.EnableRaisingEvents = true; process.Exited += (s, a) => { - taskCompletionSource.SetResult(null); + taskCompletionSource.SetResult(); process.Dispose(); }; @@ -56,7 +56,7 @@ public static Task WaitForExitAsync( throw new ArgumentNullException(nameof(process)); } - var taskCompletionSource = new TaskCompletionSource(); + var taskCompletionSource = new TaskCompletionSource(); process.EnableRaisingEvents = true; @@ -73,10 +73,10 @@ public static Task WaitForExitAsync( return taskCompletionSource.Task; - void OnExited(object sender, EventArgs e) + void OnExited(object? sender, EventArgs e) { process.Exited -= OnExited; - taskCompletionSource.TrySetResult(null); + taskCompletionSource.TrySetResult(); } } @@ -112,7 +112,7 @@ private static void GetAllChildIdsUnix(int parentId, ISet children, TimeSpa } } - private static int RunProcessAndWaitForExit(string fileName, string arguments, TimeSpan timeout, out string stdout) + private static int RunProcessAndWaitForExit(string fileName, string arguments, TimeSpan timeout, out string? stdout) { var startInfo = new ProcessStartInfo { @@ -122,7 +122,7 @@ private static int RunProcessAndWaitForExit(string fileName, string arguments, T UseShellExecute = false, }; - var process = Process.Start(startInfo); + var process = Process.Start(startInfo)!; stdout = null; if (process.WaitForExit((int)timeout.TotalMilliseconds)) diff --git a/Source/Boxed.DotnetNewTest/Project.cs b/Source/Boxed.DotnetNewTest/Project.cs index 9da2b671..c31c3229 100644 --- a/Source/Boxed.DotnetNewTest/Project.cs +++ b/Source/Boxed.DotnetNewTest/Project.cs @@ -16,7 +16,7 @@ public class Project /// The HTTPS port. /// The HTTP port. public Project( - string name, + string? name, string directoryPath, string publishDirectoryPath, int httpsPort, @@ -37,7 +37,7 @@ public Project( /// /// Gets the name of the project. /// - public string Name { get; } + public string? Name { get; } /// /// Gets the publish directory path to the project. diff --git a/Source/Boxed.DotnetNewTest/ProjectExtensions.cs b/Source/Boxed.DotnetNewTest/ProjectExtensions.cs index acccc131..1e78d7c5 100644 --- a/Source/Boxed.DotnetNewTest/ProjectExtensions.cs +++ b/Source/Boxed.DotnetNewTest/ProjectExtensions.cs @@ -151,7 +151,7 @@ await AssertStartAsync( /// A task representing the operation. public static async Task DotnetCakeAsync( this Project project, - string target = null, + string? target = null, TimeSpan? timeout = null, bool showShellWindow = false) { @@ -185,8 +185,8 @@ await AssertStartAsync( /// A task representing the operation. public static async Task DotnetPublishAsync( this Project project, - string framework = null, - string runtime = null, + string? framework = null, + string? runtime = null, bool? noRestore = true, TimeSpan? timeout = null, bool showShellWindow = false) @@ -230,7 +230,7 @@ public static async Task DotnetRunAsync( Func> readinessCheck, Func action, bool? noRestore = true, - Func validateCertificate = null, + Func? validateCertificate = null, TimeSpan? timeout = null, bool showShellWindow = false) { @@ -294,10 +294,10 @@ public static async Task DotnetRunAsync( public static async Task DotnetRunAsync( this Project project, string projectRelativeDirectoryPath, - Func> readinessCheck, + Func> readinessCheck, Func action, bool? noRestore = true, - Func validateCertificate = null, + Func? validateCertificate = null, TimeSpan? timeout = null, bool showShellWindow = false) { @@ -409,9 +409,9 @@ internal static async Task DotnetRunInMemoryAsync( } private static async Task DotnetRunInternalAsync( - Func> readinessCheck, + Func> readinessCheck, HttpClient httpClient, - HttpClient httpsClient, + HttpClient? httpsClient, string directoryPath, bool? noRestore, TimeSpan? timeout, @@ -470,9 +470,9 @@ async static ValueTask Dispose(CancellationTokenSource cancellationTokenSource, } private static async Task WaitForStartAsync( - Func> readinessCheck, + Func> readinessCheck, HttpClient httpClient, - HttpClient httpsClient, + HttpClient? httpsClient, TimeSpan timeout) { const int intervalMilliseconds = 100; @@ -517,8 +517,8 @@ private static async Task WaitForStartAsync( private static bool DefaultValidateCertificate( HttpRequestMessage request, - X509Certificate2 certificate, - X509Chain chain, + X509Certificate2? certificate, + X509Chain? chain, SslPolicyErrors errors) => true; private static async Task AssertStartAsync( diff --git a/Source/Boxed.DotnetNewTest/TempDirectoryExtensions.cs b/Source/Boxed.DotnetNewTest/TempDirectoryExtensions.cs index 20e226d1..5ba51a99 100644 --- a/Source/Boxed.DotnetNewTest/TempDirectoryExtensions.cs +++ b/Source/Boxed.DotnetNewTest/TempDirectoryExtensions.cs @@ -26,8 +26,8 @@ public static class TempDirectoryExtensions public static async Task DotnetNewAsync( this TempDirectory tempDirectory, string templateName, - string name = null, - IDictionary arguments = null, + string? name = null, + IDictionary? arguments = null, TimeSpan? timeout = null, bool showShellWindow = false) { diff --git a/Source/Boxed.DotnetNewTest/TestLogger.cs b/Source/Boxed.DotnetNewTest/TestLogger.cs index 1df5e297..8d591bd2 100644 --- a/Source/Boxed.DotnetNewTest/TestLogger.cs +++ b/Source/Boxed.DotnetNewTest/TestLogger.cs @@ -18,7 +18,7 @@ public static class TestLogger /// /// Gets or sets the write message function which defaults to writing to the debug output and console. /// - public static Action WriteMessage { get; set; } + public static Action? WriteMessage { get; set; } /// /// Writes the specified message. diff --git a/Tests/Boxed.AspNetCore.Swagger.Test/SwaggerGenOptionsExtensionsTest.cs b/Tests/Boxed.AspNetCore.Swagger.Test/SwaggerGenOptionsExtensionsTest.cs index 39a1f88c..cb0127ef 100644 --- a/Tests/Boxed.AspNetCore.Swagger.Test/SwaggerGenOptionsExtensionsTest.cs +++ b/Tests/Boxed.AspNetCore.Swagger.Test/SwaggerGenOptionsExtensionsTest.cs @@ -12,7 +12,7 @@ public class SwaggerGenOptionsExtensionsTest public void IncludeXmlCommentsIfExists_NullOptions_ThrowsArgumentNullException() => Assert.Throws(() => SwaggerGenOptionsExtensions.IncludeXmlCommentsIfExists( - null, + null!, typeof(SwaggerGenOptionsExtensionsTest).GetTypeInfo().Assembly)); [Fact] @@ -20,7 +20,7 @@ public void IncludeXmlCommentsIfExists_NullAssembly_ThrowsArgumentNullException( Assert.Throws(() => SwaggerGenOptionsExtensions.IncludeXmlCommentsIfExists( new SwaggerGenOptions(), - (Assembly)null)); + (Assembly)null!)); [Fact] public void IncludeXmlCommentsIfExists_XmlFileExistsWithAssemblyLocation_XmlCommentsFileAdded() diff --git a/Tests/Boxed.AspNetCore.TagHelpers.Test/SubresourceIntegrityTagHelperTest.cs b/Tests/Boxed.AspNetCore.TagHelpers.Test/SubresourceIntegrityTagHelperTest.cs index 56639a7f..ae406ca6 100644 --- a/Tests/Boxed.AspNetCore.TagHelpers.Test/SubresourceIntegrityTagHelperTest.cs +++ b/Tests/Boxed.AspNetCore.TagHelpers.Test/SubresourceIntegrityTagHelperTest.cs @@ -35,7 +35,7 @@ public SubresourceIntegrityTagHelperTest() this.urlHelperMock = new Mock(MockBehavior.Strict); this.htmlEncoderMock = new Mock(MockBehavior.Strict); - this.actionContextAccessor.SetupGet(x => x.ActionContext).Returns((ActionContext)null); + this.actionContextAccessor.SetupGet(x => x.ActionContext).Returns((ActionContext)null!); this.urlHelperFactoryMock.Setup(x => x.GetUrlHelper(this.actionContextAccessor.Object.ActionContext)).Returns(this.urlHelperMock.Object); this.htmlEncoderMock.Setup(x => x.Encode(It.IsAny())).Returns((string s) => s); @@ -83,7 +83,7 @@ public async Task ProcessAsync_Sha512SriNotCached_CachesSriAndReturnsItAsync() var output = new TagHelperOutput("script", attributes, (x, y) => throw new ArgumentException("message")); this.distributedCacheMock .Setup(x => x.GetAsync("SRI:/foo.js", CancellationToken.None)) - .ReturnsAsync((byte[])null); + .ReturnsAsync((byte[])null!); this.webHostEnvironmentMock.SetupGet(x => x.ContentRootPath).Returns(@"C:\Foo\wwwroot"); this.urlHelperMock.Setup(x => x.Content("/foo.js")).Returns(@"C:\Foo\wwwroot\foo.js"); this.distributedCacheMock @@ -122,7 +122,7 @@ public async Task ProcessAsync_Sha256And384And512SriNotCached_CachesSriAndReturn var output = new TagHelperOutput("script", attributes, (x, y) => throw new ArgumentException("message")); this.distributedCacheMock .Setup(x => x.GetAsync("SRI:/foo.js", CancellationToken.None)) - .ReturnsAsync((byte[])null); + .ReturnsAsync((byte[])null!); this.webHostEnvironmentMock.SetupGet(x => x.ContentRootPath).Returns(@"C:\Foo\wwwroot"); this.urlHelperMock.Setup(x => x.Content("/foo.js")).Returns(@"C:\Foo\wwwroot\foo.js"); this.distributedCacheMock diff --git a/Tests/Boxed.AspNetCore.Test/ApplicationBuilderExtensionsTest.cs b/Tests/Boxed.AspNetCore.Test/ApplicationBuilderExtensionsTest.cs index 0841c3b0..985d87da 100644 --- a/Tests/Boxed.AspNetCore.Test/ApplicationBuilderExtensionsTest.cs +++ b/Tests/Boxed.AspNetCore.Test/ApplicationBuilderExtensionsTest.cs @@ -23,7 +23,7 @@ public ApplicationBuilderExtensionsTest() [Fact] public void UseServerTiming_NullApplication_ThrowsArgumentNullException() => - Assert.Throws(() => Boxed.AspNetCore.ApplicationBuilderExtensions.UseServerTiming(null)); + Assert.Throws(() => AspNetCore.ApplicationBuilderExtensions.UseServerTiming(null!)); [Fact] public async Task UseIf_TrueCondition_ActionCalledAsync() diff --git a/Tests/Boxed.AspNetCore.Test/CursorTest.cs b/Tests/Boxed.AspNetCore.Test/CursorTest.cs index 44f104d7..a6aa51b7 100644 --- a/Tests/Boxed.AspNetCore.Test/CursorTest.cs +++ b/Tests/Boxed.AspNetCore.Test/CursorTest.cs @@ -13,7 +13,7 @@ public static IEnumerable DateTimeOffsetToCursor // If no-store is set, then location is ignored. yield return new object[] { - null, + null!, string.Empty, }; yield return new object[] @@ -77,7 +77,7 @@ public void FromCursor_NullableDateTimeOffsetValue_ReturnsPrefixedBase64Cursor() [Fact] public void FromCursor_NullStringValue_ReturnsNull() { - var value = Cursor.FromCursor(null); + var value = Cursor.FromCursor(null!); Assert.Null(value); } @@ -109,7 +109,7 @@ public void FromCursor_InvalidBase64StringValue_ReturnsNull() [Fact] public void GetFirstAndLastCursor_NullCollection_ReturnsNullFirstAndLast() { - var (first, last) = Cursor.GetFirstAndLastCursor(null, x => x.Integer); + var (first, last) = Cursor.GetFirstAndLastCursor(null!, x => x.Integer); Assert.Null(first); Assert.Null(last); @@ -117,7 +117,7 @@ public void GetFirstAndLastCursor_NullCollection_ReturnsNullFirstAndLast() [Fact] public void GetFirstAndLastCursor_NullGetCursorDelegate_ThrowsArgumentNullException() => - Assert.Throws(() => Cursor.GetFirstAndLastCursor(null, null)); + Assert.Throws(() => Cursor.GetFirstAndLastCursor(null!, null!)); [Fact] public void GetFirstAndLastCursor_EmptyCollection_ReturnsNullFirstAndLast() @@ -161,7 +161,7 @@ public void GetFirstAndLastCursor_TwoItems_ReturnsFirstAndLastCursor() [Fact] public void ToCursor_Null_ThrowsArgumentNullException() => - Assert.Throws(() => Cursor.ToCursor(null)); + Assert.Throws(() => Cursor.ToCursor(null!)); [Theory] [InlineData(0, "MA==")] diff --git a/Tests/Boxed.AspNetCore.Test/DistributedCacheExtensionsTest.cs b/Tests/Boxed.AspNetCore.Test/DistributedCacheExtensionsTest.cs index ad22a5f7..0b445b29 100644 --- a/Tests/Boxed.AspNetCore.Test/DistributedCacheExtensionsTest.cs +++ b/Tests/Boxed.AspNetCore.Test/DistributedCacheExtensionsTest.cs @@ -19,11 +19,11 @@ public DistributedCacheExtensionsTest() => [Fact] public Task GetAsJsonAsync_NullDistributedCache_ThrowsArgumentNullExceptionAsync() => - Assert.ThrowsAsync(() => ((IDistributedCache)null).GetAsJsonAsync("Key")); + Assert.ThrowsAsync(() => ((IDistributedCache)null!).GetAsJsonAsync("Key")); [Fact] public Task GetAsJsonAsync_NullKey_ThrowsArgumentNullExceptionAsync() => - Assert.ThrowsAsync(() => this.distributedCacheMock.Object.GetAsJsonAsync(null)); + Assert.ThrowsAsync(() => this.distributedCacheMock.Object.GetAsJsonAsync(null!)); [Fact] public async Task GetAsJsonAsync_ValidValue_ReturnsDeserializedObjectAsync() @@ -39,17 +39,19 @@ public async Task GetAsJsonAsync_ValidValue_ReturnsDeserializedObjectAsync() .ConfigureAwait(false); Assert.NotNull(testClass); - Assert.Equal(1, testClass.Value); + Assert.Equal(1, testClass!.Value); } } [Fact] public Task SetAsJsonAsync_NullDistributedCache_ThrowsArgumentNullExceptionAsync() => - Assert.ThrowsAsync(() => ((IDistributedCache)null).SetAsJsonAsync("Key", new TestClass())); + Assert.ThrowsAsync( + () => ((IDistributedCache)null!).SetAsJsonAsync("Key", new TestClass())); [Fact] public Task SetAsJsonAsync_NullKey_ThrowsArgumentNullExceptionAsync() => - Assert.ThrowsAsync(() => this.distributedCacheMock.Object.SetAsJsonAsync(null, new TestClass())); + Assert.ThrowsAsync( + () => this.distributedCacheMock.Object.SetAsJsonAsync(null!, new TestClass())); [Fact] public async Task SetAsJsonAsync_ValidValue_SavesSerializedValueAsync() diff --git a/Tests/Boxed.AspNetCore.Test/Middleware/ServerTimingMiddlewareTest.cs b/Tests/Boxed.AspNetCore.Test/Middleware/ServerTimingMiddlewareTest.cs index daf895c5..96aed4d4 100644 --- a/Tests/Boxed.AspNetCore.Test/Middleware/ServerTimingMiddlewareTest.cs +++ b/Tests/Boxed.AspNetCore.Test/Middleware/ServerTimingMiddlewareTest.cs @@ -20,11 +20,11 @@ public ServerTimingMiddlewareTest() [Fact] public void InvokeAsync_NullContext_ThrowsArgumentNullException() => - Assert.ThrowsAsync(() => new ServerTimingMiddleware().InvokeAsync(null, this.next)); + Assert.ThrowsAsync(() => new ServerTimingMiddleware().InvokeAsync(null!, this.next)); [Fact] public void InvokeAsync_NullNext_ThrowsArgumentNullException() => - Assert.ThrowsAsync(() => new ServerTimingMiddleware().InvokeAsync(this.context, null)); + Assert.ThrowsAsync(() => new ServerTimingMiddleware().InvokeAsync(this.context, null!)); [Fact] public async Task InvokeAsync_DoesntSupportTrailingHeaders_DontAddServerTimingHttpHeaderAsync() diff --git a/Tests/Boxed.AspNetCore.Test/RedirectToCanonicalUrlRuleTest.cs b/Tests/Boxed.AspNetCore.Test/RedirectToCanonicalUrlRuleTest.cs index aa1db51b..ed427698 100644 --- a/Tests/Boxed.AspNetCore.Test/RedirectToCanonicalUrlRuleTest.cs +++ b/Tests/Boxed.AspNetCore.Test/RedirectToCanonicalUrlRuleTest.cs @@ -11,7 +11,8 @@ public class RedirectToCanonicalUrlRuleTest { [Fact] public void ApplyRule_NullContext_ThrowsArgumentNullException() => - Assert.Throws(() => new RedirectToCanonicalUrlRule(true, true).ApplyRule(null)); + Assert.Throws( + () => new RedirectToCanonicalUrlRule(true, true).ApplyRule(null!)); [Theory] [InlineData("CONNECT")] diff --git a/Tests/Boxed.Mapping.Test/AsyncImmutableMapperTest.cs b/Tests/Boxed.Mapping.Test/AsyncImmutableMapperTest.cs index 0f521969..51bb8e23 100644 --- a/Tests/Boxed.Mapping.Test/AsyncImmutableMapperTest.cs +++ b/Tests/Boxed.Mapping.Test/AsyncImmutableMapperTest.cs @@ -22,7 +22,7 @@ public Task MapAsync_Null_ThrowsArgumentNullExceptionAsync() return Assert.ThrowsAsync( "source", - () => mapper.MapAsync(null, this.cancellationTokenSource.Token)); + () => mapper.MapAsync(null!, this.cancellationTokenSource.Token)); } [Fact] diff --git a/Tests/Boxed.Mapping.Test/AsyncMapperTest.cs b/Tests/Boxed.Mapping.Test/AsyncMapperTest.cs index 470cd0c0..6fc48995 100644 --- a/Tests/Boxed.Mapping.Test/AsyncMapperTest.cs +++ b/Tests/Boxed.Mapping.Test/AsyncMapperTest.cs @@ -22,7 +22,7 @@ public Task MapAsync_Null_ThrowsArgumentNullExceptionAsync() return Assert.ThrowsAsync( "source", - () => mapper.MapAsync(null, this.cancellationTokenSource.Token)); + () => mapper.MapAsync(null!, this.cancellationTokenSource.Token)); } [Fact] diff --git a/Tests/Boxed.Mapping.Test/ImmutableMapperTest.cs b/Tests/Boxed.Mapping.Test/ImmutableMapperTest.cs index f3b8f70b..cb89873c 100644 --- a/Tests/Boxed.Mapping.Test/ImmutableMapperTest.cs +++ b/Tests/Boxed.Mapping.Test/ImmutableMapperTest.cs @@ -17,7 +17,7 @@ public void Map_Null_ThrowsArgumentNullException() { var mapper = new ImmutableMapper(); - Assert.Throws("source", () => mapper.Map(null)); + Assert.Throws("source", () => mapper.Map(null!)); } [Fact] diff --git a/Tests/Boxed.Mapping.Test/MapperTest.cs b/Tests/Boxed.Mapping.Test/MapperTest.cs index 10abf90c..c17bace8 100644 --- a/Tests/Boxed.Mapping.Test/MapperTest.cs +++ b/Tests/Boxed.Mapping.Test/MapperTest.cs @@ -17,7 +17,7 @@ public void Map_Null_ThrowsArgumentNullException() { var mapper = new Mapper(); - Assert.Throws("source", () => mapper.Map(null)); + Assert.Throws("source", () => mapper.Map(null!)); } [Fact]