Skip to content

Commit

Permalink
Removal of NET 452 & Net 46
Browse files Browse the repository at this point in the history
  • Loading branch information
thompson-tomo committed Apr 2, 2024
1 parent 6465f65 commit 3961cf7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
22 changes: 11 additions & 11 deletions source/Handlebars/Collections/ImmutableStack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@

namespace HandlebarsDotNet.Collections
{
#if NET451 || NET452
#if NET451
[Serializable]
#endif
internal readonly struct ImmutableStack<T>
{
private readonly Node _container;

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private ImmutableStack(T value, Node parent)
:this(Node.Create(value, parent))
{
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private ImmutableStack(Node container) => _container = container;

Expand All @@ -26,8 +26,8 @@ private ImmutableStack(T value, Node parent)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public T Peek()
{
return _container == null
? default
return _container == null
? default
: _container.Value;
}

Expand All @@ -39,20 +39,20 @@ public ImmutableStack<T> Pop(out T value)
value = default;
return this;
}

value = _container.Value;
var parent = _container.Parent;
_container.Dispose();
return new ImmutableStack<T>(parent);
}
#if NET451 || NET452

#if NET451
[Serializable]
#endif
private sealed class Node : IDisposable
{
private static readonly InternalObjectPool<Node, Policy> Pool = new InternalObjectPool<Node, Policy>(new Policy());

public Node Parent;
public T Value;

Expand All @@ -63,9 +63,9 @@ public static Node Create(T value = default, Node parent = null)
item.Parent = parent;
return item;
}

private Node() { }

private struct Policy : IInternalObjectPoolPolicy<Node>
{
public Node Create() => new Node();

Check warning on line 71 in source/Handlebars/Collections/ImmutableStack.cs

View workflow job for this annotation

GitHub Actions / SonarCloud

Rename this method to not shadow the outer class' member with the same name.
Expand Down
6 changes: 3 additions & 3 deletions source/Handlebars/Handlebars.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<AssemblyName>Handlebars</AssemblyName>
<ProjectGuid>9822C7B8-7E51-42BC-9A49-72A10491B202</ProjectGuid>
<TargetFrameworks>netstandard1.3;netstandard2.0;netstandard2.1;net6</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net451;net452;net46</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net451</TargetFrameworks>
<Version>2.0.0</Version>
<RootNamespace>HandlebarsDotNet</RootNamespace>
<SignAssembly Condition="'$(ShouldSignAssembly)' == 'true'">true</SignAssembly>
Expand Down Expand Up @@ -35,7 +35,7 @@
<None Include="..\..\README.md" Pack="true" PackagePath="\" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'=='net451' or '$(TargetFramework)'=='net452' or '$(TargetFramework)'=='net46'">
<ItemGroup Condition="'$(TargetFramework)'=='net451'">
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

Expand All @@ -46,7 +46,7 @@
<PackageReference Include="System.Diagnostics.Contracts" Version="4.3.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'=='net451' or '$(TargetFramework)'=='net452' or '$(TargetFramework)'=='net46'">
<ItemGroup Condition="'$(TargetFramework)'=='net451'">
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>

Expand Down
8 changes: 4 additions & 4 deletions source/Handlebars/Polyfills/AsyncLocal.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NET451 || NET452
#if NET451
using System;
using System.Runtime.CompilerServices;
using System.Runtime.Remoting.Messaging;
Expand All @@ -8,12 +8,12 @@ namespace HandlebarsDotNet.Polyfills
public sealed class AsyncLocal<T>
{
private const string Slot = "__AsyncLocalSlot";

public T Value
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => CallContext.LogicalGetData(Slot) is Container container
? container.Value
get => CallContext.LogicalGetData(Slot) is Container container
? container.Value
: default;

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand Down

0 comments on commit 3961cf7

Please sign in to comment.