Closed sergey-tihon closed 2 years ago
@Liminiens I think I did some resources stuff in another project and the name of the resources changed in .Net Standard: they turned into fully-qualified names (ie PROJECTNAME.ResourceName
), so that might be your problem? I started by using https://docs.microsoft.com/en-us/dotnet/api/system.reflection.assembly.getmanifestresourcenames?view=netframework-4.7.2 to dump the set of resources in the assembly to see if I had the correct, expected names.
@baronfel hm...you are right. I tried to use qualified names but still have test errors. I will try to debug it further. Maybe I am missing something.
[23:27:21 INF] EXPECTO? Running tests... <Expecto>
[23:27:21 ERR] ResX Provider tests/Can return an image from the resource file errored in 00:00:00.0700000 <Expecto>
System.InvalidCastException: Unable to cast object of type 'System.String' to type 'System.Drawing.Bitmap'.
at FSharp.Configuration.Tests.ResXTests.tests@14-13.Invoke(Unit _arg2)
at Expecto.Impl.execTestAsync@924-1.Invoke(Unit unitVar)
at Microsoft.FSharp.Control.AsyncBuilderImpl.callA@522.Invoke(AsyncParams`1 args)
[23:27:21 ERR] ResX Provider tests/Can return an int from the resource file errored in 00:00:00.0830000 <Expecto>
System.InvalidCastException: Specified cast is not valid.
at FSharp.Configuration.Tests.ResXTests.tests@18-14.Invoke(Unit _arg3)
at Expecto.Impl.execTestAsync@924-1.Invoke(Unit unitVar)
at Microsoft.FSharp.Control.AsyncBuilderImpl.callA@522.Invoke(AsyncParams`1 args)
[23:27:21 ERR] ResX Provider tests/Can return a text file from the resource file failed in 00:00:00.0700000.
value.
Expected string to equal:
Text
The string differs at index 4.
TextFile.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8
String `actual` was longer than expected, at pos 4 found item 'F'.
at Expecto.Expect.stringEquals@254-9.Invoke(String x)
at Expecto.Expect.stringEquals(String a, String e, String message)
at FSharp.Configuration.Tests.ResXTests.tests@20-15.Invoke(Unit _arg4)
at Expecto.Impl.execTestAsync@924-1.Invoke(Unit unitVar)
at Microsoft.FSharp.Control.AsyncBuilderImpl.callA@522.Invoke(AsyncParams`1 args)
<Expecto>
@Liminiens this looks to be a problem with the fact that the ResXFileRef
type isn't available in .net core yet. If you look at the resx file, it 'points' to the text file by use of the ResXFileRef:
<data name="TextFile" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>TextFile.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
And that type isn't available yet (https://docs.microsoft.com/en-us/dotnet/api/system.resources.resxfileref?view=netframework-4.7.2&viewFallbackFrom=netcore-2.2). Because there's no implmentation of that type automatically packing the reference at compile-time into text content, I think you're just reading out the string value of the value
node here.
Aha! Found a tracking issue: https://github.com/Microsoft/msbuild/issues/2221
Any news here? I would like to use it in .NET core...
@Slesa let's move our conversation from twitter here.
it requires .NET4 / Mono
Yes, it is because it still build design time component for net46 https://github.com/sergey-tihon/FSharp.Configuration/blob/dotnet/src/FSharp.Configuration.DesignTime/FSharp.Configuration.DesignTime.fsproj#L6
Does 2.0.0-alpha3 works for you on .net core?
Yes, works. Thanks a lot.
Status
net45
Unit tests for ResX type provider temporary ignored because provided code failed to load actual value in runtime
Here should be some magic that fixes it when we build for full frameworks...
As of today .net core has the very limited support for resource files - https://github.com/Microsoft/msbuild/issues/2221
Status
netstandard2.0
TPs migrated to
netstandard2.0
:Tip for
YamlDotNet
serializer customization - https://www.cyotek.com/blog/using-custom-type-converters-with-csharp-and-yamldotnet-part-1