diff --git a/Jellyfin.Api/Auth/BaseAuthorizationHandler.cs b/Jellyfin.Api/Auth/BaseAuthorizationHandler.cs
index 7d68aecf99..392498c530 100644
--- a/Jellyfin.Api/Auth/BaseAuthorizationHandler.cs
+++ b/Jellyfin.Api/Auth/BaseAuthorizationHandler.cs
@@ -77,8 +77,9 @@ namespace Jellyfin.Api.Auth
return false;
}
- var ip = _httpContextAccessor.HttpContext.GetNormalizedRemoteIp();
- var isInLocalNetwork = _networkManager.IsInLocalNetwork(ip);
+ var isInLocalNetwork = _httpContextAccessor.HttpContext != null
+ && _networkManager.IsInLocalNetwork(_httpContextAccessor.HttpContext.GetNormalizedRemoteIp());
+
// User cannot access remotely and user is remote
if (!user.HasPermission(PermissionKind.EnableRemoteAccess) && !isInLocalNetwork)
{
diff --git a/Jellyfin.Api/Controllers/ConfigurationController.cs b/Jellyfin.Api/Controllers/ConfigurationController.cs
index 049a4bed7b..b6309baab0 100644
--- a/Jellyfin.Api/Controllers/ConfigurationController.cs
+++ b/Jellyfin.Api/Controllers/ConfigurationController.cs
@@ -1,3 +1,4 @@
+using System;
using System.ComponentModel.DataAnnotations;
using System.Net.Mime;
using System.Text.Json;
@@ -94,6 +95,11 @@ namespace Jellyfin.Api.Controllers
{
var configurationType = _configurationManager.GetConfigurationType(key);
var configuration = await JsonSerializer.DeserializeAsync(Request.Body, configurationType, _serializerOptions).ConfigureAwait(false);
+ if (configuration == null)
+ {
+ throw new ArgumentException("Body doesn't contain a valid configuration");
+ }
+
_configurationManager.SaveConfiguration(key, configuration);
return NoContent();
}
diff --git a/MediaBrowser.Common/Configuration/ConfigurationStore.cs b/MediaBrowser.Common/Configuration/ConfigurationStore.cs
index d31d45e4c3..050ab1ab51 100644
--- a/MediaBrowser.Common/Configuration/ConfigurationStore.cs
+++ b/MediaBrowser.Common/Configuration/ConfigurationStore.cs
@@ -1,3 +1,5 @@
+#nullable disable
+
using System;
namespace MediaBrowser.Common.Configuration
diff --git a/MediaBrowser.Common/Configuration/ConfigurationUpdateEventArgs.cs b/MediaBrowser.Common/Configuration/ConfigurationUpdateEventArgs.cs
index 344aecf530..2df87d8792 100644
--- a/MediaBrowser.Common/Configuration/ConfigurationUpdateEventArgs.cs
+++ b/MediaBrowser.Common/Configuration/ConfigurationUpdateEventArgs.cs
@@ -1,3 +1,4 @@
+#nullable disable
#pragma warning disable CS1591
using System;
diff --git a/MediaBrowser.Common/Configuration/IApplicationPaths.cs b/MediaBrowser.Common/Configuration/IApplicationPaths.cs
index 57c6546675..1370e6d79e 100644
--- a/MediaBrowser.Common/Configuration/IApplicationPaths.cs
+++ b/MediaBrowser.Common/Configuration/IApplicationPaths.cs
@@ -1,3 +1,5 @@
+#nullable disable
+
namespace MediaBrowser.Common.Configuration
{
///
diff --git a/MediaBrowser.Common/Cryptography/PasswordHash.cs b/MediaBrowser.Common/Cryptography/PasswordHash.cs
index ec21d05803..0e20653029 100644
--- a/MediaBrowser.Common/Cryptography/PasswordHash.cs
+++ b/MediaBrowser.Common/Cryptography/PasswordHash.cs
@@ -1,5 +1,4 @@
#pragma warning disable CS1591
-#nullable enable
using System;
using System.Collections.Generic;
diff --git a/MediaBrowser.Common/Events/EventHelper.cs b/MediaBrowser.Common/Events/EventHelper.cs
index c9d3226ac8..a9cf86fbc3 100644
--- a/MediaBrowser.Common/Events/EventHelper.cs
+++ b/MediaBrowser.Common/Events/EventHelper.cs
@@ -17,7 +17,7 @@ namespace MediaBrowser.Common.Events
/// The sender.
/// The instance containing the event data.
/// The logger.
- public static void QueueEventIfNotNull(EventHandler handler, object sender, EventArgs args, ILogger logger)
+ public static void QueueEventIfNotNull(EventHandler? handler, object sender, EventArgs args, ILogger logger)
{
if (handler != null)
{
@@ -43,7 +43,7 @@ namespace MediaBrowser.Common.Events
/// The sender.
/// The args.
/// The logger.
- public static void QueueEventIfNotNull(EventHandler handler, object sender, T args, ILogger logger)
+ public static void QueueEventIfNotNull(EventHandler? handler, object sender, T args, ILogger logger)
{
if (handler != null)
{
diff --git a/MediaBrowser.Common/Extensions/BaseExtensions.cs b/MediaBrowser.Common/Extensions/BaseExtensions.cs
index 40020093b6..08964420e7 100644
--- a/MediaBrowser.Common/Extensions/BaseExtensions.cs
+++ b/MediaBrowser.Common/Extensions/BaseExtensions.cs
@@ -1,5 +1,3 @@
-#nullable enable
-
using System;
using System.Security.Cryptography;
using System.Text;
diff --git a/MediaBrowser.Common/Extensions/CopyToExtensions.cs b/MediaBrowser.Common/Extensions/CopyToExtensions.cs
index 94bf7c7401..2ecbc6539b 100644
--- a/MediaBrowser.Common/Extensions/CopyToExtensions.cs
+++ b/MediaBrowser.Common/Extensions/CopyToExtensions.cs
@@ -1,5 +1,3 @@
-#nullable enable
-
using System.Collections.Generic;
namespace MediaBrowser.Common.Extensions
diff --git a/MediaBrowser.Common/Extensions/HttpContextExtensions.cs b/MediaBrowser.Common/Extensions/HttpContextExtensions.cs
index e51ad42d12..1e5877c84c 100644
--- a/MediaBrowser.Common/Extensions/HttpContextExtensions.cs
+++ b/MediaBrowser.Common/Extensions/HttpContextExtensions.cs
@@ -17,7 +17,7 @@ namespace MediaBrowser.Common.Extensions
{
return (context.Connection.LocalIpAddress == null
&& context.Connection.RemoteIpAddress == null)
- || context.Connection.LocalIpAddress.Equals(context.Connection.RemoteIpAddress);
+ || Equals(context.Connection.LocalIpAddress, context.Connection.RemoteIpAddress);
}
///
diff --git a/MediaBrowser.Common/Extensions/MethodNotAllowedException.cs b/MediaBrowser.Common/Extensions/MethodNotAllowedException.cs
index 258bd6662c..48e758ee4c 100644
--- a/MediaBrowser.Common/Extensions/MethodNotAllowedException.cs
+++ b/MediaBrowser.Common/Extensions/MethodNotAllowedException.cs
@@ -1,5 +1,3 @@
-#nullable enable
-
using System;
namespace MediaBrowser.Common.Extensions
diff --git a/MediaBrowser.Common/Extensions/ProcessExtensions.cs b/MediaBrowser.Common/Extensions/ProcessExtensions.cs
index 2f52ba196a..c747871222 100644
--- a/MediaBrowser.Common/Extensions/ProcessExtensions.cs
+++ b/MediaBrowser.Common/Extensions/ProcessExtensions.cs
@@ -1,5 +1,3 @@
-#nullable enable
-
using System;
using System.Diagnostics;
using System.Threading;
diff --git a/MediaBrowser.Common/Extensions/RateLimitExceededException.cs b/MediaBrowser.Common/Extensions/RateLimitExceededException.cs
index 7c7bdaa92f..95802a4626 100644
--- a/MediaBrowser.Common/Extensions/RateLimitExceededException.cs
+++ b/MediaBrowser.Common/Extensions/RateLimitExceededException.cs
@@ -1,4 +1,3 @@
-#nullable enable
#pragma warning disable CS1591
using System;
diff --git a/MediaBrowser.Common/Extensions/ResourceNotFoundException.cs b/MediaBrowser.Common/Extensions/ResourceNotFoundException.cs
index ebac9d8e6b..22130c5a1e 100644
--- a/MediaBrowser.Common/Extensions/ResourceNotFoundException.cs
+++ b/MediaBrowser.Common/Extensions/ResourceNotFoundException.cs
@@ -1,5 +1,3 @@
-#nullable enable
-
using System;
namespace MediaBrowser.Common.Extensions
diff --git a/MediaBrowser.Common/Extensions/ShuffleExtensions.cs b/MediaBrowser.Common/Extensions/ShuffleExtensions.cs
index 6f0ea9bd58..2604abf85c 100644
--- a/MediaBrowser.Common/Extensions/ShuffleExtensions.cs
+++ b/MediaBrowser.Common/Extensions/ShuffleExtensions.cs
@@ -1,5 +1,3 @@
-#nullable enable
-
using System;
using System.Collections.Generic;
diff --git a/MediaBrowser.Common/Extensions/SplitStringExtensions.cs b/MediaBrowser.Common/Extensions/SplitStringExtensions.cs
index e78fa78d6a..9c9108495f 100644
--- a/MediaBrowser.Common/Extensions/SplitStringExtensions.cs
+++ b/MediaBrowser.Common/Extensions/SplitStringExtensions.cs
@@ -21,7 +21,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
-#nullable enable
+
#pragma warning disable CS1591
#pragma warning disable CA1034
using System;
diff --git a/MediaBrowser.Common/Extensions/StreamExtensions.cs b/MediaBrowser.Common/Extensions/StreamExtensions.cs
index d49bf1d469..5cbf57d988 100644
--- a/MediaBrowser.Common/Extensions/StreamExtensions.cs
+++ b/MediaBrowser.Common/Extensions/StreamExtensions.cs
@@ -1,5 +1,3 @@
-#nullable enable
-
using System.Collections.Generic;
using System.IO;
using System.Linq;
diff --git a/MediaBrowser.Common/IApplicationHost.cs b/MediaBrowser.Common/IApplicationHost.cs
index c3e4ed6db8..46d93e4940 100644
--- a/MediaBrowser.Common/IApplicationHost.cs
+++ b/MediaBrowser.Common/IApplicationHost.cs
@@ -1,3 +1,5 @@
+#nullable disable
+
using System;
using System.Collections.Generic;
using System.Reflection;
diff --git a/MediaBrowser.Common/Json/Converters/JsonCommaDelimitedArrayConverter.cs b/MediaBrowser.Common/Json/Converters/JsonCommaDelimitedArrayConverter.cs
index 2ec702165d..127a41a06b 100644
--- a/MediaBrowser.Common/Json/Converters/JsonCommaDelimitedArrayConverter.cs
+++ b/MediaBrowser.Common/Json/Converters/JsonCommaDelimitedArrayConverter.cs
@@ -9,67 +9,16 @@ namespace MediaBrowser.Common.Json.Converters
/// Convert comma delimited string to array of type.
///
/// Type to convert to.
- public class JsonCommaDelimitedArrayConverter : JsonConverter
+ public sealed class JsonCommaDelimitedArrayConverter : JsonDelimitedArrayConverter
{
- private readonly TypeConverter _typeConverter;
-
///
/// Initializes a new instance of the class.
///
- public JsonCommaDelimitedArrayConverter()
+ public JsonCommaDelimitedArrayConverter() : base()
{
- _typeConverter = TypeDescriptor.GetConverter(typeof(T));
}
///
- public override T[] Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
- {
- if (reader.TokenType == JsonTokenType.String)
- {
- var stringEntries = reader.GetString().Split(',', StringSplitOptions.RemoveEmptyEntries);
- if (stringEntries.Length == 0)
- {
- return Array.Empty();
- }
-
- var parsedValues = new object[stringEntries.Length];
- var convertedCount = 0;
- for (var i = 0; i < stringEntries.Length; i++)
- {
- try
- {
- parsedValues[i] = _typeConverter.ConvertFrom(stringEntries[i].Trim());
- convertedCount++;
- }
- catch (FormatException)
- {
- // TODO log when upgraded to .Net6
- // https://github.com/dotnet/runtime/issues/42975
- // _logger.LogDebug(e, "Error converting value.");
- }
- }
-
- var typedValues = new T[convertedCount];
- var typedValueIndex = 0;
- for (var i = 0; i < stringEntries.Length; i++)
- {
- if (parsedValues[i] != null)
- {
- typedValues.SetValue(parsedValues[i], typedValueIndex);
- typedValueIndex++;
- }
- }
-
- return typedValues;
- }
-
- return JsonSerializer.Deserialize(ref reader, options);
- }
-
- ///
- public override void Write(Utf8JsonWriter writer, T[] value, JsonSerializerOptions options)
- {
- throw new NotImplementedException();
- }
+ protected override char Delimiter => ',';
}
}
diff --git a/MediaBrowser.Common/Json/Converters/JsonCommaDelimitedArrayConverterFactory.cs b/MediaBrowser.Common/Json/Converters/JsonCommaDelimitedArrayConverterFactory.cs
index 24ed3ea19e..de41348dda 100644
--- a/MediaBrowser.Common/Json/Converters/JsonCommaDelimitedArrayConverterFactory.cs
+++ b/MediaBrowser.Common/Json/Converters/JsonCommaDelimitedArrayConverterFactory.cs
@@ -19,10 +19,10 @@ namespace MediaBrowser.Common.Json.Converters
}
///
- public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options)
+ public override JsonConverter? CreateConverter(Type typeToConvert, JsonSerializerOptions options)
{
var structType = typeToConvert.GetElementType() ?? typeToConvert.GenericTypeArguments[0];
- return (JsonConverter)Activator.CreateInstance(typeof(JsonCommaDelimitedArrayConverter<>).MakeGenericType(structType));
+ return (JsonConverter?)Activator.CreateInstance(typeof(JsonCommaDelimitedArrayConverter<>).MakeGenericType(structType));
}
}
}
diff --git a/MediaBrowser.Common/Json/Converters/JsonDelimitedArrayConverter.cs b/MediaBrowser.Common/Json/Converters/JsonDelimitedArrayConverter.cs
new file mode 100644
index 0000000000..b691798c98
--- /dev/null
+++ b/MediaBrowser.Common/Json/Converters/JsonDelimitedArrayConverter.cs
@@ -0,0 +1,81 @@
+using System;
+using System.ComponentModel;
+using System.Text.Json;
+using System.Text.Json.Serialization;
+
+namespace MediaBrowser.Common.Json.Converters
+{
+ ///
+ /// Convert delimited string to array of type.
+ ///
+ /// Type to convert to.
+ public abstract class JsonDelimitedArrayConverter : JsonConverter
+ {
+ private readonly TypeConverter _typeConverter;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ protected JsonDelimitedArrayConverter()
+ {
+ _typeConverter = TypeDescriptor.GetConverter(typeof(T));
+ }
+
+ ///
+ /// Gets the array delimiter.
+ ///
+ protected virtual char Delimiter { get; }
+
+ ///
+ public override T[]? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
+ {
+ if (reader.TokenType == JsonTokenType.String)
+ {
+ // GetString can't return null here because we already handled it above
+ var stringEntries = reader.GetString()?.Split(Delimiter, StringSplitOptions.RemoveEmptyEntries);
+ if (stringEntries == null || stringEntries.Length == 0)
+ {
+ return Array.Empty();
+ }
+
+ var parsedValues = new object[stringEntries.Length];
+ var convertedCount = 0;
+ for (var i = 0; i < stringEntries.Length; i++)
+ {
+ try
+ {
+ parsedValues[i] = _typeConverter.ConvertFrom(stringEntries[i].Trim());
+ convertedCount++;
+ }
+ catch (FormatException)
+ {
+ // TODO log when upgraded to .Net6
+ // https://github.com/dotnet/runtime/issues/42975
+ // _logger.LogDebug(e, "Error converting value.");
+ }
+ }
+
+ var typedValues = new T[convertedCount];
+ var typedValueIndex = 0;
+ for (var i = 0; i < stringEntries.Length; i++)
+ {
+ if (parsedValues[i] != null)
+ {
+ typedValues.SetValue(parsedValues[i], typedValueIndex);
+ typedValueIndex++;
+ }
+ }
+
+ return typedValues;
+ }
+
+ return JsonSerializer.Deserialize(ref reader, options);
+ }
+
+ ///
+ public override void Write(Utf8JsonWriter writer, T[]? value, JsonSerializerOptions options)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/MediaBrowser.Common/Json/Converters/JsonNullableStructConverterFactory.cs b/MediaBrowser.Common/Json/Converters/JsonNullableStructConverterFactory.cs
index d5b54e3ca8..e2a3d798a2 100644
--- a/MediaBrowser.Common/Json/Converters/JsonNullableStructConverterFactory.cs
+++ b/MediaBrowser.Common/Json/Converters/JsonNullableStructConverterFactory.cs
@@ -18,10 +18,10 @@ namespace MediaBrowser.Common.Json.Converters
}
///
- public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options)
+ public override JsonConverter? CreateConverter(Type typeToConvert, JsonSerializerOptions options)
{
var structType = typeToConvert.GenericTypeArguments[0];
- return (JsonConverter)Activator.CreateInstance(typeof(JsonNullableStructConverter<>).MakeGenericType(structType));
+ return (JsonConverter?)Activator.CreateInstance(typeof(JsonNullableStructConverter<>).MakeGenericType(structType));
}
}
-}
\ No newline at end of file
+}
diff --git a/MediaBrowser.Common/Json/Converters/JsonOmdbNotAvailableStringConverter.cs b/MediaBrowser.Common/Json/Converters/JsonOmdbNotAvailableStringConverter.cs
index 6a8790374b..77cf46b706 100644
--- a/MediaBrowser.Common/Json/Converters/JsonOmdbNotAvailableStringConverter.cs
+++ b/MediaBrowser.Common/Json/Converters/JsonOmdbNotAvailableStringConverter.cs
@@ -7,15 +7,21 @@ namespace MediaBrowser.Common.Json.Converters
///
/// Converts a string N/A to string.Empty.
///
- public class JsonOmdbNotAvailableStringConverter : JsonConverter
+ public class JsonOmdbNotAvailableStringConverter : JsonConverter
{
///
- public override string Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
+ public override string? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
+ if (reader.TokenType == JsonTokenType.Null)
+ {
+ return null;
+ }
+
if (reader.TokenType == JsonTokenType.String)
{
- var str = reader.GetString();
- if (str != null && str.Equals("N/A", StringComparison.OrdinalIgnoreCase))
+ // GetString can't return null here because we already handled it above
+ var str = reader.GetString()!;
+ if (str.Equals("N/A", StringComparison.OrdinalIgnoreCase))
{
return null;
}
@@ -23,11 +29,11 @@ namespace MediaBrowser.Common.Json.Converters
return str;
}
- return JsonSerializer.Deserialize(ref reader, options);
+ return JsonSerializer.Deserialize(ref reader, options);
}
///
- public override void Write(Utf8JsonWriter writer, string value, JsonSerializerOptions options)
+ public override void Write(Utf8JsonWriter writer, string? value, JsonSerializerOptions options)
{
writer.WriteStringValue(value);
}
diff --git a/MediaBrowser.Common/Json/Converters/JsonPipeDelimitedArrayConverter.cs b/MediaBrowser.Common/Json/Converters/JsonPipeDelimitedArrayConverter.cs
index c408a3be13..a8f6cfbecf 100644
--- a/MediaBrowser.Common/Json/Converters/JsonPipeDelimitedArrayConverter.cs
+++ b/MediaBrowser.Common/Json/Converters/JsonPipeDelimitedArrayConverter.cs
@@ -9,67 +9,16 @@ namespace MediaBrowser.Common.Json.Converters
/// Convert Pipe delimited string to array of type.
///
/// Type to convert to.
- public class JsonPipeDelimitedArrayConverter : JsonConverter
+ public sealed class JsonPipeDelimitedArrayConverter : JsonDelimitedArrayConverter
{
- private readonly TypeConverter _typeConverter;
-
///
/// Initializes a new instance of the class.
///
- public JsonPipeDelimitedArrayConverter()
+ public JsonPipeDelimitedArrayConverter() : base()
{
- _typeConverter = TypeDescriptor.GetConverter(typeof(T));
}
///
- public override T[] Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
- {
- if (reader.TokenType == JsonTokenType.String)
- {
- var stringEntries = reader.GetString()?.Split('|', StringSplitOptions.RemoveEmptyEntries);
- if (stringEntries == null || stringEntries.Length == 0)
- {
- return Array.Empty();
- }
-
- var parsedValues = new object[stringEntries.Length];
- var convertedCount = 0;
- for (var i = 0; i < stringEntries.Length; i++)
- {
- try
- {
- parsedValues[i] = _typeConverter.ConvertFrom(stringEntries[i].Trim());
- convertedCount++;
- }
- catch (FormatException)
- {
- // TODO log when upgraded to .Net6
- // https://github.com/dotnet/runtime/issues/42975
- // _logger.LogDebug(e, "Error converting value.");
- }
- }
-
- var typedValues = new T[convertedCount];
- var typedValueIndex = 0;
- for (var i = 0; i < stringEntries.Length; i++)
- {
- if (parsedValues[i] != null)
- {
- typedValues.SetValue(parsedValues[i], typedValueIndex);
- typedValueIndex++;
- }
- }
-
- return typedValues;
- }
-
- return JsonSerializer.Deserialize(ref reader, options);
- }
-
- ///
- public override void Write(Utf8JsonWriter writer, T[] value, JsonSerializerOptions options)
- {
- throw new NotImplementedException();
- }
+ protected override char Delimiter => '|';
}
}
diff --git a/MediaBrowser.Common/Json/Converters/JsonPipeDelimitedArrayConverterFactory.cs b/MediaBrowser.Common/Json/Converters/JsonPipeDelimitedArrayConverterFactory.cs
index 5e77223ef2..1bebc49ecc 100644
--- a/MediaBrowser.Common/Json/Converters/JsonPipeDelimitedArrayConverterFactory.cs
+++ b/MediaBrowser.Common/Json/Converters/JsonPipeDelimitedArrayConverterFactory.cs
@@ -19,10 +19,10 @@ namespace MediaBrowser.Common.Json.Converters
}
///
- public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options)
+ public override JsonConverter? CreateConverter(Type typeToConvert, JsonSerializerOptions options)
{
var structType = typeToConvert.GetElementType() ?? typeToConvert.GenericTypeArguments[0];
- return (JsonConverter)Activator.CreateInstance(typeof(JsonPipeDelimitedArrayConverter<>).MakeGenericType(structType));
+ return (JsonConverter?)Activator.CreateInstance(typeof(JsonPipeDelimitedArrayConverter<>).MakeGenericType(structType));
}
}
}
diff --git a/MediaBrowser.Common/Json/Converters/JsonStringConverter.cs b/MediaBrowser.Common/Json/Converters/JsonStringConverter.cs
index 669b3cd077..6cd980e48a 100644
--- a/MediaBrowser.Common/Json/Converters/JsonStringConverter.cs
+++ b/MediaBrowser.Common/Json/Converters/JsonStringConverter.cs
@@ -9,10 +9,10 @@ namespace MediaBrowser.Common.Json.Converters
///
/// Converter to allow the serializer to read strings.
///
- public class JsonStringConverter : JsonConverter
+ public class JsonStringConverter : JsonConverter
{
///
- public override string Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
+ public override string? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
return reader.TokenType switch
{
@@ -23,7 +23,7 @@ namespace MediaBrowser.Common.Json.Converters
}
///
- public override void Write(Utf8JsonWriter writer, string value, JsonSerializerOptions options)
+ public override void Write(Utf8JsonWriter writer, string? value, JsonSerializerOptions options)
{
writer.WriteStringValue(value);
}
@@ -36,4 +36,4 @@ namespace MediaBrowser.Common.Json.Converters
return Encoding.UTF8.GetString(utf8Bytes);
}
}
-}
\ No newline at end of file
+}
diff --git a/MediaBrowser.Common/Json/Converters/JsonVersionConverter.cs b/MediaBrowser.Common/Json/Converters/JsonVersionConverter.cs
index f69e868cc4..81c093c541 100644
--- a/MediaBrowser.Common/Json/Converters/JsonVersionConverter.cs
+++ b/MediaBrowser.Common/Json/Converters/JsonVersionConverter.cs
@@ -14,7 +14,7 @@ namespace MediaBrowser.Common.Json.Converters
{
///
public override Version Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
- => new Version(reader.GetString());
+ => new Version(reader.GetString()!); // Will throw ArgumentNullException on null
///
public override void Write(Utf8JsonWriter writer, Version value, JsonSerializerOptions options)
diff --git a/MediaBrowser.Common/MediaBrowser.Common.csproj b/MediaBrowser.Common/MediaBrowser.Common.csproj
index 0d9f78704e..0299a84563 100644
--- a/MediaBrowser.Common/MediaBrowser.Common.csproj
+++ b/MediaBrowser.Common/MediaBrowser.Common.csproj
@@ -33,6 +33,7 @@
false
true
true
+ enable
AllEnabledByDefault
../jellyfin.ruleset
true
diff --git a/MediaBrowser.Common/Net/INetworkManager.cs b/MediaBrowser.Common/Net/INetworkManager.cs
index 185df5b773..b939397301 100644
--- a/MediaBrowser.Common/Net/INetworkManager.cs
+++ b/MediaBrowser.Common/Net/INetworkManager.cs
@@ -1,4 +1,3 @@
-#nullable enable
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
diff --git a/MediaBrowser.Common/Net/IPHost.cs b/MediaBrowser.Common/Net/IPHost.cs
index 7156ce6188..5db8817ee6 100644
--- a/MediaBrowser.Common/Net/IPHost.cs
+++ b/MediaBrowser.Common/Net/IPHost.cs
@@ -1,4 +1,3 @@
-#nullable enable
using System;
using System.Diagnostics;
using System.Linq;
diff --git a/MediaBrowser.Common/Net/IPNetAddress.cs b/MediaBrowser.Common/Net/IPNetAddress.cs
index 589aad4b09..f6e3971bf3 100644
--- a/MediaBrowser.Common/Net/IPNetAddress.cs
+++ b/MediaBrowser.Common/Net/IPNetAddress.cs
@@ -1,4 +1,3 @@
-#nullable enable
using System;
using System.Net;
using System.Net.Sockets;
diff --git a/MediaBrowser.Common/Net/IPObject.cs b/MediaBrowser.Common/Net/IPObject.cs
index 3542dcd75e..2612268fd8 100644
--- a/MediaBrowser.Common/Net/IPObject.cs
+++ b/MediaBrowser.Common/Net/IPObject.cs
@@ -1,4 +1,3 @@
-#nullable enable
using System;
using System.Net;
using System.Net.Sockets;
diff --git a/MediaBrowser.Common/Plugins/BasePlugin.cs b/MediaBrowser.Common/Plugins/BasePlugin.cs
index ad5a7338dd..8972089a8e 100644
--- a/MediaBrowser.Common/Plugins/BasePlugin.cs
+++ b/MediaBrowser.Common/Plugins/BasePlugin.cs
@@ -1,3 +1,5 @@
+#nullable disable
+
using System;
using System.IO;
using System.Reflection;
diff --git a/MediaBrowser.Common/Plugins/BasePluginOfT.cs b/MediaBrowser.Common/Plugins/BasePluginOfT.cs
index e074cc6a01..8a6d28e0f6 100644
--- a/MediaBrowser.Common/Plugins/BasePluginOfT.cs
+++ b/MediaBrowser.Common/Plugins/BasePluginOfT.cs
@@ -1,4 +1,6 @@
+#nullable disable
#pragma warning disable SA1649 // File name should match first type name
+
using System;
using System.IO;
using System.Runtime.InteropServices;
diff --git a/MediaBrowser.Common/Plugins/IPlugin.cs b/MediaBrowser.Common/Plugins/IPlugin.cs
index b2ba1179c1..01e0a536da 100644
--- a/MediaBrowser.Common/Plugins/IPlugin.cs
+++ b/MediaBrowser.Common/Plugins/IPlugin.cs
@@ -1,3 +1,5 @@
+#nullable disable
+
using System;
using MediaBrowser.Model.Plugins;
diff --git a/MediaBrowser.Common/Plugins/IPluginManager.cs b/MediaBrowser.Common/Plugins/IPluginManager.cs
index 0e2e814cb0..176bcbbd54 100644
--- a/MediaBrowser.Common/Plugins/IPluginManager.cs
+++ b/MediaBrowser.Common/Plugins/IPluginManager.cs
@@ -1,5 +1,3 @@
-#nullable enable
-
using System;
using System.Collections.Generic;
using System.Reflection;
diff --git a/MediaBrowser.Common/Plugins/LocalPlugin.cs b/MediaBrowser.Common/Plugins/LocalPlugin.cs
index 12a1ad1ec8..4c8e2d5044 100644
--- a/MediaBrowser.Common/Plugins/LocalPlugin.cs
+++ b/MediaBrowser.Common/Plugins/LocalPlugin.cs
@@ -1,4 +1,3 @@
-#nullable enable
using System;
using System.Collections.Generic;
using MediaBrowser.Model.Plugins;
diff --git a/MediaBrowser.Common/Plugins/PluginManifest.cs b/MediaBrowser.Common/Plugins/PluginManifest.cs
index 4c724f6949..2910dbe144 100644
--- a/MediaBrowser.Common/Plugins/PluginManifest.cs
+++ b/MediaBrowser.Common/Plugins/PluginManifest.cs
@@ -1,5 +1,3 @@
-#nullable enable
-
using System;
using System.Text.Json.Serialization;
using MediaBrowser.Model.Plugins;
diff --git a/MediaBrowser.Common/Progress/ActionableProgress.cs b/MediaBrowser.Common/Progress/ActionableProgress.cs
index fe7cb10788..0ba46ea3ba 100644
--- a/MediaBrowser.Common/Progress/ActionableProgress.cs
+++ b/MediaBrowser.Common/Progress/ActionableProgress.cs
@@ -14,9 +14,9 @@ namespace MediaBrowser.Common.Progress
///
/// The _actions.
///
- private Action _action;
+ private Action? _action;
- public event EventHandler ProgressChanged;
+ public event EventHandler? ProgressChanged;
///
/// Registers the action.
diff --git a/MediaBrowser.Common/Progress/SimpleProgress.cs b/MediaBrowser.Common/Progress/SimpleProgress.cs
index 988d8ad34a..7071f2bc3d 100644
--- a/MediaBrowser.Common/Progress/SimpleProgress.cs
+++ b/MediaBrowser.Common/Progress/SimpleProgress.cs
@@ -7,7 +7,7 @@ namespace MediaBrowser.Common.Progress
{
public class SimpleProgress : IProgress
{
- public event EventHandler ProgressChanged;
+ public event EventHandler? ProgressChanged;
public void Report(T value)
{
diff --git a/MediaBrowser.Common/Providers/ProviderIdParsers.cs b/MediaBrowser.Common/Providers/ProviderIdParsers.cs
index 64c2e19766..33d09ed385 100644
--- a/MediaBrowser.Common/Providers/ProviderIdParsers.cs
+++ b/MediaBrowser.Common/Providers/ProviderIdParsers.cs
@@ -1,6 +1,4 @@
-#nullable enable
-
-using System;
+using System;
using System.Diagnostics.CodeAnalysis;
namespace MediaBrowser.Common.Providers
diff --git a/MediaBrowser.Common/Updates/IInstallationManager.cs b/MediaBrowser.Common/Updates/IInstallationManager.cs
index 0844c2d792..c2a28e0a2c 100644
--- a/MediaBrowser.Common/Updates/IInstallationManager.cs
+++ b/MediaBrowser.Common/Updates/IInstallationManager.cs
@@ -1,5 +1,3 @@
-#nullable enable
-
using System;
using System.Collections.Generic;
using System.Threading;
diff --git a/MediaBrowser.Common/Updates/InstallationEventArgs.cs b/MediaBrowser.Common/Updates/InstallationEventArgs.cs
index adf336313f..f4f7599559 100644
--- a/MediaBrowser.Common/Updates/InstallationEventArgs.cs
+++ b/MediaBrowser.Common/Updates/InstallationEventArgs.cs
@@ -1,3 +1,5 @@
+#nullable disable
+
using System;
using MediaBrowser.Model.Updates;
diff --git a/MediaBrowser.Common/Updates/InstallationFailedEventArgs.cs b/MediaBrowser.Common/Updates/InstallationFailedEventArgs.cs
index 46f10c84fd..d37146195c 100644
--- a/MediaBrowser.Common/Updates/InstallationFailedEventArgs.cs
+++ b/MediaBrowser.Common/Updates/InstallationFailedEventArgs.cs
@@ -1,3 +1,4 @@
+#nullable disable
#pragma warning disable CS1591
using System;