Embed the sample files of F# JsonProvider to use in a library - f#

According to this, you can specify samples as embedded resources by using EmbeddedResource:
type Declaracion = JsonProvider<"declaracion.json", EmbeddedResource="Irpf.Hechos, declaracion.json">
But when I reference this library, "Irpf.Hechos.dll", I get a File Not Found error, the path ConsumingLibraryPath\declaracion.json is not found; typecheck error FS3033
I have tried to set the declaracion.json file as resource, and content, but no luck.
Am I missing some step?

You need to set the build action as "EmbeddedResource" rather than "Resource".

Related

Where should the erlang_ls.config go

I want to use coc.nvim and elrang_ls in vim8.2. There are some problems. It report missing an erlang_ls.config when I open a erlang file. But i have erlang_ls.config in project root.
the result of CocCommand workspace.showOutput show it read config from unexpected place
Where is correct position for erlang_ls.config?
Sorry for my poor English. Thanks.
It is possible to customize the behaviour of the erlang_ls server via
a configuration file, named erlang_ls.config. The erlang_ls.config
file should be placed in the root directory of a given project to
store the configuration for that project.
According to the picture, the clue has already been given to you. In the els_config.erl file consult_config function, line 126. error type = 2.
I think the information is enough, you can find source code file and read it and find why?
It is need create erlang_ls.config in C:\Users\Administrator\AppData\Roaming\erlang_ls and erlang_ls.config erlang_ls.yaml in the project root path. But I don't know why.

Swashbuckle custom asset not found

I added to SwaggerConfig.cs this string
c.CustomAsset("index", thisAssembly, "Table.Web.CustomContent.index.html");
...than I run the application, go to swagger docs and get error:
An error has occurred.
Embedded resource not found - Table.Web.CustomContent.index.html
Swashbuckle.SwaggerUi.AssetNotFound
The build action property of the index.html was set to embedded resource
What should I do to fix it?
I struggled with this for a while today in a ASP.NET C# project and finally resolved it by cobbling together a few different resources.
First (as noted in the Swagger comments), the item must be marked as an Embedded Resource by right-clicking the item in the solution explorer and going to Properties, and selecting Embedded Resource from the Build Action dropdown.
Second, the logical name can be tricky to identify. In my case, a dash in a directory name was being converted to an underscore once embedded, leading to lots of hair-pulling (hair_pulling?). The easiest way to get the true logical path is to get it from the Build Output window.
Go to Tools => Options
Expand the Projects and Solutions sidebar item and click Build and Run
Set the MSBuild Output to Detailed.
Clean the solution and rebuild, opening the Output window if necessary.
The output log should unambiguously state the true logical name of the file with a line like...
Resource file 'swagger-ui\SwaggerUiStyle.css' gets manifest resource name 'MySolutionName.swagger_ui.SwaggerUiStyle.css'
(credit to #bkwdesign for his excellent explanation on this part)

is there a good way to find function define in header file in ace framework

As a ace framework newer, i always encounter some problem when using this framework.
I copy some example code from website and execute it in linux. however some error throw out because of no include correspond header file. for exmaple some error like this: error: ‘sleep’ is not a member of ‘ACE_OS’.
so how can i found this function define in which header file
Most easiest is just to do a "grep sleep $ACE_ROOT/ace/OS*.h", that tells you the file where this method is defined. Other option is to use the most recent doxygen tree at http://doxygen.theaceorb.nl/libace-doc/index.html

Properties.Resources.XXXX Namespace or Module not Defined

I'm trying to read in the text (as a string) of an XML file from my Resources. The XML file is named MyXMLResourceFile.resx.
I tried using the C# way using
let myFile : string = Properties.Resources.MyXMLResourceFile
but it is giving me the error (under Properties):
The namespace or module 'Properties' is not defined.
I'm assuming I'm missing an open but have no idea what it would be.
Sorry, I'm still pretty new to F# coming from VB.
Additional information:
I made the resx file myself per this SO answer I then looked to see how others accessed it. In C# they did Properties.Resources.XXXX per this project I saw you could use ResourceManager but didn't see any method to read the whole file directly into a string.
The namespace or module 'Properties' is not defined.
That's because the namespace Properties is not defined. You probably brought the resx file from another project. Open the associated .Designer file, if it doesn't appear in the F# project, open it up in the original project. You will see a namespace with and a bunch of C# code, assuming the original project was in C#. The namespace of this file has to be the same namespace of the project where you are trying to call it.
But, since this is C# code, it won't run on a F# project. You have two choices: use a code generator to generate the associated .Designer class in F# code with the Properties namespace, (I don't know if such generator exists); or pre-compile the resx in the original project and reference it as a dll from your F# project, then you can access it with ResourceManager.

Type provider and static argument in F#

I have a library, Library_1, which compiles correctly and defines a provided type :
type modelforexcel = FSharpx.ExcelFile<#"template.xls", "Brokernet", true>
When I include this library in another project, Library_2, the compiler complains that it can't find any "Brokernet.template.xls", at the root of the new Library_2 project.
Error 4 'C:\Library_2\template.xls' could not be found. Check the spelling of the file name, and verify that the file location is correct.
I would like the type to refer to the original "Brokernet.template.xls", so I am trying to provide the complete path to it, but
type modelforexcel =
FSharpx.ExcelFile<__SOURCE_DIRECTORY__+#"Brokernet.template.xls", "Brokernet", true>
does not work, as I guess it is not a literal (?)
But 'obviously' defining this literal does not work either
[<Literal>]
let a = __SOURCE_DIRECTORY__+#"Brokernet.template.xls"
Are there any way to define such a 'dynamic literal' ?
edit
Interestingly enough, if I define my type inside a module in the first library
module Load =
[<Literal>]
let a = #"Brokernet.template.xls"
type modelforexcel = FSharpx.ExcelFile< a , "Brokernet", true>
Then the type is not 'regenerated' upon using the first library in the second one, and the type provider does not complain about the file being absent of the root of the 2nd library.
This sheds profound insights in the compilation model of F# that are probably best exposed by masters. I'd just say, as a rough man, that "the code is in modules"
PS : I guess thats one more problem which would be solved by a proper staged compilation.
As being shown in the comments, using relative paths e.g. #"..\Library_1\Brokernet.template.xls" solved the problem.

Resources