Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove net5 or greater #45

Merged
merged 2 commits into from
Dec 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions .github/workflows/qodana_code_quality.yml

This file was deleted.

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
Loading