fsprojects / FSharp.Configuration

The FSharp.Configuration project contains type providers for the configuration of .NET projects.
http://fsprojects.github.io/FSharp.Configuration/
Other
114 stars 63 forks source link

New project file format + Net Standard 2.0 build #139

Closed sergey-tihon closed 2 years ago

sergey-tihon commented 6 years ago

Statusnet45

Unit tests for ResX type provider temporary ignored because provided code failed to load actual value in runtime

[23:17:19 ERR] ResX Provider tests/Can return an image from the resource file errored in 00:00:00.0100000 <Expecto>
System.Resources.MissingManifestResourceException: Could not find any resources appropriate for the specified culture or the neutral culture.  Make sure "Resource1.resources" was correctly embedded or linked into assembly "FSharp.Configuration.Tests" at compile time, or that allthe satellite assemblies required are loadable and fully signed.
  at System.Resources.ManifestBasedResourceGroveler.HandleResourceStreamMissing (System.String fileName) [0x000bf] in <e22c1963d07746cd9708456620d50e1a>:0
  at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet (System.Globalization.CultureInfo culture, System.Collections.Generic.Dictionary`2[TKey,TValue] localResourceSets, System.Boolean tryParents, System.Boolean createIfNotExists, System.Threading.StackCrawlMark& stackMark) [0x000d9] in <e22c1963d07746cd9708456620d50e1a>:0
  at System.Resources.ResourceManager.InternalGetResourceSet (System.Globalization.CultureInfo requestedCulture, System.Boolean createIfNotExists, System.Boolean tryParents, System.Threading.StackCrawlMark& stackMark) [0x00099] in <e22c1963d07746cd9708456620d50e1a>:0
  at System.Resources.ResourceManager.InternalGetResourceSet (System.Globalization.CultureInfo culture, System.Boolean createIfNotExists, System.Boolean tryParents) [0x00002] in <e22c1963d07746cd9708456620d50e1a>:0
  at System.Resources.ResourceManager.GetObject (System.String name, System.Globalization.CultureInfo culture, System.Boolean wrapUnmanagedMemStream) [0x00071] in <e22c1963d07746cd9708456620d50e1a>:0
  at System.Resources.ResourceManager.GetObject (System.String name) [0x00000] in <e22c1963d07746cd9708456620d50e1a>:0
  at FSharp.Configuration.ResXProvider.readValue[a] (System.String resourceName, System.Reflection.Assembly assembly, System.String key) [0x00024] in <5adcedc545d3202aa7450383c5eddc5a>:0
  at FSharp.Configuration.Tests.ResXTests+tests@15-256.Invoke (Microsoft.FSharp.Core.Unit _arg2) [0x0000b] in <5adcedcdb7adfc68a7450383cdeddc5a>:0
  at Expecto.Impl+execTestAsync@888-1.Invoke (Microsoft.FSharp.Core.Unit unitVar) [0x00027] in <5ac8c052822f8511a745038352c0c85a>:0
  at Microsoft.FSharp.Control.AsyncBuilderImpl+callA@522[b,a].Invoke (Microsoft.FSharp.Control.AsyncParams`1[T] args) [0x00051] in <5a7d678a904cf4daa74503838a677d5a>:0

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

Statusnetstandard2.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

baronfel commented 5 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.

Liminiens commented 5 years ago

@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>
baronfel commented 5 years ago

@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.

baronfel commented 5 years ago

Aha! Found a tracking issue: https://github.com/Microsoft/msbuild/issues/2221

Liminiens commented 5 years ago

@baronfel I actually use my port of ResxReader from winforms there, it adds missing ResX types. :) but maybe something inside of ResourceReader isn't working.

Maybe we can use the .GetValue() method from the ResXDataNode directly? Like I did here here ?

Slesa commented 2 years ago

Any news here? I would like to use it in .NET core...

sergey-tihon commented 2 years ago

@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?

Slesa commented 2 years ago

Yes, works. Thanks a lot.