Skip to content

Commit

Permalink
Enable C# 8 nullable reference types
Browse files Browse the repository at this point in the history
  • Loading branch information
RehanSaeed committed Mar 11, 2021
1 parent c65180e commit ce7ff12
Show file tree
Hide file tree
Showing 71 changed files with 296 additions and 288 deletions.
2 changes: 1 addition & 1 deletion Benchmarks/Boxed.Mapping.Benchmark/MapArrayBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class MapArrayBenchmark
private readonly IMapper automapper;
private readonly IMapper<MapFrom, MapTo> boilerplateMapper;
private readonly Random random;
private MapFrom[] mapFrom;
private MapFrom[] mapFrom = default!;

public MapArrayBenchmark()
{
Expand Down
2 changes: 1 addition & 1 deletion Benchmarks/Boxed.Mapping.Benchmark/MapListBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class MapListBenchmark
private readonly IMapper automapper;
private readonly IMapper<MapFrom, MapTo> boilerplateMapper;
private readonly Random random;
private List<MapFrom> mapFrom;
private List<MapFrom> mapFrom = default!;

public MapListBenchmark()
{
Expand Down
2 changes: 1 addition & 1 deletion Benchmarks/Boxed.Mapping.Benchmark/MapObjectBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class MapObjectBenchmark
private readonly IMapper automapper;
private readonly IMapper<MapFrom, MapTo> boilerplateMapper;
private readonly Random random;
private MapFrom mapFrom;
private MapFrom mapFrom = default!;

public MapObjectBenchmark()
{
Expand Down
2 changes: 1 addition & 1 deletion Benchmarks/Boxed.Mapping.Benchmark/Models/MapFrom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ public class MapFrom

public long LongFrom { get; set; }

public string StringFrom { get; set; }
public string? StringFrom { get; set; }
}
}
2 changes: 1 addition & 1 deletion Benchmarks/Boxed.Mapping.Benchmark/Models/MapTo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ public class MapTo

public long LongTo { get; set; }

public string StringTo { get; set; }
public string? StringTo { get; set; }
}
}
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<LangVersion>latest</LangVersion>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<AnalysisLevel>latest</AnalysisLevel>
<Nullable>enable</Nullable>
<NeutralLanguage>en-GB</NeutralLanguage>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public HrefSubresourceIntegrityTagHelper(

/// <inheritdoc />
[HtmlAttributeName(SubresourceIntegrityHrefAttributeName)]
public override string Source { get; set; }
public override string? Source { get; set; }

/// <inheritdoc />
protected override string UrlAttributeName => HrefAttributeName;
Expand Down
2 changes: 1 addition & 1 deletion Source/Boxed.AspNetCore.TagHelpers/HtmlHelperExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static class HtmlHelperExtensions
/// <param name="htmlHelper">The HTML helper.</param>
/// <param name="referrerMode">The type of referrer allowed to be sent.</param>
/// <returns>The referrer meta tag.</returns>
public static HtmlString ReferrerMeta(this IHtmlHelper htmlHelper, ReferrerMode referrerMode)
public static HtmlString? ReferrerMeta(this IHtmlHelper htmlHelper, ReferrerMode referrerMode)
{
if (htmlHelper is null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public abstract class OpenGraphMedia
/// Initializes a new instance of the <see cref="OpenGraphMedia"/> class.
/// </summary>
/// <param name="mediaUrl">The media URL.</param>
/// <exception cref="System.ArgumentNullException">Thrown if <paramref name="mediaUrl"/> is <c>null</c>.</exception>
/// <exception cref="ArgumentNullException">Thrown if <paramref name="mediaUrl"/> is <c>null</c>.</exception>
public OpenGraphMedia(Uri mediaUrl)
{
if (mediaUrl is null)
Expand All @@ -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.
/// </summary>
public string Type { get; set; }
public string? Type { get; set; }

/// <summary>
/// Gets the absolute HTTP media URL which should represent your object within the graph.
Expand All @@ -49,7 +49,7 @@ public OpenGraphMedia(Uri mediaUrl)
/// <summary>
/// Gets the absolute HTTPS media URL which should represent your object within the graph.
/// </summary>
public Uri UrlSecure { get; }
public Uri? UrlSecure { get; }

/// <summary>
/// Appends a HTML-encoded string representing this instance to the <paramref name="stringBuilder"/> containing the Open Graph meta tags.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <see cref="OpenGraphBooksBook"/>.
/// </summary>
[HtmlAttributeName(BookUrlsAttributeName)]
public IEnumerable<string> BookUrls { get; set; }
public IEnumerable<string>? BookUrls { get; set; }

/// <summary>
/// Gets or sets the authors gender.
Expand All @@ -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 <see cref="OpenGraphBooksGenre"/>.
/// </summary>
[HtmlAttributeName(GenreUrlsAttributeName)]
public IEnumerable<string> GenreUrls { get; set; }
public IEnumerable<string>? GenreUrls { get; set; }

/// <summary>
/// Gets the namespace of this open graph type.
Expand All @@ -48,7 +48,7 @@ public class OpenGraphBooksAuthor : OpenGraphMetadata
/// Gets or sets the official site URL of the author.
/// </summary>
[HtmlAttributeName(OfficialSiteUrlAttributeName)]
public Uri OfficialSiteUrl { get; set; }
public Uri? OfficialSiteUrl { get; set; }

/// <summary>
/// Gets the type of your object. Depending on the type you specify, other properties may also be required.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <see cref="OpenGraphBooksAuthor"/>.
/// </summary>
[HtmlAttributeName(AuthorUrlsAttributeName)]
public IEnumerable<string> AuthorUrls { get; set; }
public IEnumerable<string>? AuthorUrls { get; set; }

/// <summary>
/// Gets or sets the URL's to the pages about the genres of the book. This URL must contain books.genre meta tags <see cref="OpenGraphBooksGenre"/>.
/// </summary>
[HtmlAttributeName(GenreUrlsAttributeName)]
public IEnumerable<string> GenreUrls { get; set; }
public IEnumerable<string>? GenreUrls { get; set; }

/// <summary>
/// Gets or sets the initial release date of the book.
Expand All @@ -50,13 +50,13 @@ public class OpenGraphBooksBook : OpenGraphMetadata
/// Gets or sets the books unique ISBN number.
/// </summary>
[HtmlAttributeName(ISBNAttributeName)]
public string ISBN { get; set; }
public string? ISBN { get; set; }

/// <summary>
/// Gets or sets the language of the book in the format language_TERRITORY.
/// </summary>
[HtmlAttributeName(LanguageAttributeName)]
public string Language { get; set; }
public string? Language { get; set; }

/// <summary>
/// Gets the namespace of this open graph type.
Expand All @@ -73,7 +73,7 @@ public class OpenGraphBooksBook : OpenGraphMetadata
/// Gets or sets the rating of the book.
/// </summary>
[HtmlAttributeName(RatingAttributeName)]
public OpenGraphRating Rating { get; set; }
public OpenGraphRating? Rating { get; set; }

/// <summary>
/// Gets or sets the release date of the book.
Expand All @@ -85,7 +85,7 @@ public class OpenGraphBooksBook : OpenGraphMetadata
/// Gets or sets the URL to a sample of the book.
/// </summary>
[HtmlAttributeName(SampleUrlAttributeName)]
public Uri SampleUrl { get; set; }
public Uri? SampleUrl { get; set; }

/// <summary>
/// Gets the type of your object. Depending on the type you specify, other properties may also be required.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <see cref="OpenGraphBooksAuthor"/>.
/// </summary>
[HtmlAttributeName(AuthorUrlsAttributeName)]
public IEnumerable<string> AuthorUrls { get; set; }
public IEnumerable<string>? AuthorUrls { get; set; }

/// <summary>
/// Gets or sets the URL's to the pages about the books written by the author. This URL must contain books.book meta tags <see cref="OpenGraphBooksBook"/>.
/// </summary>
[HtmlAttributeName(BookUrlsAttributeName)]
public IEnumerable<string> BookUrls { get; set; }
public IEnumerable<string>? BookUrls { get; set; }

/// <summary>
/// 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 &amp; Lesbian, Graphic Novels, Historical Fiction, Horror, Fiction &amp; Literature, Mystery, Mythology &amp; Folklore, Poetry, Religious &amp; Inspiratonal, Rhetoric &amp; Critcism, Romance, Satire &amp; Humor, Science Fiction, Thrillers &amp; Suspense, Westerns, Women&#039;s Fiction, Young Adult Fiction, Biography &amp; Memoir, Current Affairs &amp; 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&#039;s Non-fiction, Computer Science, Encyclopedias, General Collections, Gift Books, Information Sciences, Journalism &amp; Publishing, Magazines &amp; Journals, Manuscripts &amp; Rare Books, Epistemology, Ethics, Logic, Metaphysics, Philosophy, Parapsychology &amp; Occultism, Psychology, Self-help, Bible, Comparative Religions, Natural Theory, Theology, Business, Customs &amp; Etiquette, Economics, Education, Finance, Gay &amp; Lesbian Non-Fiction, Gender Studies, Law, Political Science, Social Sciences, Social Services, Statistics, True Crime, English &amp; Old English, French, German, Greek, Italian, Language, Latin, Linguistics, Other Languages, Portugese, Spanish, Astronomy, Chemistry, Earth Sciences, Life Sciences, Mathematics, Paleontology &amp; Paleozoology, Physics, Plants Sciences, Zoology, Agriculture, Chemical Engineering, Engineering &amp; Opera?ons, Management, Manufacturing, Medical Sciences, Technology, Cooking &amp; 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.
/// </summary>
[HtmlAttributeName(CanonicalNameAttributeName)]
public string CanonicalName { get; set; }
public string? CanonicalName { get; set; }

/// <summary>
/// Gets the namespace of this open graph type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ public class OpenGraphBusiness : OpenGraphMetadata
/// Gets or sets the contact data for the business.
/// </summary>
[HtmlAttributeName(ContactDataAttributeName)]
public OpenGraphContactData ContactData { get; set; }
public OpenGraphContactData? ContactData { get; set; }

/// <summary>
/// Gets or sets the location of the business.
/// </summary>
[HtmlAttributeName(LocationAttributeName)]
public OpenGraphLocation Location { get; set; }
public OpenGraphLocation? Location { get; set; }

/// <summary>
/// Gets the namespace of this open graph type.
Expand All @@ -45,7 +45,7 @@ public class OpenGraphBusiness : OpenGraphMetadata
/// Gets or sets the opening hours of the business.
/// </summary>
[HtmlAttributeName(OpeningHoursAttributeName)]
public IEnumerable<OpenGraphHours> OpeningHours { get; set; }
public IEnumerable<OpenGraphHours>? OpeningHours { get; set; }

/// <summary>
/// Gets the type of your object. Depending on the type you specify, other properties may also be required.
Expand All @@ -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)
{
Expand All @@ -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);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,31 +36,31 @@ public class OpenGraphFitnessCourse : OpenGraphMetadata
/// Gets or sets the energy used during the course.
/// </summary>
[HtmlAttributeName(CustomUnitEnergyAttributeName)]
public OpenGraphQuantity CustomUnitEnergy { get; set; }
public OpenGraphQuantity? CustomUnitEnergy { get; set; }

/// <summary>
/// Gets or sets the distance of the course.
/// </summary>
[HtmlAttributeName(DistanceAttributeName)]
public OpenGraphQuantity Distance { get; set; }
public OpenGraphQuantity? Distance { get; set; }

/// <summary>
/// Gets or sets the duration taken on the course.
/// </summary>
[HtmlAttributeName(DurationAttributeName)]
public OpenGraphQuantity Duration { get; set; }
public OpenGraphQuantity? Duration { get; set; }

/// <summary>
/// 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.
/// </summary>
[HtmlAttributeName(LiveTextAttributeName)]
public string LiveText { get; set; }
public string? LiveText { get; set; }

/// <summary>
/// Gets or sets the metrics about the course.
/// </summary>
[HtmlAttributeName(MetricsAttributeName)]
public IEnumerable<OpenGraphFitnessActivityDataPoint> Metrics { get; set; }
public IEnumerable<OpenGraphFitnessActivityDataPoint>? Metrics { get; set; }

/// <summary>
/// Gets the namespace of this open graph type.
Expand All @@ -71,19 +71,19 @@ public class OpenGraphFitnessCourse : OpenGraphMetadata
/// Gets or sets the pace achieved on the course.
/// </summary>
[HtmlAttributeName(PaceAttributeName)]
public OpenGraphQuantity Pace { get; set; }
public OpenGraphQuantity? Pace { get; set; }

/// <summary>
/// Gets or sets the split times during the course.
/// </summary>
[HtmlAttributeName(SplitsAttributeName)]
public IEnumerable<OpenGraphSplit> Splits { get; set; }
public IEnumerable<OpenGraphSplit>? Splits { get; set; }

/// <summary>
/// Gets or sets the speed achieved on the course.
/// </summary>
[HtmlAttributeName(SpeedAttributeName)]
public OpenGraphQuantity Speed { get; set; }
public OpenGraphQuantity? Speed { get; set; }

/// <summary>
/// Gets the type of your object. Depending on the type you specify, other properties may also be required.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class OpenGraphPlace : OpenGraphMetadata
/// Gets or sets the location of the place.
/// </summary>
[HtmlAttributeName(LocationAttributeName)]
public OpenGraphLocation Location { get; set; }
public OpenGraphLocation? Location { get; set; }

/// <summary>
/// Gets the namespace of this open graph type.
Expand All @@ -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);
}

/// <summary>
Expand Down
Loading

0 comments on commit ce7ff12

Please sign in to comment.