Skip to content

Commit

Permalink
Remove NET 5.0 and greater references.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ygg01 committed Dec 23, 2023
1 parent 007119e commit 0f1b0b3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 21 deletions.
8 changes: 1 addition & 7 deletions Linguini.Bundle/FluentBundle.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#nullable enable
using System;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
Expand Down Expand Up @@ -240,10 +239,6 @@ public void AddFunctions(IDictionary<string, ExternalFunction> functions, out Li
{
switch (behavior)
{
#if NET5_0_OR_GREATER
case InsertBehavior.None:
return _funcList.TryAdd(funcName, fluentFunction);
#else
case InsertBehavior.None:
if (!_funcList.ContainsKey(funcName))
{
Expand All @@ -252,7 +247,6 @@ public void AddFunctions(IDictionary<string, ExternalFunction> functions, out Li
}

return false;
#endif
case InsertBehavior.OverwriteExisting:
_funcList[funcName] = fluentFunction;
break;
Expand Down
4 changes: 1 addition & 3 deletions Linguini.Shared/Util/ZeroCopyUtil.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;

namespace Linguini.Shared.Util
{
Expand Down Expand Up @@ -87,7 +85,7 @@ public static bool IsOneOf(this char c, char c1, char c2, char c3, char c4)
return c == c1 || c == c2 || c == c3 || c == c4;
}

#if !NET5_0_OR_GREATER
#if NETSTANDARD2_1
// Polyfill for netstandard 2.1 until dotnet backports MemoryExtension
public static ReadOnlyMemory<char> TrimEndPolyFill(this ReadOnlyMemory<char> memory)
=> memory.Slice(0, FindLastWhitespace(memory.Span));
Expand Down
21 changes: 10 additions & 11 deletions Linguini.Syntax/Parser/LinguiniParser.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#nullable enable


using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
Expand All @@ -21,7 +20,7 @@ public class LinguiniParser
{
private readonly ZeroCopyReader _reader;
private readonly bool _enableExperimental;
private const string CR = "\n";
private const string Cr = "\n";

/// <summary>
/// Set input to <c>string</c>
Expand Down Expand Up @@ -609,11 +608,11 @@ private bool TryGetPattern(out Pattern? pattern, out ParseError? error)
ReadOnlyMemory<char> value;
if (textLiteral.MissingEol && textLiteral.Start == textLiteral.End)
{
value = CR.AsMemory();
value = Cr.AsMemory();
}
else if (textLiteral.MissingEol && textLiteral.Start != textLiteral.End)
{
var str = _reader.ReadSlice(start, end) + CR;
var str = _reader.ReadSlice(start, end) + Cr;
value = str.AsMemory();
}
else
Expand All @@ -623,10 +622,10 @@ private bool TryGetPattern(out Pattern? pattern, out ParseError? error)

if (lastNonBlank == i)
{
#if NET5_0_OR_GREATER
value = value.TrimEnd();
#else
#if NETSTANDARD2_1
value = value.TrimEndPolyFill();
#else
value = value.TrimEnd();
#endif
}

Expand Down Expand Up @@ -772,21 +771,21 @@ private List<Attribute> GetAttributes()

private bool TryGetAttribute([NotNullWhen(true)] out Attribute? attr)
{
if (!TryGetIdentifier(out var id, out var err))
if (!TryGetIdentifier(out var id, out _))
{
attr = default!;
return false;
}

_reader.SkipBlankInline();

if (!TryExpectChar('=', out err))
if (!TryExpectChar('=', out _))
{
attr = default!;
return false;
}

if (TryGetPattern(out var pattern, out err) && pattern != null)
if (TryGetPattern(out var pattern, out _) && pattern != null)
{
attr = new Attribute(id, pattern);
return true;
Expand Down

0 comments on commit 0f1b0b3

Please sign in to comment.