Inline out variable declaration

pull/9607/head
Stepan Goremykin 2 years ago
parent 6ae1903453
commit c051736c80

@ -1866,8 +1866,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{ {
await writer.WriteStartDocumentAsync(true).ConfigureAwait(false); await writer.WriteStartDocumentAsync(true).ConfigureAwait(false);
await writer.WriteStartElementAsync(null, "tvshow", null).ConfigureAwait(false); await writer.WriteStartElementAsync(null, "tvshow", null).ConfigureAwait(false);
string id; if (timer.SeriesProviderIds.TryGetValue(MetadataProvider.Tvdb.ToString(), out var id))
if (timer.SeriesProviderIds.TryGetValue(MetadataProvider.Tvdb.ToString(), out id))
{ {
await writer.WriteElementStringAsync(null, "id", null, id).ConfigureAwait(false); await writer.WriteElementStringAsync(null, "id", null, id).ConfigureAwait(false);
} }

@ -170,9 +170,8 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
var nameInExtInf = nameParts.Length > 1 ? nameParts[^1].AsSpan().Trim() : ReadOnlySpan<char>.Empty; var nameInExtInf = nameParts.Length > 1 ? nameParts[^1].AsSpan().Trim() : ReadOnlySpan<char>.Empty;
string numberString = null; string numberString = null;
string attributeValue;
if (attributes.TryGetValue("tvg-chno", out attributeValue) if (attributes.TryGetValue("tvg-chno", out var attributeValue)
&& double.TryParse(attributeValue, CultureInfo.InvariantCulture, out _)) && double.TryParse(attributeValue, CultureInfo.InvariantCulture, out _))
{ {
numberString = attributeValue; numberString = attributeValue;

@ -64,8 +64,7 @@ namespace Rssdp.Infrastructure
} }
message.Method = new HttpMethod(parts[0].Trim()); message.Method = new HttpMethod(parts[0].Trim());
Uri requestUri; if (Uri.TryCreate(parts[1].Trim(), UriKind.RelativeOrAbsolute, out var requestUri))
if (Uri.TryCreate(parts[1].Trim(), UriKind.RelativeOrAbsolute, out requestUri))
{ {
message.RequestUri = requestUri; message.RequestUri = requestUri;
} }

@ -77,8 +77,7 @@ namespace Rssdp.Infrastructure
message.Version = ParseHttpVersion(parts[0].Trim()); message.Version = ParseHttpVersion(parts[0].Trim());
int statusCode = -1; if (!Int32.TryParse(parts[1].Trim(), out var statusCode))
if (!Int32.TryParse(parts[1].Trim(), out statusCode))
{ {
throw new ArgumentException("data status line is invalid. Status code is not a valid integer.", nameof(data)); throw new ArgumentException("data status line is invalid. Status code is not a valid integer.", nameof(data));
} }

@ -483,8 +483,7 @@ namespace Rssdp.Infrastructure
} }
} }
Uri retVal; Uri.TryCreate(value, UriKind.RelativeOrAbsolute, out var retVal);
Uri.TryCreate(value, UriKind.RelativeOrAbsolute, out retVal);
return retVal; return retVal;
} }
@ -501,8 +500,7 @@ namespace Rssdp.Infrastructure
} }
} }
Uri retVal; Uri.TryCreate(value, UriKind.RelativeOrAbsolute, out var retVal);
Uri.TryCreate(value, UriKind.RelativeOrAbsolute, out retVal);
return retVal; return retVal;
} }

@ -244,7 +244,6 @@ namespace Rssdp.Infrastructure
// Wait on random interval up to MX, as per SSDP spec. // Wait on random interval up to MX, as per SSDP spec.
// Also, as per UPnP 1.1/SSDP spec ignore missing/bank MX header. If over 120, assume random value between 0 and 120. // Also, as per UPnP 1.1/SSDP spec ignore missing/bank MX header. If over 120, assume random value between 0 and 120.
// Using 16 as minimum as that's often the minimum system clock frequency anyway. // Using 16 as minimum as that's often the minimum system clock frequency anyway.
int maxWaitInterval = 0;
if (String.IsNullOrEmpty(mx)) if (String.IsNullOrEmpty(mx))
{ {
// Windows Explorer is poorly behaved and doesn't supply an MX header value. // Windows Explorer is poorly behaved and doesn't supply an MX header value.
@ -254,7 +253,7 @@ namespace Rssdp.Infrastructure
// return; // return;
} }
if (!Int32.TryParse(mx, out maxWaitInterval) || maxWaitInterval <= 0) if (!Int32.TryParse(mx, out var maxWaitInterval) || maxWaitInterval <= 0)
{ {
return; return;
} }
@ -581,8 +580,7 @@ namespace Rssdp.Infrastructure
private string GetFirstHeaderValue(System.Net.Http.Headers.HttpRequestHeaders httpRequestHeaders, string headerName) private string GetFirstHeaderValue(System.Net.Http.Headers.HttpRequestHeaders httpRequestHeaders, string headerName)
{ {
string retVal = null; string retVal = null;
IEnumerable<String> values = null; if (httpRequestHeaders.TryGetValues(headerName, out var values) && values != null)
if (httpRequestHeaders.TryGetValues(headerName, out values) && values != null)
{ {
retVal = values.FirstOrDefault(); retVal = values.FirstOrDefault();
} }

@ -238,9 +238,6 @@ namespace Jellyfin.Providers.Tests.Manager
} }
}; };
object? result;
List<PersonInfo> actual;
// overwrite provider id // overwrite provider id
var overwriteNewValue = new List<PersonInfo> var overwriteNewValue = new List<PersonInfo>
{ {
@ -249,9 +246,9 @@ namespace Jellyfin.Providers.Tests.Manager
Name = "Name 2" Name = "Name 2"
} }
}; };
Assert.False(TestMergeBaseItemDataPerson(GetOldValue(), overwriteNewValue, null, false, out result)); Assert.False(TestMergeBaseItemDataPerson(GetOldValue(), overwriteNewValue, null, false, out var result));
// People not already in target are not merged into it from source // People not already in target are not merged into it from source
actual = (List<PersonInfo>)result!; List<PersonInfo> actual = (List<PersonInfo>)result!;
Assert.Single(actual); Assert.Single(actual);
Assert.Equal("Name 1", actual[0].Name); Assert.Equal("Name 1", actual[0].Name);

Loading…
Cancel
Save