core: bump C# language version (#15469)

This commit is contained in:
Bogdan 2024-07-07 22:27:26 +03:00 committed by GitHub
parent 31f7ce4a3b
commit edf84f4a4f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 31 additions and 32 deletions

View File

@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>8</LangVersion> <LangVersion>9</LangVersion>
<NoWarn /> <NoWarn />
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<WarningsAsErrors /> <WarningsAsErrors />

View File

@ -225,13 +225,13 @@ namespace Jackett.Common.Indexers.Definitions.Abstract
var description = ""; var description = "";
var jAudio = row.Value<JArray>("audio"); var jAudio = row.Value<JArray>("audio");
if (jAudio != null && jAudio.HasValues) if (jAudio is { HasValues: true })
{ {
var audioList = jAudio.Select(tag => tag.Value<string>("language")).ToList(); var audioList = jAudio.Select(tag => tag.Value<string>("language")).ToList();
description += $"Audio: {string.Join(", ", audioList)}"; description += $"Audio: {string.Join(", ", audioList)}";
} }
var jSubtitle = row.Value<JArray>("subtitle"); var jSubtitle = row.Value<JArray>("subtitle");
if (jSubtitle != null && jSubtitle.HasValues) if (jSubtitle is { HasValues: true })
{ {
var subtitleList = jSubtitle.Select(tag => tag.Value<string>("language")).ToList(); var subtitleList = jSubtitle.Select(tag => tag.Value<string>("language")).ToList();
description += $"<br/>Subtitles: {string.Join(", ", subtitleList)}"; description += $"<br/>Subtitles: {string.Join(", ", subtitleList)}";
@ -260,7 +260,7 @@ namespace Jackett.Common.Indexers.Definitions.Abstract
Subs = row.Value<JArray>("subtitle")?.Select(x => x.Value<string>("language")).ToList() ?? new List<string>(), Subs = row.Value<JArray>("subtitle")?.Select(x => x.Value<string>("language")).ToList() ?? new List<string>(),
}; };
if (release.Size.HasValue && release.Size > 0) if (release.Size is > 0)
{ {
var sizeGigabytes = release.Size.Value / Math.Pow(1024, 3); var sizeGigabytes = release.Size.Value / Math.Pow(1024, 3);
@ -270,7 +270,7 @@ namespace Jackett.Common.Indexers.Definitions.Abstract
} }
var jMovieTv = row.Value<JToken>("movie_tv"); var jMovieTv = row.Value<JToken>("movie_tv");
if (jMovieTv != null && jMovieTv.HasValues) if (jMovieTv is { HasValues: true })
{ {
release.Imdb = ParseUtil.GetImdbId(jMovieTv.Value<string>("imdb")); release.Imdb = ParseUtil.GetImdbId(jMovieTv.Value<string>("imdb"));

View File

@ -234,11 +234,11 @@ namespace Jackett.Common.Indexers.Definitions.Abstract
queryCollection.Set("filter_cat[" + cat + "]", "1"); queryCollection.Set("filter_cat[" + cat + "]", "1");
} }
if (configData.FreeleechOnly != null && configData.FreeleechOnly.Value) if (configData.FreeleechOnly is { Value: true })
{ {
queryCollection.Set("freetorrent", "1"); queryCollection.Set("freetorrent", "1");
} }
else if (configData.FreeloadOnly != null && configData.FreeloadOnly.Value) else if (configData.FreeloadOnly is { Value: true })
{ {
queryCollection.Set("freetorrent", "4"); queryCollection.Set("freetorrent", "4");
} }
@ -397,7 +397,7 @@ namespace Jackett.Common.Indexers.Definitions.Abstract
var isFreeleech = bool.TryParse((string)torrent["isFreeleech"], out var freeleech) && freeleech; var isFreeleech = bool.TryParse((string)torrent["isFreeleech"], out var freeleech) && freeleech;
// skip non-freeleech results when freeleech only is set // skip non-freeleech results when freeleech only is set
return configData.FreeleechOnly != null && configData.FreeleechOnly.Value && !isFreeleech; return configData.FreeleechOnly is { Value: true } && !isFreeleech;
} }
protected void FillReleaseInfoFromJson(ReleaseInfo release, JObject torrent) protected void FillReleaseInfoFromJson(ReleaseInfo release, JObject torrent)
@ -522,7 +522,7 @@ namespace Jackett.Common.Indexers.Definitions.Abstract
} }
var isPersonalFreeleech = (bool?)torrent["isPersonalFreeleech"]; var isPersonalFreeleech = (bool?)torrent["isPersonalFreeleech"];
if (isPersonalFreeleech != null && isPersonalFreeleech == true) if (isPersonalFreeleech is true)
{ {
release.DownloadVolumeFactor = 0; release.DownloadVolumeFactor = 0;
} }

View File

@ -33,7 +33,7 @@ namespace Jackett.Common.Indexers.Definitions
private string ScrapeUrl => SiteLink + "scrape.php"; private string ScrapeUrl => SiteLink + "scrape.php";
private bool AllowRaws => ConfigData.IncludeRaw.Value; private bool AllowRaws => ConfigData.IncludeRaw.Value;
private bool PadEpisode => ConfigData.PadEpisode != null && ConfigData.PadEpisode.Value; private bool PadEpisode => ConfigData.PadEpisode is { Value: true };
private bool AddJapaneseTitle => ConfigData.AddJapaneseTitle.Value; private bool AddJapaneseTitle => ConfigData.AddJapaneseTitle.Value;
private bool AddRomajiTitle => ConfigData.AddRomajiTitle.Value; private bool AddRomajiTitle => ConfigData.AddRomajiTitle.Value;
private bool AddAlternativeTitles => ConfigData.AddAlternativeTitles.Value; private bool AddAlternativeTitles => ConfigData.AddAlternativeTitles.Value;
@ -455,7 +455,7 @@ namespace Jackett.Common.Indexers.Definitions
if (FilterSeasonEpisode) if (FilterSeasonEpisode)
{ {
if (query.Season.HasValue && query.Season > 0 && season != null && season != query.Season) // skip if season doesn't match if (query.Season is > 0 && season != null && season != query.Season) // skip if season doesn't match
{ {
continue; continue;
} }

View File

@ -98,7 +98,7 @@ namespace Jackett.Common.Indexers.Definitions
if (Definition.RequestDelay != null) if (Definition.RequestDelay != null)
webclient.requestDelay = Definition.RequestDelay.Value; webclient.requestDelay = Definition.RequestDelay.Value;
if (Definition.Login != null && Definition.Login.Method == null) if (Definition.Login is { Method: null })
Definition.Login.Method = "form"; Definition.Login.Method = "form";
if (Definition.Search.Paths == null) if (Definition.Search.Paths == null)
@ -146,7 +146,7 @@ namespace Jackett.Common.Indexers.Definitions
case "checkbox": case "checkbox":
item = new BoolConfigurationItem(itemName) { Value = false }; item = new BoolConfigurationItem(itemName) { Value = false };
if (Setting.Default != null && Setting.Default == "true") if (Setting.Default is "true")
{ {
((BoolConfigurationItem)item).Value = true; ((BoolConfigurationItem)item).Value = true;
} }
@ -1557,7 +1557,7 @@ namespace Jackett.Common.Indexers.Definitions
var results = response.ContentString; var results = response.ContentString;
if (SearchPath.Response != null && SearchPath.Response.Type.Equals("json")) if (SearchPath.Response is { Type: "json" })
{ {
// check if we need to login again // check if we need to login again
var loginNeeded = CheckIfLoginIsNeeded(response); var loginNeeded = CheckIfLoginIsNeeded(response);
@ -1591,8 +1591,7 @@ namespace Jackett.Common.Indexers.Definitions
} }
if (response.Status == HttpStatusCode.OK if (response.Status == HttpStatusCode.OK
&& SearchPath.Response != null && SearchPath.Response is { NoResultsMessage: not null }
&& SearchPath.Response.NoResultsMessage != null
&& (SearchPath.Response.NoResultsMessage != string.Empty && results.Contains(SearchPath.Response.NoResultsMessage) || (SearchPath.Response.NoResultsMessage == string.Empty && results == string.Empty))) && (SearchPath.Response.NoResultsMessage != string.Empty && results.Contains(SearchPath.Response.NoResultsMessage) || (SearchPath.Response.NoResultsMessage == string.Empty && results == string.Empty)))
{ {
continue; continue;
@ -1733,7 +1732,7 @@ namespace Jackett.Common.Indexers.Definitions
{ {
IHtmlCollection<IElement> rowsDom; IHtmlCollection<IElement> rowsDom;
if (SearchPath.Response != null && SearchPath.Response.Type.Equals("xml")) if (SearchPath.Response is { Type: "xml" })
{ {
var SearchResultParser = new XmlParser(); var SearchResultParser = new XmlParser();
var SearchResultDocument = SearchResultParser.ParseDocument(results); var SearchResultDocument = SearchResultParser.ParseDocument(results);

View File

@ -145,7 +145,7 @@ namespace Jackett.Common.Indexers.Definitions
} }
var isPersonalFreeleech = (bool?)torrent["isPersonalFreeleech"]; var isPersonalFreeleech = (bool?)torrent["isPersonalFreeleech"];
if (isPersonalFreeleech != null && isPersonalFreeleech == true) if (isPersonalFreeleech is true)
release.DownloadVolumeFactor = 0; release.DownloadVolumeFactor = 0;
var imdbID = (string)result["imdbId"]; var imdbID = (string)result["imdbId"];

View File

@ -385,7 +385,7 @@ namespace Jackett.Common.Indexers.Definitions
foreach (var serie in series) foreach (var serie in series)
{ {
var link = serie["link"].ToString(); var link = serie["link"].ToString();
var season = query.Season.HasValue && query.Season > 0 ? $"/season_{query.Season}" : "/seasons"; var season = query.Season is > 0 ? $"/season_{query.Season}" : "/seasons";
var url = SiteLink + link.TrimStart('/') + season; var url = SiteLink + link.TrimStart('/') + season;
if (!string.IsNullOrEmpty(query.Episode)) // Fetch single episode releases if (!string.IsNullOrEmpty(query.Episode)) // Fetch single episode releases

View File

@ -222,7 +222,7 @@ namespace Jackett.Common.Indexers.Definitions
{ {
// check there are results // check there are results
var rows = table.Children; var rows = table.Children;
if (rows != null && rows.Length > 0) if (rows is { Length: > 0 })
foreach (var row in rows) foreach (var row in rows)
{ {
var rowQuality = row.Children[0].Children[0].Children[0].TextContent; var rowQuality = row.Children[0].Children[0].Children[0].TextContent;

View File

@ -87,7 +87,7 @@ namespace Jackett.Common.Indexers.Definitions
{ {
var isFreeload = bool.TryParse((string)torrent["isFreeload"], out var freeload) && freeload; var isFreeload = bool.TryParse((string)torrent["isFreeload"], out var freeload) && freeload;
if (configData.FreeloadOnly != null && configData.FreeloadOnly.Value && !isFreeload) if (configData.FreeloadOnly is { Value: true } && !isFreeload)
{ {
return true; return true;
} }

View File

@ -1535,7 +1535,7 @@ namespace Jackett.Common.Indexers.Definitions
{ {
searchString = searchString.Replace("-", " "); searchString = searchString.Replace("-", " ");
if (query.Season.HasValue && query.Season > 0) if (query.Season is > 0)
{ {
searchString += " Сезон: " + query.Season; searchString += " Сезон: " + query.Season;
} }

View File

@ -64,7 +64,7 @@ namespace Jackett.Common.Indexers.Definitions
return caps; return caps;
} }
private int ShowPagesFetchLimit => int.TryParse(configData.ShowPagesFetchLimit.Value, out var limit) && limit > 0 && limit <= 5 ? limit : 2; private int ShowPagesFetchLimit => int.TryParse(configData.ShowPagesFetchLimit.Value, out var limit) && limit is > 0 and <= 5 ? limit : 2;
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson) public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{ {

View File

@ -145,7 +145,7 @@ namespace Jackett.Common.Indexers.Definitions
} }
// Only include season > 1 in searchTerm, format as S2 rather than S02 // Only include season > 1 in searchTerm, format as S2 rather than S02
if (query.Season.HasValue && query.Season.Value > 1) if (query.Season is > 1)
{ {
searchTerm += $" S{query.Season}"; searchTerm += $" S{query.Season}";
query.Season = 0; query.Season = 0;

View File

@ -303,7 +303,7 @@ namespace Jackett.Common.Indexers.Definitions
queryParams.Add("c", Convert.ToBase64String(plainTextBytes)); queryParams.Add("c", Convert.ToBase64String(plainTextBytes));
} }
if (query.Season.HasValue && query.Season > 0) if (query.Season is > 0)
{ {
queryParams.Add("s", query.Season.ToString()); queryParams.Add("s", query.Season.ToString());

View File

@ -272,7 +272,7 @@ namespace Jackett.Common.Indexers.Definitions
{ {
searchString = searchString.Replace("-", " "); searchString = searchString.Replace("-", " ");
if (query.Season.HasValue && query.Season > 0) if (query.Season is > 0)
{ {
searchString += " Сезон " + query.Season; searchString += " Сезон " + query.Season;
} }

View File

@ -3,7 +3,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
<Version>0.0.0</Version> <Version>0.0.0</Version>
<LangVersion>8</LangVersion> <LangVersion>9</LangVersion>
<NoWarn /> <NoWarn />
<WarningsAsErrors /> <WarningsAsErrors />
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> <TreatWarningsAsErrors>false</TreatWarningsAsErrors>

View File

@ -102,7 +102,7 @@ namespace Jackett.Common.Models
Publisher.IsNotNullOrWhiteSpace() || Publisher.IsNotNullOrWhiteSpace() ||
Year.HasValue; Year.HasValue;
public bool HasSpecifiedCategories => (Categories != null && Categories.Length > 0); public bool HasSpecifiedCategories => Categories is { Length: > 0 };
public string SanitizedSearchTerm public string SanitizedSearchTerm
{ {
@ -224,7 +224,7 @@ namespace Jackett.Common.Models
{ {
var queryString = !string.IsNullOrWhiteSpace(queryStringOverride) ? queryStringOverride : GetQueryString(); var queryString = !string.IsNullOrWhiteSpace(queryStringOverride) ? queryStringOverride : GetQueryString();
if (limit != null && limit > 0) if (limit is > 0)
{ {
if (limit > queryString.Length) if (limit > queryString.Length)
{ {

View File

@ -192,7 +192,7 @@ namespace Jackett.Common.Utils.Clients
var body = ""; var body = "";
var bodySize = 0; var bodySize = 0;
var isBinary = false; var isBinary = false;
if (result.ContentBytes != null && result.ContentBytes.Length > 0) if (result.ContentBytes is { Length: > 0 })
{ {
bodySize = result.ContentBytes.Length; bodySize = result.ContentBytes.Length;
var contentString = result.ContentString.Trim(); var contentString = result.ContentString.Trim();

View File

@ -82,11 +82,11 @@ namespace Jackett.Service
private void StopConsoleApplication() private void StopConsoleApplication()
{ {
if (consoleProcess != null && !consoleProcess.HasExited) if (consoleProcess is { HasExited: false })
{ {
consoleProcess.StandardInput.Close(); consoleProcess.StandardInput.Close();
consoleProcess.WaitForExit(2000); consoleProcess.WaitForExit(2000);
if (consoleProcess != null && !consoleProcess.HasExited) if (consoleProcess is { HasExited: false })
{ {
consoleProcess.Kill(); consoleProcess.Kill();
} }