Skip to content

Commit 98667ed

Browse files
authored
Replace resx with a statically generated cs file (DataDog#3025)
* Replace resx with a statically generated cs file * upgrade regex to remove need for System.Buffers * Really remove need for System.Buffers * don't modify the throughput tests and fix build constants * import vendored improvements * Re-apply Anna's fix * remove annoying json file and add .gitignore to avoid these errors in the future * actually add the .gitignore mentioned earlier * don't null out array before it's used
1 parent 1711980 commit 98667ed

21 files changed

+167
-991
lines changed

tracer/build/_build/UpdateVendors/VendoredDependency.cs

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ static VendoredDependency()
7575

7676
Add(
7777
libraryName: "IndieSystem.Text.RegularExpressions",
78-
version: "0.1",
79-
downloadUrl: "https://github.com/robertpi/IndieRegex/archive/refs/tags/v0.3.zip",
80-
pathToSrc: new[] { "IndieRegex-0.3", "src" },
78+
version: "0.6",
79+
downloadUrl: "https://github.com/robertpi/IndieRegex/archive/refs/tags/v0.6.zip",
80+
pathToSrc: new[] { "IndieRegex-0.6", "src" },
8181
// Perform standard CS file transform with additional '#nullable enable' directive at the beginning of the files, since the vendored project was built with <Nullable>enable</Nullable>
8282
transform: filePath => RewriteCsFileWithStandardTransform(filePath, originalNamespace: "IndieSystem.Text.RegularExpressions",
83-
AddIfNetcoreapp31OrGreater, AddNullableDirectiveTransform, AddIgnoreNullabilityWarningDisablePragma, FixupResources),
84-
relativePathsToExclude: new[] { "additional/HashCode.cs" });
83+
AddIfNetcoreapp31OrGreater, AddNullableDirectiveTransform, AddIgnoreNullabilityWarningDisablePragma),
84+
relativePathsToExclude: new[] { "additional/HashCode.cs", "SR.resx" });
8585
}
8686

8787
public static List<VendoredDependency> All { get; set; } = new List<VendoredDependency>();
@@ -265,17 +265,6 @@ static string AddIgnoreNullabilityWarningDisablePragma(string filePath, string c
265265
"CS8774" + // Member 'x' must have a non-null value when exiting.
266266
Environment.NewLine + content;
267267

268-
static string FixupResources(string filePath, string content)
269-
{
270-
if (content.Contains("new global::System.Resources.ResourceManager(\"IndieSystem.Text.RegularExpressions.SR\""))
271-
{
272-
return content.Replace("new global::System.Resources.ResourceManager(\"IndieSystem.Text.RegularExpressions.SR\"",
273-
"new global::System.Resources.ResourceManager(\"Datadog.Trace.Vendors.IndieSystem.Text.RegularExpressions.SR\"");
274-
}
275-
276-
return content;
277-
}
278-
279268
private static void RewriteFileWithTransform(string filePath, Func<string, string> transform)
280269
{
281270
var fileContent = File.ReadAllText(filePath);

tracer/build/crank/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.json

tracer/dependabot/Datadog.Dependabot.Vendors.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
<!-- https://www.nuget.org/packages/Datadog.Sketches/1.0.0 -->
2828
<PackageReference Include="Datadog.Sketches" Version="1.0.0" />
2929

30-
<!-- https://www.nuget.org/packages/IndieSystem.Text.RegularExpressions/0.1 -->
31-
<PackageReference Include="IndieSystem.Text.RegularExpressions" Version="0.1" />
30+
<!-- https://www.nuget.org/packages/IndieSystem.Text.RegularExpressions/0.6 -->
31+
<PackageReference Include="IndieSystem.Text.RegularExpressions" Version="0.6" />
3232

3333
</ItemGroup>
3434

tracer/src/Datadog.Trace/Datadog.Trace.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@
9191
<DefineConstants>$(DefineConstants);ASYNCLOCAL;HASHTABLE;FEATURE_DEFAULT_INTERFACE;FEATURE_SPAN</DefineConstants>
9292
</PropertyGroup>
9393

94-
<PropertyGroup>
95-
<DefineConstants>$(DefineConstants);REGEXGENERATOR</DefineConstants>
94+
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
95+
<DefineConstants>$(DefineConstants);NO_ARRAY_POOL</DefineConstants>
9696
</PropertyGroup>
9797

9898
<!-- Remove System.Collections.NonGeneric. This was defined in Serilog but it is unnecessary -->

tracer/src/Datadog.Trace/Vendors/IndieSystem.Text.RegularExpressions/IndieSystem.Text.RegularExpressions.csproj.txt

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,15 @@
66
<Nullable>enable</Nullable>
77
<EnablePreviewFeatures>true</EnablePreviewFeatures>
88
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
9+
10+
<!-- nuget stuff -->
11+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
12+
<PackageTags>regex;regular-expression;non-backtracking</PackageTags>
13+
<Authors>Robert Pickering</Authors>
14+
<Copyright>Robert Pickering, .NET Foundation and Contributors</Copyright>
15+
<Description>IndieRegex or IndieSystem.Text.RegularExpressions is a drop-in replacement for .NET's Regex class. It is built using the source of Regex from .NET 7.0, modified and patched to run on .NET Framework 4.6.1, .NET Standard 2.0, .NET Core 3.1, .NET 5.0 and .NET 6.0.</Description>
916
</PropertyGroup>
17+
1018
<ItemGroup>
1119
<Compile Include="additional\BitOperations.cs" />
1220
<Compile Include="System\Collections\HashtableExtensions.cs" />
@@ -35,7 +43,6 @@
3543
<Compile Include="System\Text\RegularExpressions\RegexCharClass.cs" />
3644
<Compile Include="System\Text\RegularExpressions\RegexCompilationInfo.cs" />
3745
<Compile Include="System\Text\RegularExpressions\RegexFindOptimizations.cs" />
38-
<Compile Include="System\Text\RegularExpressions\RegexGeneratorAttribute.cs" />
3946
<Compile Include="System\Text\RegularExpressions\RegexInterpreter.cs" />
4047
<Compile Include="System\Text\RegularExpressions\RegexInterpreterCode.cs" />
4148
<Compile Include="System\Text\RegularExpressions\RegexMatchTimeoutException.cs" />
@@ -99,9 +106,8 @@
99106
<Compile Include="common\ValueListBuilder.Pop.cs" />
100107

101108
<!-- our additional files -->
102-
<Compile Include="AssemblyInfo.cs" />
103109
<Compile Include="SR.cs" />
104-
<Compile Include="SR.Designer.cs" />
110+
<Compile Include="SR.g.cs" />
105111
<Compile Include="additional\HashCode.cs" />
106112
<Compile Include="additional\RequiresDynamicCodeAttribute.cs" />
107113
<Compile Include="additional\StringSyntaxAttribute.cs" />
@@ -119,18 +125,13 @@
119125
<PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.7.0" />
120126
</ItemGroup>
121127

122-
<ItemGroup>
123-
<Compile Update="SR.Designer.cs">
124-
<DesignTime>True</DesignTime>
125-
<AutoGen>True</AutoGen>
126-
<DependentUpon>SR.resx</DependentUpon>
127-
</Compile>
128-
</ItemGroup>
129128

130129
<ItemGroup>
131-
<EmbeddedResource Update="SR.resx">
132-
<Generator>ResXFileCodeGenerator</Generator>
133-
<LastGenOutput>SR.Designer.cs</LastGenOutput>
134-
</EmbeddedResource>
130+
<EmbeddedResource Remove="SR.resx" />
135131
</ItemGroup>
136-
</Project>
132+
133+
<PropertyGroup>
134+
<DefineConstants>$(DefineConstants);NO_ARRAY_POOL</DefineConstants>
135+
</PropertyGroup>
136+
137+
</Project>

0 commit comments

Comments
 (0)