F# Embedded resource is ignoring subfolder structure - f#

I am trying to embed resources (.xsd) to my project. The folder structure is as follows
- Project
project.fsproj
- subfolder
- v1
file.xsd
- v2
file.xsd
This file is embedded as a recourse and I would expect that I can access the files as follows {Namespace}.subfolder.v1.file.xsd and replace v1 with v2 if I want to load v2. However, my resources are being embedded without any reference to namespace or folder structure. When I call GetManifestResourceNames() it tells me that there is only one file
file.xsd
If I change v2/file.xsd -> v2/file2.xsd output for GetManifestResourceNames is
file.xsd
file2.xsd
What I expected the names would be
{Namespace}.v1.file.xsd
{Namespace}.v2.file.xsd
Project is part of a much larger solution that may be causing this in its build process. I can't reproduce the behaviour with an isolated project. But I am not sure where to start looking.

Related

Blazor Server localization

I have a project using Localization. program.cs:
builder.Services.AddLocalization();
...
app.UseRequestLocalization(new RequestLocalizationOptions()
.SetDefaultCulture(LanguageList.GetSupportedLanguages[0])
.AddSupportedCultures(LanguageList.GetSupportedLanguages)
.AddSupportedUICultures(LanguageList.GetSupportedLanguages));
Where LanguageList.GetSupportedLanguages is nothing but an array of CultureInfo.
It's working perfectly; however, I have put the .resx files in the same folder as the razor files and the folder content gets quite messy fast. If I move them, it doesn't work anymore.
I read in Microsoft doc that the Resource file path can be set by:
builder.Services.AddLocalization(config => config.ResourcesPath = "Resources");
However, if I move the resx files to this folder two things happen. It doesn't work (text is not set) and I get this error message:
Custom tool PublicResXFileCodeGenerator failed to produce an output for input file 'Resources\Index.en.resx' but did not log a specific error.
I been trying some tips I found here on StackOverflow, among them adjusting the folder structure to mimic the namespace.
No luck. What am I doing wrong here? How do I utilize the ResourcesPath setting?

Organize GraphQL files in directories in Rails

Upon running rails g graphql:install, a set of useful base type files are created in /app/graphql/types for us to extend when defining our own types. When running any of the generators, it creates these files in the same folder also. I set about creating sub directories thinking I could add some sense to this giant catch-all directory, but couldn't get things to load properly.
Since there is a base file for each type (base_enum.rb, base_object.rb, etc.), I created a folder for extensions of each of these types (enum_types, object_types, etc.). This broke auto loading though and I had to explicitly import these files to be able to use these custom types. So, at the top of query_type.rb, mutation_type.rb and app/graphql/mutations/base_mutation.rb I added the following:
['enum_typs', 'input_object_types', 'interface_types', 'object_types', 'scalar_types', 'union_types'].each do |dir|
Dir[File.dirname(__FILE__) + "/#{dir}/*.rb"].each {|file| require file }
end
This allowed things to run, but any change would break auto loading so I would have to restart the server on each change. I started reading through this article about auto loading on the rails site, but it was quite honestly a little over my head. Though it led me to believe I had to either find the correct names for my folders or namespace the objects defined in my type definition files properly to be able to do this.
Is there a sane way to organize these files in sub-directories which doesn't break auto loading? Do most projects just have a flat folder structure for these files?
Thank you!

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)

phpspec tests within zend 2 module

I'm trying to move my spec folder into a zend 2 module folder. I don't totally understand how phpspec determines where the source folder is. How can I configure it to use the below folder structure.
\ModuleName
\spec
\ModuleName
\Class.php
\src
\ModuleName
ClassSpec.php
...
...
You can configure spec and src paths, see the docs:
http://phpspec.net/en/latest/cookbook/configuration.html
If that doesn't solve your issue, you'll need to write a phpspec extension and provide a custom resource locator. Here's a similar example for Symfony:
https://github.com/phpspec/Symfony2Extension/blob/master/src/PhpSpec/Symfony2Extension/Locator/PSR0Locator.php

MVC 4 error in accessing resource file from controller

Getting error in accessing resource file string from MVC controller(working file with views)
Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "TempNameSpace.App_GlobalResources.Resource_EN_US.resources" was correctly embedded or linked into assembly "TempNameSpace" at compile time, or that all the satellite assemblies required are loadable and fully signed.
What I have already done
1. Resource file build action : from content to Embedded resource
Result : Publish does not include resource files in it.
2. Added new resource file with name Resource.resx
Result : Same error
Solution hierarchy
1. Solution contains 4 projects, two with resource files(Resource.resx and Resource_EN_US under App_GlobalResources folder)
2. Designer for Resource_EN_US contains correct namespace
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TempNameSpace.App_GlobalResources.Resource_EN_US", typeof(Resource_EN_US).Assembly);
In my projects I use a seperate project for resources. I have set all resource files Build Action property to Embedded Resource.
On the reference to the resources project, I have Copy Local set to True for the resources project. (Rightclick a reference and select Properties)
If you have your resource files inside your web project, I think that the property corresponding with Copy Local should be Copy to Output Directory (Also accessible via rightclick and Properties).
Edit:
I see that in your comment you said that you access the file as Resource.Resource_EN_US.WaterMarkEmail but this is not the right way to access the files. You should access them as one single file: Resources.Property.
My files are named as: Standard.resx, Standard.en.resx, Standard.no.resx and so on. To access them I can use Standard.Property. The resource files will mold toghether, but only if you give them valid names. If you can access all your resource files individually, then you have not used the correct naming convention.
I recommend implementing a ResourceHelper that uses the ResourceManager to access the property that you need.

Resources