diff --git a/Directory.Packages.props b/Directory.Packages.props
index 8291d766..bbb927fc 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -1,25 +1,28 @@
true
+ true
-
-
-
+
+
-
+
+
+
+
-
\ No newline at end of file
+
diff --git a/src/generator/Generator.Deserialize.cs b/src/generator/Generator.Deserialize.cs
index f18b1168..94b38bdc 100644
--- a/src/generator/Generator.Deserialize.cs
+++ b/src/generator/Generator.Deserialize.cs
@@ -95,7 +95,7 @@ private static MethodDeclarationSyntax GenerateEnumDeserializeMethod(
throw new InvalidDeserializeValueException($"Unexpected value: {errorName}");
}
return index switch {
- {{string.Join("," + Environment.NewLine, members
+ {{string.Join("," + Utilities.NewLine, members
.Select((m, i) => $"{i} => {typeSyntax}.{m.Name}")) }},
_ => throw new InvalidDeserializeValueException($"Unexpected index: {index}")
};
diff --git a/src/generator/Generator.Impl.cs b/src/generator/Generator.Impl.cs
index a9484133..38d61bde 100644
--- a/src/generator/Generator.Impl.cs
+++ b/src/generator/Generator.Impl.cs
@@ -94,10 +94,10 @@ internal static void GenerateImpl(
usings: List(new[] { UsingDirective(IdentifierName("System")), UsingDirective(IdentifierName("Serde")) }),
attributeLists: default,
members: List(new[] { newType }));
- tree = tree.NormalizeWhitespace(eol: Environment.NewLine);
+ tree = tree.NormalizeWhitespace(eol: Utilities.NewLine);
context.AddSource(srcName,
- Environment.NewLine + "#nullable enable" + Environment.NewLine + tree.ToFullString());
+ Utilities.NewLine + "#nullable enable" + Utilities.NewLine + tree.ToFullString());
}
internal static (string FileName, string Body) MakePartialDecl(
@@ -126,7 +126,7 @@ internal static (string FileName, string Body) MakePartialDecl(
newType = typeDeclContext.WrapNewType(newType);
- return (srcName, Environment.NewLine + "#nullable enable" + Environment.NewLine + newType);
+ return (srcName, Utilities.NewLine + "#nullable enable" + Utilities.NewLine + newType);
}
///
diff --git a/src/generator/Generator.Serialize.cs b/src/generator/Generator.Serialize.cs
index b4cc391b..12fdc62d 100644
--- a/src/generator/Generator.Serialize.cs
+++ b/src/generator/Generator.Serialize.cs
@@ -45,7 +45,7 @@ internal static (MemberDeclarationSyntax[], BaseListSyntax) GenSerialize(
statements.Add(ParseStatement($$"""
var index = value switch
{
- {{string.Join("," + Environment.NewLine, fieldsAndProps
+ {{string.Join("," + Utilities.NewLine, fieldsAndProps
.Select((m, i) => $"{typeSyntax}.{m.Name} => {i}")) }},
var v => throw new InvalidOperationException($"Cannot serialize unnamed enum value '{v}' of enum '{{enumType.Name}}'"),
};
diff --git a/src/generator/HelpersAndUtilities/Utilities.cs b/src/generator/HelpersAndUtilities/Utilities.cs
index 36cfc3b2..ef05f14e 100644
--- a/src/generator/HelpersAndUtilities/Utilities.cs
+++ b/src/generator/HelpersAndUtilities/Utilities.cs
@@ -33,6 +33,10 @@ public static bool IsSorted(this ReadOnlySpan span, IComparer comparer)
internal static class Utilities
{
+#pragma warning disable RS1035
+ public static readonly string NewLine = Environment.NewLine;
+#pragma warning restore RS1035
+
public static T NotNull(this T? value) where T : struct => value!.Value;
public static string Concat(this string recv, string other)
diff --git a/src/generator/SerdeGenerator.csproj b/src/generator/SerdeGenerator.csproj
index 1e915034..39002d93 100644
--- a/src/generator/SerdeGenerator.csproj
+++ b/src/generator/SerdeGenerator.csproj
@@ -11,6 +11,7 @@
$(DefineConstants);SRCGEN
true
$(NoWarn);CS1591
+ true
diff --git a/src/generator/SerdeInfoGenerator.cs b/src/generator/SerdeInfoGenerator.cs
index f7f3f55d..bbdf7dda 100644
--- a/src/generator/SerdeInfoGenerator.cs
+++ b/src/generator/SerdeInfoGenerator.cs
@@ -57,7 +57,7 @@ public static void GenerateSerdeInfo(
typeString = typeString + "<" + new string(',', receiverType.TypeParameters.Length - 1) + ">";
}
- var membersString = string.Join("," + Environment.NewLine,
+ var membersString = string.Join("," + Utilities.NewLine,
SymbolUtilities.GetDataMembers(receiverType, SerdeUsage.Both).SelectNotNull(GetMemberEntry));
List makeArgs = [ $"\"{receiverType.Name}\"", $"typeof({typeString}).GetCustomAttributesData()" ];
@@ -83,7 +83,7 @@ public static void GenerateSerdeInfo(
}
""");
- var argsString = string.Join("," + Environment.NewLine + " ", makeArgs);
+ var argsString = string.Join("," + Utilities.NewLine + " ", makeArgs);
var body = $$"""
static global::Serde.ISerdeInfo global::Serde.ISerdeInfoProvider.SerdeInfo { get; } = Serde.SerdeInfo.Make{{makeFuncSuffix}}(
diff --git a/src/generator/TypeDeclContext.cs b/src/generator/TypeDeclContext.cs
index c1d59a1c..8c3dfe2c 100644
--- a/src/generator/TypeDeclContext.cs
+++ b/src/generator/TypeDeclContext.cs
@@ -64,7 +64,7 @@ public string WrapNewType(string newType)
}
if (NamespaceNames.Count > 0)
{
- newType = "namespace " + string.Join(".", NamespaceNames) + ";" + Environment.NewLine + newType;
+ newType = "namespace " + string.Join(".", NamespaceNames) + ";" + Utilities.NewLine + newType;
}
return newType;
diff --git a/src/generator/Wrappers.cs b/src/generator/Wrappers.cs
index 2283f368..6e4cbed3 100644
--- a/src/generator/Wrappers.cs
+++ b/src/generator/Wrappers.cs
@@ -53,9 +53,9 @@ readonly partial struct {{wrapperName}} { }
usings: default,
attributeLists: default,
members: List(new[] { newType }));
- tree = tree.NormalizeWhitespace(eol: Environment.NewLine);
+ tree = tree.NormalizeWhitespace(eol: Utilities.NewLine);
- context.AddSource(fullWrapperName, Environment.NewLine + tree.ToFullString());
+ context.AddSource(fullWrapperName, Utilities.NewLine + tree.ToFullString());
}
// If the target is a core type, we can wrap it
diff --git a/src/pack/Serde.Pkg.proj b/src/pack/Serde.Pkg.proj
index b7354a96..9bce2a9a 100644
--- a/src/pack/Serde.Pkg.proj
+++ b/src/pack/Serde.Pkg.proj
@@ -18,7 +18,7 @@
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all