diff --git a/.editorconfig b/.editorconfig index 87902f038..a9a2a81b8 100644 --- a/.editorconfig +++ b/.editorconfig @@ -85,7 +85,7 @@ dotnet_diagnostic.CA1837.severity = suggestion # CA1837: Use 'Environment.Proce dotnet_diagnostic.CA1838.severity = suggestion # CA1838: Avoid 'StringBuilder' parameters for P/Invokes dotnet_diagnostic.CA1845.severity = none # CA1845: Use span-based 'string.Concat' dotnet_diagnostic.CA1846.severity = none # CA1846: Prefer 'AsSpan' over 'Substring' -dotnet_diagnostic.CA1847.severity = none # CA1847: Use char literal for a single character lookup +dotnet_diagnostic.CA1847.severity = suggestion # CA1847: Use char literal for a single character lookup dotnet_diagnostic.CA1852.severity = suggestion # CA1852: Seal internal types dotnet_diagnostic.CA1854.severity = suggestion # CA1854: Prefer the 'IDictionary.TryGetValue(TKey, out TValue)' method dotnet_diagnostic.CA1859.severity = suggestion # CA1859: Use concrete types when possible for improved performance diff --git a/src/core/IronPython.Modules/IronPython.Modules.csproj b/src/core/IronPython.Modules/IronPython.Modules.csproj index a01c87ae2..7a314eec0 100644 --- a/src/core/IronPython.Modules/IronPython.Modules.csproj +++ b/src/core/IronPython.Modules/IronPython.Modules.csproj @@ -5,6 +5,16 @@ 885063680 true true + True + + T:System.Diagnostics.CodeAnalysis.AllowNullAttribute; + T:System.Diagnostics.CodeAnalysis.DisallowNullAttribute; + T:System.Diagnostics.CodeAnalysis.MemberNotNullAttribute; + T:System.Diagnostics.CodeAnalysis.NotNullAttribute; + T:System.Diagnostics.CodeAnalysis.NotNullWhenAttribute; + T:System.Runtime.Versioning.SupportedOSPlatformAttribute; + M:System.String.EndsWith(System.Char); + @@ -32,6 +42,13 @@ + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/src/core/IronPython/IronPython.csproj b/src/core/IronPython/IronPython.csproj index f33f51a8f..f4c66fcf1 100644 --- a/src/core/IronPython/IronPython.csproj +++ b/src/core/IronPython/IronPython.csproj @@ -5,6 +5,21 @@ 879755264 true true + True + + T:System.Diagnostics.CodeAnalysis.AllowNullAttribute; + T:System.Diagnostics.CodeAnalysis.DisallowNullAttribute; + T:System.Diagnostics.CodeAnalysis.MemberNotNullAttribute; + T:System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute; + T:System.Diagnostics.CodeAnalysis.NotNullAttribute; + T:System.Diagnostics.CodeAnalysis.NotNullIfNotNullAttribute; + T:System.Diagnostics.CodeAnalysis.NotNullWhenAttribute; + T:System.Runtime.Versioning.SupportedOSPlatformAttribute; + T:System.Runtime.Versioning.UnsupportedOSPlatformAttribute; + M:System.String.StartsWith(System.Char); + M:System.String.EndsWith(System.Char); + M:System.String.Contains(System.Char); + @@ -50,7 +65,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/core/IronPython/Modules/_fileio.cs b/src/core/IronPython/Modules/_fileio.cs index e599bfa34..efc214fc0 100644 --- a/src/core/IronPython/Modules/_fileio.cs +++ b/src/core/IronPython/Modules/_fileio.cs @@ -611,10 +611,5 @@ private void EnsureWritable() { #endregion } - -#if !NETCOREAPP - private static bool Contains(this string str, char value) - => str.IndexOf(value) != -1; -#endif } } diff --git a/src/core/IronPython/StringExtensions.cs b/src/core/IronPython/StringExtensions.cs deleted file mode 100644 index acbc2fbe5..000000000 --- a/src/core/IronPython/StringExtensions.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; - -namespace IronPython { - internal static class StringExtensions { -#if !NETCOREAPP - public static bool EndsWith(this string str, char value) { - return str.EndsWith(value.ToString(), StringComparison.Ordinal); - } - - public static bool StartsWith(this string str, char value) { - return str.StartsWith(value.ToString(), StringComparison.Ordinal); - } -#endif - } -} diff --git a/src/core/IronPython/SystemRuntimeVersioning.cs b/src/core/IronPython/SystemRuntimeVersioning.cs deleted file mode 100644 index e8c1a7ae5..000000000 --- a/src/core/IronPython/SystemRuntimeVersioning.cs +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the Apache 2.0 license. -// See the LICENSE file in the project root for more information. - -#nullable enable - -namespace System.Runtime.Versioning { -#if !FEATURE_OSPLATFORMATTRIBUTE - internal abstract class OSPlatformAttribute : Attribute { - private protected OSPlatformAttribute(string platformName) { - PlatformName = platformName; - } - public string PlatformName { get; } - } - - [AttributeUsage(AttributeTargets.Assembly | - AttributeTargets.Class | - AttributeTargets.Constructor | - AttributeTargets.Enum | - AttributeTargets.Event | - AttributeTargets.Field | - AttributeTargets.Method | - AttributeTargets.Module | - AttributeTargets.Property | - AttributeTargets.Struct, - AllowMultiple = true, Inherited = false)] - internal sealed class SupportedOSPlatformAttribute : OSPlatformAttribute { - public SupportedOSPlatformAttribute(string platformName) : base(platformName) { - } - } - - [AttributeUsage(AttributeTargets.Assembly | - AttributeTargets.Class | - AttributeTargets.Constructor | - AttributeTargets.Enum | - AttributeTargets.Event | - AttributeTargets.Field | - AttributeTargets.Method | - AttributeTargets.Module | - AttributeTargets.Property | - AttributeTargets.Struct, - AllowMultiple = true, Inherited = false)] - internal sealed class UnsupportedOSPlatformAttribute : OSPlatformAttribute { - public UnsupportedOSPlatformAttribute(string platformName) : base(platformName) { - } - - public UnsupportedOSPlatformAttribute (string platformName, string? message) : base(platformName) { - Message = message; - } - - public string? Message { get; } - } -#endif -}