Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
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
1 change: 1 addition & 0 deletions .props/_GlobalStaticVersion.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<SemanticVersionMinor>18</SemanticVersionMinor> <!-- If changing the Minor version, also update the Date value. -->
<SemanticVersionPatch>0</SemanticVersionPatch>
<PreReleaseMilestone></PreReleaseMilestone> <!--Valid values: beta1, beta2, EMPTY for stable -->
<PreReleaseMilestone Condition="'$(Redfield)' == 'True'">redfield</PreReleaseMilestone>
<PreReleaseMilestone Condition="'$(NightlyBuild)' == 'True'">nightly</PreReleaseMilestone> <!-- Overwrite this property for nightly builds from the DEVELOP branch. -->
<!--
Date when Semantic Version was changed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Microsoft.ApplicationInsights.TestFramework;
using System.Diagnostics.Tracing;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Linq;

[TestClass]
public class CoreEventSourceTest
Expand All @@ -25,5 +26,30 @@ private static EventAttribute GetEventAttribute(string methodName)
MethodInfo method = typeof(CoreEventSource).GetMethod(methodName);
return method.GetCustomAttribute<EventAttribute>();
}

#if REDFIELD
/// <summary>
/// This is a sanitiy check.
/// The 'Redfield' compilation flag should switch the name of EventSource class.
/// Devs can review the test log and confirm that this test runs and passes.
/// This will serve as a verification that the Redfield compilation flag worked as expected.
///
/// To run this test:
/// dotnet build /p:Redfield=True ".\dotnet\BASE\Microsoft.ApplicationInsights.sln"
/// dotnet test ".\bin\Debug\test\Microsoft.ApplicationInsights.Tests\net5.0\Microsoft.ApplicationInsights.Tests.dll" --filter Name~VerifyRedfieldEventSourceName
/// </summary>
[TestMethod]
public void VerifyRedfieldEventSourceName()
{
var expectedName = "Redfield-Microsoft-ApplicationInsights-Core";

var eventSourceAttribute = typeof(CoreEventSource)
.GetCustomAttributes(typeof(EventSourceAttribute))
.Single() as EventSourceAttribute;

Assert.IsNotNull(eventSourceAttribute);
Assert.AreEqual(expectedName, eventSourceAttribute.Name);
}
#endif
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Tracing;

#if REDFIELD
[EventSource(Name = "Redfield-Microsoft-ApplicationInsights-Core")]
#else
[EventSource(Name = "Microsoft-ApplicationInsights-Core")]
#endif
[SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", Justification = "appDomainName is required")]
internal sealed class CoreEventSource : EventSource
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,21 @@
<PackageReference Include="Microsoft.Diagnostics.Tracing.EventRegister" Version="1.1.28" Condition="$(OS) == 'Windows_NT'">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="5.0.0" />
</ItemGroup>

<Choose>
<When Condition="'$(Redfield)' == 'True'">
<ItemGroup>
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.7.0" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="5.0.0" />
</ItemGroup>
</Otherwise>
</Choose>

<ItemGroup Condition="'$(TargetFramework)' != 'netstandard2.0'">
<Reference Include="System.Net.Http" />
</ItemGroup>
Expand Down
12 changes: 12 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,20 @@

<!-- This is used to disable some build properties. -->
<IsExamplesSolution Condition="'$(SolutionName)' == 'Examples' ">true</IsExamplesSolution>

<!-- This is used to change EventSource names. -->
<DefineConstants Condition="'$(Redfield)' == 'True'">$(DefineConstants);REDFIELD</DefineConstants>
</PropertyGroup>

<Target Name="Info_Redfield" BeforeTargets="Build" Condition="'$(Redfield)' == 'True'">
<!--
This flag is reserved for Codeless Attach products.
Redfield has some unique code changes to avoid conflicting with the real AI SDK.
To use: dotnet build /p:Redfield=True
-->
<Message Text="Directory.Build.props: Redfield build detected." Importance="high"/>
</Target>

<Target Name="Info_InternalSettings" BeforeTargets="Build">
<Message Text="Directory.Build.props: Internal_Logging is set to $(Internal_Logging)." Importance="high"/>
</Target>
Expand Down