Closed blumu closed 4 years ago
Thanks. This was fixed in https://github.com/dotnet/corefx/pull/29234.
@stephentoub Any idea when the nuget with will be released? The latest package at nuget.org is 4.3.0 and dates back from 2016 (https://www.nuget.org/packages/System.Diagnostics.TextWriterTraceListener/4.3.0). Shall I be using a different nuget instead?
@blumu are you using .NET Core? It should be in version 2.2
@danmosemsft This is for github project FSharpLu (https://github.com/Microsoft/fsharplu/blob/master/FSharpLu/FSharpLu.fsproj). It's a library project so it's not targetting any particular version of netcore. It currently targets frameworks netstandard2.0
in addition to net452
, net461
. net462
and net472
.
The package System.Diagnostics.TextWriterTraceListener
is referenced as follows in the project file:
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
...
<PackageReference Include="System.Diagnostics.Tracing" Version="4.3.0" />
<PackageReference Include="System.Diagnostics.TraceSource" Version="4.3.0" />
<PackageReference Include="System.Diagnostics.TextWriterTraceListener" Version="4.3.0" />
...
</ItemGroup>
After reading your comments I tried removing those package dependencies and I can confirm that the project builds just fines. I'm guessing that it's a sufficient fix that will guarantee that any top-level project depending on FSharpLu.dll that is targetting at least dotnetcore 2.2 will have the right implementation of System.Diagnostics.TextWriterTraceListener
with the fix from dotnet/corefx#29234?
The constructor
System.Diagnostics.TextWriterTraceListener(string fileName)
is not properly implemented. The filename gets stored in a class field (_fileName
) but nothing gets ever written to the file.Repro (F#)
Observed
File
C:\temp\test.log
is not present on disk.Expected File
File
C:\temp\test.log
should be created on disk and contain two lines: "test1" and "test2". Or at least the method should throw an exception, or at the very least the source code and documention should indicate that this API is not fully supported on dotnet core.See source at: https://github.com/dotnet/corefx/blob/43760cebc9b2773c0959629a443a28111d8b7de8/src/System.Diagnostics.TextWriterTraceListener/src/System/Diagnostics/TextWriterTraceListener.cs#L77
Known work around
First create a
FileStream
and instantiate the TraceListener using the constructor that takes a Stream instead of a filename: