Skip to content

Commit

Permalink
fix polyfills visibility (#910)
Browse files Browse the repository at this point in the history
Co-authored-by: Roland Pheasant <roland_pheasant@hotmail.com>
  • Loading branch information
kronic and RolandPheasant authored Jun 29, 2024
1 parent ad5d682 commit 897beb8
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 20 deletions.
6 changes: 1 addition & 5 deletions src/DynamicData/DynamicData.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,4 @@ Dynamic Data is a comprehensive caching and data manipulation solution which int
</Compile>
</ItemGroup>

<ItemGroup>
<Compile Remove="Polyfills/ListEnsureCapacity.cs" Condition="'$(TargetFramework)' == 'net6.0' Or '$(TargetFramework)' == 'net7.0' Or '$(TargetFramework)' == 'net8.0'" />
</ItemGroup>

</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2011-2023 Roland Pheasant. All rights reserved.
// Roland Pheasant licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.

#if !NET7_0_OR_GREATER
namespace System.Runtime.CompilerServices;

// Allows use of the C#11 `required` keyword, internally within this library, when targeting frameworks older than .NET 7.
Expand All @@ -19,3 +19,4 @@ public const string RequiredMembers

public bool IsOptional { get; init; }
}
#endif
7 changes: 3 additions & 4 deletions src/DynamicData/Polyfills/IsExternalInit.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// Copyright (c) 2011-2023 Roland Pheasant. All rights reserved.
// Roland Pheasant licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.

#if !NETCOREAPP
namespace System.Runtime.CompilerServices;

// Allows use of the C#11 `init` keyword, internally within this library, when targeting frameworks older than .NET 5.
internal sealed class IsExternalInit
{
}
internal sealed class IsExternalInit;

Check warning on line 8 in src/DynamicData/Polyfills/IsExternalInit.cs

View workflow job for this annotation

GitHub Actions / build (Release)

Remove this empty class, write its code or make it an "interface". (https://rules.sonarsource.com/csharp/RSPEC-2094)

Check warning on line 8 in src/DynamicData/Polyfills/IsExternalInit.cs

View workflow job for this annotation

GitHub Actions / build (Release)

Remove this empty class, write its code or make it an "interface". (https://rules.sonarsource.com/csharp/RSPEC-2094)
#endif
7 changes: 3 additions & 4 deletions src/DynamicData/Polyfills/ListEnsureCapacity.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
// Copyright (c) 2011-2023 Roland Pheasant. All rights reserved.
// Roland Pheasant licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.

#if !NETCOREAPP
namespace System.Collections.Generic;

internal static class ListEnsureCapacity
{
public static void EnsureCapacity<T>(
this List<T> list,
int capacity)
public static void EnsureCapacity<T>(this List<T> list, int capacity)
{
if (list.Capacity < capacity)
list.Capacity = capacity;
}
}
#endif
10 changes: 4 additions & 6 deletions src/DynamicData/Polyfills/RequiredMemberAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
// Copyright (c) 2011-2023 Roland Pheasant. All rights reserved.
// Roland Pheasant licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.

#if !NET7_0_OR_GREATER
using System.ComponentModel;

namespace System.Runtime.CompilerServices;

// Allows use of the C#11 `required` keyword, internally within this library, when targeting frameworks older than .NET 7.
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Field | AttributeTargets.Property, Inherited = false)]
[EditorBrowsable(EditorBrowsableState.Never)]
internal sealed class RequiredMemberAttribute
: Attribute
{
}
internal sealed class RequiredMemberAttribute : Attribute;
#endif

0 comments on commit 897beb8

Please sign in to comment.