Skip to content

Commit 6ac6ef2

Browse files
authored
Merge pull request #488 from sebastienros/sebros/srcwarnings
Fix warnings in src package
2 parents 074ffa9 + eddbc4f commit 6ac6ef2

File tree

6 files changed

+26
-27
lines changed

6 files changed

+26
-27
lines changed

BuildScripts/MakeInternal.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ ForEach ($file in $inputFiles)
1313
{
1414
$content = Get-Content -path $file
1515
$content = $content -creplace "public(?=\s+(((abstract|sealed|static|record)\s+)?(partial\s+)?class|delegate|enum|interface|struct|record))", "internal"
16+
$content = $content -replace "^\s*#pragma warning.*$", "" # remove any #pragma directive that could be reactivating our global disable
17+
$content = ,"#pragma warning disable" + $content # $content is a list of lines, insert at the top
1618
$outputPath = Join-Path $outputFolder (Split-Path $file -Leaf)
1719
Out-File $outputPath UTF8 -InputObject $content
1820
}

src/FastExpressionCompiler.LightExpression/ExpressionVisitor.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -550,5 +550,3 @@ protected internal virtual Expression VisitRuntimeVariables(RuntimeVariablesExpr
550550

551551
protected internal virtual Expression VisitDebugInfo(DebugInfoExpression node) => node;
552552
}
553-
554-
#nullable restore

src/FastExpressionCompiler/FastExpressionCompiler.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11436,4 +11436,3 @@ namespace System.Diagnostics.CodeAnalysis
1143611436
public sealed class UnscopedRefAttribute : Attribute { }
1143711437
}
1143811438
#endif
11439-
#nullable restore

src/FastExpressionCompiler/ILReader.cs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#nullable disable
2+
13
#if DEBUG
24
// #define DEBUG_INTERNALS
35
#endif
@@ -7,6 +9,7 @@
79
using System.Collections;
810
using System.Collections.Generic;
911
using System.Diagnostics;
12+
using System.Globalization;
1013
using System.Reflection;
1114
using System.Reflection.Emit;
1215
using System.Text;
@@ -613,21 +616,21 @@ public DynamicMethodILProvider(DynamicMethod method)
613616

614617
public static class ILFormatter
615618
{
616-
public static StringBuilder Int32ToHex(StringBuilder sb, int int32) => sb.Append(int32.ToString("X8"));
617-
public static StringBuilder Int16ToHex(StringBuilder sb, int int16) => sb.Append(int16.ToString("X4"));
618-
public static StringBuilder Int8ToHex(StringBuilder sb, int int8) => sb.Append(int8.ToString("X2"));
619-
public static StringBuilder Argument(StringBuilder sb, int ordinal) => sb.Append($"V_{ordinal}");
620-
public static StringBuilder Label(StringBuilder sb, int offset) => sb.Append($"IL_{offset:D4}");
619+
public static StringBuilder Int32ToHex(StringBuilder sb, int int32) => sb.Append(int32.ToString("X8", CultureInfo.InvariantCulture));
620+
public static StringBuilder Int16ToHex(StringBuilder sb, int int16) => sb.Append(int16.ToString("X4", CultureInfo.InvariantCulture));
621+
public static StringBuilder Int8ToHex(StringBuilder sb, int int8) => sb.Append(int8.ToString("X2", CultureInfo.InvariantCulture));
622+
public static StringBuilder Argument(StringBuilder sb, int ordinal) => sb.AppendFormat(CultureInfo.InvariantCulture, "V_{0}", ordinal);
623+
public static StringBuilder Label(StringBuilder sb, int offset) => sb.AppendFormat(CultureInfo.InvariantCulture, "IL_{0:D4}", offset);
621624

622625
public static StringBuilder MultipleLabels(StringBuilder sb, int[] offsets)
623626
{
624627
var length = offsets.Length;
625628
for (var i = 0; i < length; i++)
626629
{
627-
sb.AppendFormat(i == 0 ? "(" : ", ");
630+
sb.Append(i == 0 ? "(" : ", ");
628631
sb.Append(Label(sb, offsets[i]));
629632
}
630-
sb.AppendFormat(")");
633+
sb.Append(')');
631634
return sb;
632635
}
633636

@@ -648,9 +651,9 @@ public static StringBuilder EscapedString(StringBuilder sb, string str)
648651
else if (ch == '\"')
649652
sb.Append("\\\"");
650653
else if (ch == '\\')
651-
sb.Append("\\");
654+
sb.Append('\\');
652655
else if (ch < 0x20 || ch >= 0x7f)
653-
sb.AppendFormat("\\u{0:x4}", (int)ch);
656+
sb.AppendFormat(CultureInfo.InvariantCulture, "\\u{0:x4}", (int)ch);
654657
else
655658
sb.Append(ch);
656659
}
@@ -663,10 +666,10 @@ public static StringBuilder SigByteArrayToString(StringBuilder sb, byte[] sig)
663666
var length = sig.Length;
664667
for (var i = 0; i < length; i++)
665668
{
666-
sb.AppendFormat(i == 0 ? "SIG [" : " ");
669+
sb.Append(i == 0 ? "SIG [" : " ");
667670
sb.Append(Int8ToHex(sb, sig[i]));
668671
}
669-
sb.AppendFormat("]");
672+
sb.Append(']');
670673
return sb;
671674
}
672675
}
@@ -820,5 +823,3 @@ public MemberInfo AsMember(int token)
820823

821824
public byte[] AsSignature(int token) => this[token] as byte[];
822825
}
823-
824-
#pragma warning restore CS1591

src/FastExpressionCompiler/ImTools.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,5 +1583,3 @@ public struct SmallSet16<K, TEq>() where TEq : struct, IEq<K>
15831583
/// <summary>Set with 16 keys on stack and entries baked by the single array</summary>
15841584
public SmallMap<K, SmallMap.Entry<K>, TEq, Size16, Stack16<int>, Stack16<SmallMap.Entry<K>>, SmallMap.SingleArrayEntries<K, SmallMap.Entry<K>, TEq>> Set;
15851585
}
1586-
1587-
#nullable restore

src/FastExpressionCompiler/TestTools.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System;
1+
#nullable disable
2+
3+
using System;
24
using System.Linq;
35
using System.Text;
46
using System.Reflection;
@@ -19,6 +21,7 @@ namespace FastExpressionCompiler;
1921

2022
using FastExpressionCompiler.ILDecoder;
2123
using FastExpressionCompiler.ImTools;
24+
using System.Globalization;
2225
using System.Linq.Expressions;
2326
#endif
2427

@@ -27,10 +30,10 @@ namespace FastExpressionCompiler;
2730
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "This is used for the testing purposes only.")]
2831
public static class TestTools
2932
{
30-
public static bool AllowPrintIL = false;
31-
public static bool AllowPrintCS = false;
32-
public static bool AllowPrintExpression = false;
33-
public static bool DisableAssertOpCodes = false;
33+
public static bool AllowPrintIL;
34+
public static bool AllowPrintCS;
35+
public static bool AllowPrintExpression;
36+
public static bool DisableAssertOpCodes;
3437

3538
static TestTools()
3639
{
@@ -628,9 +631,9 @@ class CallerMemberNameAttribute : Attribute { }
628631
class CallerLineNumberAttribute : Attribute { }
629632

630633
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
631-
class CallerArgumentExpression : Attribute
634+
class CallerArgumentExpressionAttribute : Attribute
632635
{
633-
public CallerArgumentExpression(string parameterName) { }
636+
public CallerArgumentExpressionAttribute(string parameterName) { }
634637
}
635638
#endif
636639

@@ -1060,5 +1063,3 @@ public void Run<T>(T test, TestFlags flags = TestFlags.Default) where T : ITestX
10601063
}
10611064
}
10621065
}
1063-
1064-
#pragma warning restore CS1591

0 commit comments

Comments
 (0)