Skip to content

Commit

Permalink
build: Drop support for .NET Core 2.x
Browse files Browse the repository at this point in the history
Remove build targets for .NET Core 2.0 and 2.1 and target .NET Core 3.1 instead.
Since the library still targets .NET Standard 2.0, too, it continues to be usable from .NET Core 2.x, however, there might be build errors because some extension methods exist in both this library as well as in the .NET Core 2 base class library.

BREAKING CHANGE:  .NET Core 2.0 and  .NET Core 2.1 are no longer supported. Projects targeting these projects might encounter conflicts between extensions methods provided by this library and extension methods provided by the .NET Core Base Class Library.
Pull-Request: #90
  • Loading branch information
ap0llo authored Dec 30, 2021
2 parents a3983a8 + cd91b89 commit 3f2415d
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
6 changes: 3 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ jobs:
- task: CmdLine@2
displayName: Restore NuGet packages
inputs:
script: dotnet restore $(solutionPath)
script: dotnet restore $(solutionPath) /warnaserror
- task: DotNetCoreCLI@2
displayName: Build
inputs:
command: build
projects: $(solutionPath)
arguments: '--configuration $(configuration) --no-restore /m:1'
arguments: '--configuration $(configuration) --no-restore /warnaserror /m:1'
- task: DotNetCoreCLI@2
displayName: Test
inputs:
Expand All @@ -111,7 +111,7 @@ jobs:
inputs:
command: pack
projects: $(solutionPath)
arguments: '--configuration $(configuration) --output $(Build.ArtifactStagingDirectory) --no-build'
arguments: '--configuration $(configuration) --output $(Build.ArtifactStagingDirectory) --no-build /warnaserror'
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifacts: $(artifactsName_Binaries)'
inputs:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="MSBuild.Sdk.Extras">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp2.0;netcoreapp2.1;net472</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp3.1;net472</TargetFrameworks>
<IsPackable>false</IsPackable>
<NoWarn>1591;$(NoWarn)</NoWarn>
</PropertyGroup>
Expand Down
8 changes: 4 additions & 4 deletions src/Utilities/Collections/DictionaryExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ public static TValue GetValueOrDefault<TKey, TValue>(this IDictionary<TKey, TVal
}

// GetValueOrDefault was added in .NET Core 2.0.
// Exclude the method from the reference assembly for .NET Core 2.0,
// so a project targeting netcoreapp2.0, uses the built-in method
#if !(REFERENCE_ASSEMBLY && (NETCOREAPP2_0 || NETCOREAPP2_1 || NETSTANDARD2_1))
// Exclude the method from the reference assembly for .NET Core 2.0 or later,
// so a project targeting netcoreapp2.0 or later, uses the built-in method
#if !(REFERENCE_ASSEMBLY && (NETCOREAPP2_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER))

/// <summary>
/// Tries to get the element with the specified key.
Expand All @@ -56,7 +56,7 @@ public static TValue GetValueOrDefault<TKey, TValue>(this IDictionary<TKey, TVal
/// <typeparam name="TValue">The type of values in the dictionary.</typeparam>
/// <param name="dictionary">The dictionary to retrieve the value from.</param>
/// <param name="key">The key to locate in the dictionary.</param>
[HiddenFromReferenceAssembly("netcoreapp2.0")]
[HiddenFromReferenceAssembly("netcoreapp3.1")]
[HiddenFromReferenceAssembly("netstandard2.1")]
public static TValue GetValueOrDefault<TKey, TValue>(this IReadOnlyDictionary<TKey, TValue> dictionary, TKey key) => dictionary.GetValueOrDefault(key, default);

Expand Down
8 changes: 4 additions & 4 deletions src/Utilities/Collections/EnumerableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public static IEnumerable<T> Concat<T>(this IEnumerable<T> enumerable, T newItem

// ToHashSet exists in .NET Core 2.0, .NET Standard 2.1 and .NET Framework 4.7.2
// Exclude the method from the reference assembly for these target frameworks
// so a project targeting netcoreapp2.0, uses the built-in method
#if !(REFERENCE_ASSEMBLY && (NETCOREAPP2_0 || NETCOREAPP2_1 || NET472 || NETSTANDARD2_1))
// so a project targeting these frameworks, uses the built-in method
#if !(REFERENCE_ASSEMBLY && (NETCOREAPP2_0_OR_GREATER|| NET472_OR_GREATER || NETSTANDARD2_1_OR_GREATER))

/// <summary>
/// Creates a new <see cref="HashSet{T}"/> with elements copied from the enumerable
Expand All @@ -67,7 +67,7 @@ public static IEnumerable<T> Concat<T>(this IEnumerable<T> enumerable, T newItem
/// <typeparam name="T">The type of elements in the enumerable.</typeparam>
/// <param name="enumerable">The collection of items to copy to the set.</param>
[HiddenFromReferenceAssembly("net472")]
[HiddenFromReferenceAssembly("netcoreapp2.0")]
[HiddenFromReferenceAssembly("netcoreapp3.1")]
[HiddenFromReferenceAssembly("netstandard2.1")]
public static HashSet<T> ToHashSet<T>(this IEnumerable<T> enumerable) => new HashSet<T>(enumerable);

Expand All @@ -88,7 +88,7 @@ public static IEnumerable<T> Concat<T>(this IEnumerable<T> enumerable, T newItem
/// <param name="enumerable">The collection of items to copy to the set.</param>
/// <param name="comparer">The comparer to use for creating the set.</param>
[HiddenFromReferenceAssembly("net472")]
[HiddenFromReferenceAssembly("netcoreapp2.0")]
[HiddenFromReferenceAssembly("netcoreapp3.1")]
[HiddenFromReferenceAssembly("netstandard2.1")]
public static HashSet<T> ToHashSet<T>(this IEnumerable<T> enumerable, IEqualityComparer<T> comparer) =>
new HashSet<T>(enumerable, comparer);
Expand Down
6 changes: 3 additions & 3 deletions src/Utilities/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static Stream ToStream(this string s)

// Hide Methods from projects targeting .NET Core 2.0 or later / .NET Standard 2.1 or later
// because for that target, String.StartsWith(char) and String.EndsWith(char) are built-in
#if !(REFERENCE_ASSEMBLY && (NETCOREAPP2_0 || NETCOREAPP2_1 || NETSTANDARD2_1))
#if !(REFERENCE_ASSEMBLY && (NETCOREAPP2_0_OR_GREATER|| NETSTANDARD2_1_OR_GREATER))
/// <summary>
/// Determines if the string starts with the specified character.
/// </summary>
Expand All @@ -46,7 +46,7 @@ public static Stream ToStream(this string s)
/// <param name="str">The string which's first character to check.</param>
/// <param name="c">The character to compare to the string's first character.</param>
/// <returns>Returns true if the string has at least one character and the first character matches <paramref name="c"/>.</returns>
[HiddenFromReferenceAssembly("netcoreapp2.0")]
[HiddenFromReferenceAssembly("netcoreapp3.1")]
[HiddenFromReferenceAssembly("netstandard2.1")]
public static bool StartsWith(this string str, char c)
{
Expand All @@ -70,7 +70,7 @@ public static bool StartsWith(this string str, char c)
/// <param name="str">The string which's last character to check.</param>
/// <param name="c">The character to compare to the string's last character.</param>
/// <returns>Returns true if the string has at least one character and the last character matches <paramref name="c"/>.</returns>
[HiddenFromReferenceAssembly("netcoreapp2.0")]
[HiddenFromReferenceAssembly("netcoreapp3.1")]
[HiddenFromReferenceAssembly("netstandard2.1")]
public static bool EndsWith(this string str, char c)
{
Expand Down
14 changes: 7 additions & 7 deletions src/Utilities/Text/StringBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static class StringBuilderExtensions

// Hide AppendJoin() methods from projects targeting .NET Core 2.0 or later / .NET Standard 2.1 or later
// because AppendJoin() is available as built-in functionality.
#if !(REFERENCE_ASSEMBLY && (NETCOREAPP2_0 || NETCOREAPP2_1 || NETSTANDARD2_1))
#if !(REFERENCE_ASSEMBLY && (NETCOREAPP2_0_OR_GREATER|| NETSTANDARD2_1_OR_GREATER))

/// <summary>
/// Appends the members of a collection, separated by the specified separator.
Expand All @@ -31,7 +31,7 @@ public static class StringBuilderExtensions
/// <param name="separator">The separator to insert between the values.</param>
/// <param name="values">The values to concatenate.</param>
/// <returns>Returns the specified <see cref="StringBuilder"/>.</returns>
[HiddenFromReferenceAssembly("netcoreapp2.0")]
[HiddenFromReferenceAssembly("netcoreapp3.1")]
[HiddenFromReferenceAssembly("netstandard2.1")]
public static StringBuilder AppendJoin<T>(this StringBuilder stringBuilder, string separator, IEnumerable<T> values)
{
Expand All @@ -55,7 +55,7 @@ public static StringBuilder AppendJoin<T>(this StringBuilder stringBuilder, stri
/// <param name="separator">The separator to insert between the values.</param>
/// <param name="values">The values to concatenate.</param>
/// <returns>Returns the specified <see cref="StringBuilder"/>.</returns>
[HiddenFromReferenceAssembly("netcoreapp2.0")]
[HiddenFromReferenceAssembly("netcoreapp3.1")]
[HiddenFromReferenceAssembly("netstandard2.1")]
public static StringBuilder AppendJoin(this StringBuilder stringBuilder, string separator, params string[] values)
{
Expand All @@ -79,7 +79,7 @@ public static StringBuilder AppendJoin(this StringBuilder stringBuilder, string
/// <param name="separator">The separator to insert between the values.</param>
/// <param name="values">The values to concatenate.</param>
/// <returns>Returns the specified <see cref="StringBuilder"/>.</returns>
[HiddenFromReferenceAssembly("netcoreapp2.0")]
[HiddenFromReferenceAssembly("netcoreapp3.1")]
[HiddenFromReferenceAssembly("netstandard2.1")]
public static StringBuilder AppendJoin(this StringBuilder stringBuilder, string separator, params object[] values)
{
Expand All @@ -103,7 +103,7 @@ public static StringBuilder AppendJoin(this StringBuilder stringBuilder, string
/// <param name="separator">The separator to insert between the values.</param>
/// <param name="values">The values to concatenate.</param>
/// <returns>Returns the specified <see cref="StringBuilder"/>.</returns>
[HiddenFromReferenceAssembly("netcoreapp2.0")]
[HiddenFromReferenceAssembly("netcoreapp3.1")]
[HiddenFromReferenceAssembly("netstandard2.1")]
public static StringBuilder AppendJoin(this StringBuilder stringBuilder, char separator, params object[] values)
{
Expand All @@ -127,7 +127,7 @@ public static StringBuilder AppendJoin(this StringBuilder stringBuilder, char se
/// <param name="separator">The separator to insert between the values.</param>
/// <param name="values">The values to concatenate.</param>
/// <returns>Returns the specified <see cref="StringBuilder"/>.</returns>
[HiddenFromReferenceAssembly("netcoreapp2.0")]
[HiddenFromReferenceAssembly("netcoreapp3.1")]
[HiddenFromReferenceAssembly("netstandard2.1")]
public static StringBuilder AppendJoin(this StringBuilder stringBuilder, char separator, params string[] values)
{
Expand All @@ -151,7 +151,7 @@ public static StringBuilder AppendJoin(this StringBuilder stringBuilder, char se
/// <param name="separator">The separator to insert between the values.</param>
/// <param name="values">The values to concatenate.</param>
/// <returns>Returns the specified <see cref="StringBuilder"/>.</returns>
[HiddenFromReferenceAssembly("netcoreapp2.0")]
[HiddenFromReferenceAssembly("netcoreapp3.1")]
[HiddenFromReferenceAssembly("netstandard2.1")]
public static StringBuilder AppendJoin<T>(this StringBuilder stringBuilder, char separator, IEnumerable<T> values)
{
Expand Down

0 comments on commit 3f2415d

Please sign in to comment.