Skip to content

Commit

Permalink
Merge branch 'master' into combine-dictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
Ygg01 authored Dec 24, 2023
2 parents 506a05c + 0f1b0b3 commit c87bb09
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 40 deletions.
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 @@ -258,10 +257,6 @@ private bool TryInsert(string funcName, ExternalFunction fluentFunction,
{
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 @@ -270,7 +265,6 @@ private bool TryInsert(string funcName, ExternalFunction fluentFunction,
}

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 c87bb09

Please sign in to comment.