Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resource.designer.fs is not being generated on build #6404

Closed
nbevans opened this issue Oct 19, 2021 · 9 comments
Closed

Resource.designer.fs is not being generated on build #6404

nbevans opened this issue Oct 19, 2021 · 9 comments
Assignees
Labels
Area: App+Library Build Issues when building Library projects or Application projects.

Comments

@nbevans
Copy link

nbevans commented Oct 19, 2021

Steps to Reproduce

  1. Create a Android app in VS using the F# template
  2. Try to build it.
  3. Observe that the Resource.designer.fs file is not generated. No resources can be resolved at runtime by doing say:
        let foo = Application.Context.Resources.GetString(Resource_String.my_string_value)

Indeed on a fresh app as per Step 1 then Resource_String won't even exist in the codebase, so immediate compile error. If it did exist (as in our case, a copy from 2020) then the auto-generated ID numbers will be out of date and will result in runtime exceptions when trying to resolve those resource IDs.

Expected Behavior

The Resource.designer.fs file should be generated on each build.

Actual Behavior

The Resource.designer.fs file is not being generated, ever.

Version Information

Microsoft Visual Studio Community 2019
Version 16.11.5

Notes

I am some what shocked to be creating this issue. It appears that F# builds have been broken now for sometime. I have only just noticed it because it is quite rare we need to make changes to our Resources in our app. There has been an issue open in the Xamarin.Android.FSharp.ResourceProvider project for a long time but there is no resolution. As this is a blocking issue and affects production apps I have created a issue here for better visibility.

@nbevans nbevans added Area: App+Library Build Issues when building Library projects or Application projects. needs-triage Issues that need to be assigned. labels Oct 19, 2021
@nbevans
Copy link
Author

nbevans commented Oct 19, 2021

@nbevans nbevans changed the title Resource.designer.fs is not being built Resource.designer.fs is not being generated on build Oct 19, 2021
@jonathanpeppers
Copy link
Member

This happened for me in VS 2022:

image

But then I Rebuild and it starts working:

image

I suspect this problem has always been here? It seems like the first design-time build isn't working, but future ones work.

@jonathanpeppers jonathanpeppers removed the needs-triage Issues that need to be assigned. label Oct 19, 2021
@jonathanpeppers jonathanpeppers added this to the Under Consideration milestone Oct 19, 2021
@nbevans
Copy link
Author

nbevans commented Oct 19, 2021

Hmm.

What happened to the Resource_String, Resource_Id, Resource_<resource type> approach?

When did it start relying on a type provider like this?

This has caught me out because I don't actually know when the regression occurred. All I know is, my Resource.designer.fs is last modified mid-2020 (!) and no matter what I try now (rebuilds the lot) it won't update it. It seems to no longer be in use (except my Resource_* references to it all over my codebase).

@jonathanpeppers
Copy link
Member

I just tested the default Xamarin.Android F# template.

You might create one of those and compare with your project.

@nosami
Copy link
Contributor

nosami commented Oct 20, 2021

I suspect this problem has always been here? It seems like the first design-time build isn't working, but future ones work.

No the IDE didn't used to show squiggles after the initial design time build had completed. Doesn't seem like a blocking issue though.

What happened to the Resource_String, Resource_Id, Resource_ approach?

It never really worked properly for many people as the F# codegen often produced uncompilable code. Also Xamarin.Android relies on public static fields being assigned at runtime. F# does not support public static fields so a new approach was required.

When did it start relying on a type provider like this?

Around 5 years ago.

@nbevans
Copy link
Author

nbevans commented Oct 20, 2021

I suspect this problem has always been here? It seems like the first design-time build isn't working, but future ones work.

No the IDE didn't used to show squiggles after the initial design time build had completed. Doesn't seem like a blocking issue though.

What happened to the Resource_String, Resource_Id, Resource_ approach?

It never really worked properly for many people as the F# codegen often produced uncompilable code. Also Xamarin.Android relies on public static fields being assigned at runtime. F# does not support public static fields so a new approach was required.

When did it start relying on a type provider like this?

Around 5 years ago.

What was updating our Resource.designer.fs through all these commits until 2020?

image

We're always broadly up to date with Visual Studio releases, never more than 1 to 2 releases behind for more than a month or so. It is not like we haven't updated VS for the past year.

@nosami
Copy link
Contributor

nosami commented Oct 22, 2021

Resouce.designer.fs may have still been generated, but it was deprecated around 5 years ago.

Xamarin.Android must have finally stopped producing this file.

@jonathanpeppers
Copy link
Member

Resource.designer.fs was removed from Xamarin.Android in ~January 2020:

86be621

Documented in release notes here:

https://docs.microsoft.com/en-us/xamarin/android/release-notes/10/10.3#removal-of-f-resourcedesignerfs-file-support

From what I remember, it was done so we could remove .NET framework-only types and support dotnet build in .NET 6.

@jonathanpeppers
Copy link
Member

I think we understand the cause here. If you have further issues migrating to Xamarin.Android.FSharp.ResourceProvider, file a new issue and we can take a look, thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Area: App+Library Build Issues when building Library projects or Application projects.
Projects
None yet
Development

No branches or pull requests

4 participants