Skip to content

Commit 9b34544

Browse files
authored
Enable OpenTelemetry for Desktop target in xUnit tests (dotnet#18233)
1 parent b2f2065 commit 9b34544

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

tests/FSharp.Test.Utilities/CompilerAssert.fs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ module AssemblyResolver =
5959
match found() with
6060
| None -> Unchecked.defaultof<Assembly>
6161
| Some name -> Assembly.Load(name) )
62-
63-
do addResolver()
6462
#endif
6563

6664
type ExecutionOutcome =

tests/FSharp.Test.Utilities/FSharp.Test.Utilities.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
<None Include="ScriptingShims.fsx" />
3434
<Compile Include="TestConsole.fs" />
3535
<Compile Include="TestFramework.fs" />
36-
<Compile Include="XunitHelpers.fs" />
3736
<Compile Include="ILChecker.fs" />
3837
<Compile Include="Utilities.fs" />
3938
<Compile Include="CompilerAssert.fs" />
@@ -46,6 +45,7 @@
4645
<Compile Include="FileInlineDataAttribute.fs" />
4746
<Compile Include="ReflectionHelper.fs" />
4847
<Compile Include="SurfaceArea.fs" />
48+
<Compile Include="XunitHelpers.fs" />
4949
</ItemGroup>
5050

5151
<ItemGroup>

tests/FSharp.Test.Utilities/XunitHelpers.fs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ type FSharpXunitFramework(sink: IMessageSink) =
3131
// This gets executed once per test assembly.
3232
MessageSink.sinkWriter |> ignore
3333
TestConsole.install()
34+
#if !NETCOREAPP
35+
AssemblyResolver.addResolver ()
36+
#endif
3437

3538
interface IDisposable with
3639
member _.Dispose() =
@@ -148,24 +151,23 @@ type FSharpXunitFramework(sink: IMessageSink) =
148151
log "FSharpXunitFramework with XUNIT_EXTRAS installing TestConsole redirection"
149152
TestConsole.install()
150153

151-
// TODO: Currently does not work with Desktop .NET Framework. Upcoming OpenTelemetry 1.11.0 may change it.
152-
#if NETCOREAPP
154+
#if !NETCOREAPP
155+
AssemblyResolver.addResolver ()
156+
#endif
157+
153158
let traceProvider =
154159
Sdk.CreateTracerProviderBuilder()
155160
.AddSource(ActivityNames.FscSourceName)
156161
.SetResourceBuilder(
157162
ResourceBuilder.CreateDefault().AddService(serviceName="F#", serviceVersion = "1.0.0"))
158163
.AddOtlpExporter()
159164
.Build()
160-
#endif
161165

162166
interface IDisposable with
163167
member _.Dispose() =
164168
cleanUpTemporaryDirectoryOfThisTestRun ()
165-
#if NETCOREAPP
166169
traceProvider.ForceFlush() |> ignore
167170
traceProvider.Dispose()
168-
#endif
169171
base.Dispose()
170172

171173
override this.CreateDiscoverer (assemblyInfo) =

0 commit comments

Comments
 (0)