Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,16 @@
</ItemGroup>
<ItemGroup>
<Compile Include="..\Datadog.Trace\ClrProfiler\InstrumentationCategory.cs" Link="InstrumentationDefinitions\InstrumentationCategory.cs" />
<Compile Include="..\Datadog.Trace\Iast\Dataflow\AspectType.cs" Link="AspectsDefinitions\AspectType.cs" />
<Compile Include="..\Datadog.Trace\Iast\Dataflow\AspectAttribute.cs" Link="AspectsDefinitions\AspectAttribute.cs" />
<Compile Include="..\Datadog.Trace\Iast\Dataflow\AspectClassAttribute.cs" Link="AspectsDefinitions\AspectClassAttribute.cs" />
<Compile Include="..\Datadog.Trace\Iast\Dataflow\AspectCtorReplaceAttribute.cs" Link="AspectsDefinitions\AspectCtorReplaceAttribute.cs" />
<Compile Include="..\Datadog.Trace\Iast\Dataflow\AspectFilter.cs" Link="AspectsDefinitions\AspectFilter.cs" />
<Compile Include="..\Datadog.Trace\Iast\Dataflow\AspectMethodInsertAfterAttribute.cs" Link="AspectsDefinitions\AspectMethodInsertAfterAttribute.cs" />
<Compile Include="..\Datadog.Trace\Iast\Dataflow\AspectMethodInsertBeforeAttribute.cs" Link="AspectsDefinitions\AspectMethodInsertBeforeAttribute.cs" />
<Compile Include="..\Datadog.Trace\Iast\Dataflow\AspectMethodReplaceAttribute.cs" Link="AspectsDefinitions\AspectMethodReplaceAttribute.cs" />
<Compile Include="..\Datadog.Trace\Iast\Helpers\StringExtensions.cs" Link="AspectsDefinitions\StringExtensions.cs" />
<Compile Include="..\Datadog.Trace\Iast\VulnerabilityType.cs" Link="AspectsDefinitions\VulnerabilityType.cs" />
<Compile Include="..\Datadog.Trace\Iast\VulnerabilityTypeName.cs" Link="AspectsDefinitions\VulnerabilityTypeName.cs" />
<Compile Include="..\Datadog.Trace\Iast\Dataflow\AspectType.cs" Link="AspectsDefinitions\Sources\AspectType.cs" />
<EmbeddedResource Include="..\Datadog.Trace\Iast\Dataflow\AspectAttribute.cs" Link="AspectsDefinitions\Sources\AspectAttribute.cs" />
<EmbeddedResource Include="..\Datadog.Trace\Iast\Dataflow\AspectClassAttribute.cs" Link="AspectsDefinitions\Sources\AspectClassAttribute.cs" />
<EmbeddedResource Include="..\Datadog.Trace\Iast\Dataflow\AspectCtorReplaceAttribute.cs" Link="AspectsDefinitions\Sources\AspectCtorReplaceAttribute.cs" />
<Compile Include="..\Datadog.Trace\Iast\Dataflow\AspectFilter.cs" Link="AspectsDefinitions\Sources\AspectFilter.cs" />
<EmbeddedResource Include="..\Datadog.Trace\Iast\Dataflow\AspectMethodInsertAfterAttribute.cs" Link="AspectsDefinitions\Sources\AspectMethodInsertAfterAttribute.cs" />
<EmbeddedResource Include="..\Datadog.Trace\Iast\Dataflow\AspectMethodInsertBeforeAttribute.cs" Link="AspectsDefinitions\Sources\AspectMethodInsertBeforeAttribute.cs" />
<EmbeddedResource Include="..\Datadog.Trace\Iast\Dataflow\AspectMethodReplaceAttribute.cs" Link="AspectsDefinitions\Sources\AspectMethodReplaceAttribute.cs" />
<Compile Include="..\Datadog.Trace\Iast\VulnerabilityType.cs" Link="AspectsDefinitions\Sources\VulnerabilityType.cs" />
<Compile Include="..\Datadog.Trace\Iast\VulnerabilityTypeName.cs" Link="AspectsDefinitions\Sources\VulnerabilityTypeName.cs" />
<Compile Include="..\Datadog.Trace\Vendors\MessagePack\Attributes.cs">
<Link>MessagePack\Attributes.cs</Link>
</Compile>
Expand Down Expand Up @@ -285,4 +284,7 @@
<Link>MessagePack\_last_downloaded_source_url.txt</Link>
</Content>
</ItemGroup>
<ItemGroup>
<Folder Include="AspectsDefinitions\Sources\" />
</ItemGroup>
Comment on lines +287 to +289
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't needed I think

Suggested change
<ItemGroup>
<Folder Include="AspectsDefinitions\Sources\" />
</ItemGroup>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is If I want to add the sources to compilation on the fly. Something left for next improvement

</Project>
30 changes: 30 additions & 0 deletions tracer/src/Datadog.Trace.SourceGenerators/EmbeddedSources.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// <copyright file="EmbeddedSources.cs" company="Datadog">
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License.
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc.
// </copyright>

using System;
using System.IO;
using System.Reflection;
using System.Text;

namespace Datadog.Trace.SourceGenerators;

internal static partial class EmbeddedSources
{
private static readonly Assembly ThisAssembly = typeof(EmbeddedSources).Assembly;

internal static string LoadEmbeddedResource(string resourceName)
{
var resourceStream = ThisAssembly.GetManifestResourceStream(resourceName);
if (resourceStream is null)
{
var existingResources = ThisAssembly.GetManifestResourceNames();
throw new ArgumentException($"Could not find embedded resource {resourceName}. Available names: {string.Join(", ", existingResources)}");
}

using var reader = new StreamReader(resourceStream, Encoding.UTF8);

return reader.ReadToEnd();
}
}
Loading