Skip to content

Commit

Permalink
Replaced System.Text.Json with Newtonsoft
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-romano-DD committed Nov 15, 2024
1 parent 80ecfb1 commit fa44bc2
Show file tree
Hide file tree
Showing 7 changed files with 377 additions and 403 deletions.
3 changes: 2 additions & 1 deletion tracer/build/_build/CodeGenerators/CallTargetsGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text;
using System.Text.Json;
using Mono.Cecil;
using Newtonsoft.Json;
using Nuke.Common.IO;

namespace CodeGenerators
Expand Down Expand Up @@ -566,7 +567,7 @@ internal static void GenerateJsonFile(Dictionary<CallTargetDefinitionSource, Tar
var options = new JsonSerializerOptions();
options.IncludeFields = true;
options.WriteIndented = true;
string jsonString = System.Text.Json.JsonSerializer.Serialize(orderedDefinitions, options);
string jsonString = JsonConvert.SerializeObject(orderedDefinitions, Formatting.Indented);

if (!Directory.Exists(outputPath)) { Directory.CreateDirectory(outputPath); }
var fileName = outputPath / FileNames.DefinitionsJson;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace PrepareRelease
{
public static class GenerateIntegrationDefinitions
{
public static List<InstrumentedAssembly> GetAllIntegrations(ICollection<string> assemblyPaths, AbsolutePath dependabotJsonFile)
public static List<InstrumentedAssembly> GetAllIntegrations(ICollection<string> assemblyPaths, AbsolutePath definitionsJsonFile)
{
var callTargetIntegrations = Enumerable.Empty<InstrumentedAssembly>();

Expand All @@ -27,17 +27,17 @@ public static List<InstrumentedAssembly> GetAllIntegrations(ICollection<string>
var assemblyLoadContext = new CustomAssemblyLoadContext(Path.GetDirectoryName(path));
var assembly = assemblyLoadContext.LoadFromAssemblyPath(path);

callTargetIntegrations = callTargetIntegrations.Concat(GetCallTargetIntegrations(assembly, dependabotJsonFile));
callTargetIntegrations = callTargetIntegrations.Concat(GetCallTargetIntegrations(assembly, definitionsJsonFile));

assemblyLoadContext.Unload();
}

return callTargetIntegrations.ToList();
}

static IEnumerable<InstrumentedAssembly> GetCallTargetIntegrations(Assembly assembly, AbsolutePath dependabotJsonFile)
static IEnumerable<InstrumentedAssembly> GetCallTargetIntegrations(Assembly assembly, AbsolutePath definitionsJsonFile)
{
var definitions = JsonConvert.DeserializeObject<CallTargetDefinitionSource[]>(File.ReadAllText(dependabotJsonFile));
var definitions = JsonConvert.DeserializeObject<CallTargetDefinitionSource[]>(File.ReadAllText(definitionsJsonFile));
return definitions
.Select(x => new InstrumentedAssembly
{
Expand Down
742 changes: 371 additions & 371 deletions tracer/build/supported_calltargets.g.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion tracer/src/Datadog.Tracer.Native/Datadog.Tracer.Native.def
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ EXPORTS
InitializeTraceMethods
InstrumentProbes
GetProbesStatuses
DisableTracerCLRProfiler
RegisterIastAspects
RegisterCallTargetDefinitions3
EnableCallTargetDefinitions
Expand Down
10 changes: 0 additions & 10 deletions tracer/src/Datadog.Tracer.Native/cor_profiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1381,16 +1381,6 @@ HRESULT STDMETHODCALLTYPE CorProfiler::Shutdown()
return S_OK;
}

void CorProfiler::DisableTracerCLRProfiler()
{
// A full profiler detach request cannot be made because:
// 1. We use the COR_PRF_DISABLE_TRANSPARENCY_CHECKS_UNDER_FULL_TRUST event mask (CORPROF_E_IMMUTABLE_FLAGS_SET)
// 2. We instrument code with SetILFunctionBody for the Loader injection. (CORPROF_E_IRREVERSIBLE_INSTRUMENTATION_PRESENT)
// https://docs.microsoft.com/en-us/dotnet/framework/unmanaged-api/profiling/icorprofilerinfo3-requestprofilerdetach-method
Logger::Info("Disabling Tracer CLR Profiler...");
Shutdown();
}

void CorProfiler::UpdateSettings(WCHAR* keys[], WCHAR* values[], int length)
{
const WSTRING debugVarName = WStr("DD_TRACE_DEBUG");
Expand Down
5 changes: 0 additions & 5 deletions tracer/src/Datadog.Tracer.Native/cor_profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,6 @@ class CorProfiler : public CorProfilerBase
void ReportSuccessfulInstrumentation(ModuleID moduleId, int methodToken, const WCHAR* instrumentationId, int products);
bool ShouldHeal(ModuleID moduleId, int methodToken, const WCHAR* instrumentationId, int products);

//
// Disable profiler
//
void DisableTracerCLRProfiler();

//
// Propagate settings from RCM
//
Expand Down
11 changes: 0 additions & 11 deletions tracer/src/Datadog.Tracer.Native/interop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,17 +156,6 @@ EXTERN_C int STDAPICALLTYPE GetProbesStatuses(WCHAR** probeIds, int probeIdsLeng
return trace::profiler->GetProbesStatuses(probeIds, probeIdsLength, probeStatuses);
}

EXTERN_C VOID STDAPICALLTYPE DisableTracerCLRProfiler()
{
if (trace::profiler == nullptr)
{
trace::Logger::Error("Error in DisableTracerCLRProfiler call. Tracer CLR Profiler was not initialized.");
return;
}

trace::profiler->DisableTracerCLRProfiler();
}

EXTERN_C int STDAPICALLTYPE RegisterIastAspects(WCHAR** aspects, int aspectsLength)
{
if (trace::profiler == nullptr)
Expand Down

0 comments on commit fa44bc2

Please sign in to comment.