Skip to content

Conversation

@dellis1972
Copy link
Contributor

@dellis1972 dellis1972 commented Aug 12, 2016

The latest release of F# removed support for static fields. As a result
the Resource.Designer.fs file that wes being generated by our build
system no longer compiled.

This commit reworks the Designer.cs code to emit a C# assembly for
F# projects rather than just the code. This has the benifit of
us not having to produce F# code in the first place.

The new system works as follows.

  1. GenerateResourceDesigner Task generates a Resources.Designer.xx file as normal
  2. If the target project is F# that file is then compiled into a Resource.Designer.dll
  3. The new .dll is then included in the @ReferencePaths ItemGroup
  4. The Resource.Designer.xx is removed from the @complie ItemGroup

If the project is C# or VS the Designer file is just included as normal.

@dellis1972
Copy link
Contributor Author

Personally, if this works as we expect, I think we should move ALL project types over to using the Resource.Designer.dll rather than using the .cs file. That way we only have one system to deal with.

@dellis1972 dellis1972 changed the title [Xamarin.Android.Build.Tasks] Fixed F# Resource Designer compilation issues [Xamarin.Android.Build.Tasks] Fixed F# Resource Designer compilation issues [DONT MERGE] Aug 12, 2016
@dellis1972
Copy link
Contributor Author

The problem with this so far is the C# code is generated in Resource.Designer.fs .
Changing the extension is problematic since its defined in the user project.

@nosami
Copy link
Contributor

nosami commented Sep 1, 2016

I know this isn't finished yet, but just reporting my findings.

Resource.Designer.dll compiled with Resource.Designer.stub.cs is compiled against the wrong mscorlib

14:10 $ ikdasm Resource.Designer.dll

// Metadata version: v4.0.30319
.assembly extern mscorlib
{
  .publickeytoken = (B7 7A 5C 56 19 34 E0 89 )                         // .z\V.4..
  .ver 4:0:0:0
}

This causes a warning in the editor before build

screen shot 2016-09-01 at 14 17 51

I also get two red squiggles in the editor

screen shot 2016-09-01 at 14 21 23

Would it be possible to include Resource.Layout.Main and Resource.Id.myButton to be part of the 'stub' dll?

After building (and making a random edit) everything looks fine :-

screen shot 2016-09-01 at 14 23 33

"Bug 42840 Unable to build F# Android project with F# Class Library." is fixed by this change. I wasn't able to test the mixed F#/C# solution bugs, because this PR breaks C# :) But I would expect them to just work.

…issues

The latest release of F# removed support for static fields. As a result
the Resource.Designer.fs file that wes being generated by our build
system no longer compiled.

This commit reworks the Designer.cs code to emit a C# assembly for
F# projects rather than just the code. This has the benifit of
us not having to produce F# code in the first place.

The new system works as follows.

1) GenerateResourceDesigner Task generates a Resources.Designer.cs file as normal
2) If the target project is F# that file is then compiled into a Resource.Designer.dll
3) The new .dll is then included in the @ReferencePaths ItemGroup
4) The Resource.Designer.cs is removed from the @complie ItemGroup

If the project is C# or VS the Designer file is just included as normal.
@jonpryor
Copy link
Contributor

@nosami, @dellis1972: what's the status of this PR? Should we merge this for XA 7.2? Does it need testing, QA? What are the QA implications of this PR?

@dellis1972
Copy link
Contributor Author

@jonpryor I think @nosami went down a different route (see #238 ) I'm not sure this is required anymore. @nosami can you confirm?

@dellis1972 dellis1972 closed this Apr 27, 2017
radical pushed a commit that referenced this pull request May 8, 2018
Without this, abstract classes that implement `java.time.chrono.Chronology`
fail to bind because they will try to implement those static properties
as instance (this check had been done for methods, but not for properties).
jonpryor pushed a commit that referenced this pull request Jan 28, 2020
Context: #238
Context: #4132

Removes the use of F# CodeDOM for generating the resource designer
file for F#.

Instead, the [Xamarin.Android.FSharp.ResourceProvider][0] type
provider will be used at compile time -- via both `msbuild` and the
IDE -- which will compile the C# `Resource.Designer.cs` file and make
the types available to the consuming F# project.

The type provider is available as a [NuGet package][1] and is
included in the Android templates.

This is conceptually similar to [PR #159][2], but uses an F# type
provider to compile the C# code instead of an MSBuild task.  The
advantage of this method is that IntelliSense works within the IDE
without needing to change the IDE code.

[0]: https://github.com/xamarin/Xamarin.Android.FSharp.ResourceProvider
[1]: https://www.nuget.org/packages/Xamarin.Android.FSharp.ResourceProvider
[2]: #159

Co-authored-by: Jason Imison <nosami@users.noreply.github.com>
jonpryor added a commit to jonpryor/xamarin-android that referenced this pull request Mar 16, 2022
jonpryor added a commit that referenced this pull request Mar 17, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Feb 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants