Skip to content

Conversation

@nosami
Copy link
Contributor

@nosami nosami commented Sep 27, 2016

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

Instead, a type provider
is used at compile time (both xbuild and the IDE) that compiles the
C# code using CSharpCodeProvider and makes the types available to
the consuming F# project. The type provider is available as a NuGet
package and is included in the Android templates.

This is similar to #159, but uses an F# type provider to compile the C# instead of an msbuild task. The advantage of this method is that intellisense works in the IDE without having to change the IDE code.

@nosami
Copy link
Contributor Author

nosami commented Sep 27, 2016

I created a build lane for XS with the new templates.

The overall experience looks like this :-

fsharpandroid

@nosami nosami force-pushed the fsharp-type-provider branch from 500d009 to ae3bdc4 Compare September 27, 2016 14:38
@jonpryor
Copy link
Contributor

Does this work in both IDEs, Xamarin Studio and Visual Studio?

</CreateItem>

<CreateProperty Value="@(_AndroidResgenFilenameItems->'%(Filename)%(Extension)')">
<CreateProperty Value="@(_AndroidResgenFilenameItems->'%(Filename).%(Extension)')">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The %(Extension) already contains the . :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accident :)

@nosami
Copy link
Contributor Author

nosami commented Sep 27, 2016

It's not working when deployed right now. I have definitely seen it working though, currently trying to figure out why.

@nosami
Copy link
Contributor Author

nosami commented Sep 27, 2016

@jonpryor I haven't tested VS yet, but I expect it to work

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

Instead, a [type
provider](https://github.com/xamarin/Xamarin.Android.FSharp.ResourceProvider/blob/master/ResourceTypeProvider.fs)
is used at compile time (both xbuild and the IDE) that compiles the
C# code using CSharpCodeProvider and makes the types available to
the consuming F# project. The type provider is available as a NuGet
package and is included in the Android templates.
@nosami nosami force-pushed the fsharp-type-provider branch from ae3bdc4 to ad15b93 Compare September 28, 2016 10:44
@nosami
Copy link
Contributor Author

nosami commented Sep 28, 2016

So it does work inside VS too. The runtime issue I mentioned earlier was a bodged nuget package - false alarm.

fsharpandroid-win

@nosami
Copy link
Contributor Author

nosami commented Sep 29, 2016

This PR can be considered for clean up purposes only. It doesn't seem to actually be required.

You can test the new F# template here https://github.com/nosami/android-template-test

@dellis1972
Copy link
Contributor

We have decided not the merge these changes until the new template has been published. That way we don't break existing users. We'll merge this in C10

@dellis1972 dellis1972 changed the title [F#] Use C# Resource.designer.cs file for F# [F#] Use C# Resource.designer.cs file for F# [C10 MERGE ONLY] Sep 29, 2016
@atsushieno
Copy link
Contributor

Now that we have branched cycle9, maybe this can be merged? It would be no rush though.

@borgdylan
Copy link

Can this make an assembly with the constants that is added to the reference assemblies that get passe don the compiler. That would allow me to use the same constants file for projects written with my custom compiler. I currently have to hack the resource file generating code to support my language as well.

@borgdylan
Copy link

The current situation while hacking the build tasks to sneak in support for another language is terrible on Linux. The build system is a mine field with signing failing because CSC is still depending on Windows parts like mscoree.dll.

@monojenkins
Copy link

Hello! I'm the build bot for the Mono project.

I need approval from a Mono team member to build this pull request. A team member should reply with "approve" to approve a build of this pull request, "whitelist" to whitelist this and all future pull requests from this contributor, or "build" to explicitly request a build, even if one has already been done.

Contributors can ignore this message.

1 similar comment
@monojenkins
Copy link

Hello! I'm the build bot for the Mono project.

I need approval from a Mono team member to build this pull request. A team member should reply with "approve" to approve a build of this pull request, "whitelist" to whitelist this and all future pull requests from this contributor, or "build" to explicitly request a build, even if one has already been done.

Contributors can ignore this message.

@nosami nosami closed this Sep 7, 2017
radical pushed a commit that referenced this pull request May 8, 2018
Appease Gendarme's [UseCorrectDisposeSignaturesRule][0] logic:

[0]: https://github.com/spouliot/gendarme/wiki/Gendarme.Rules.Design.UseCorrectDisposeSignaturesRule(2.10)

Gendarme doesn't like `Dispose()` overloads except those which
implement the `IDisposable` pattern. Meaning, specifically, Gendarme
doesn't like `JniRuntime.JniValueManager.Dispose(IJavaPeerable)`.

Rename `JniRuntime.JniValueManager.Dispose(IJavaPeerable)` to
`JniRuntime.JniValueManager.DisposePeer(IJavaPeerable)`, and then for
consistency rename many of the other `JniRuntime.JniValueManager`
methods to likewise have a `Peer` suffix.

* `Add(IJavaPeerable)` becomes `AddPeer(IJavaPeerable)`
* `Collect()` becomes `CollectPeers()`
* `Construct(IJavaPeerable)` becomes `ConstructPeer(IJavaPeerable)`
* `Dispose(IJavaPeerable)` becomes `DisposePeer(IJavaPeerable)`
* `DisposeUnlessReferenced(IJavaPeerable)` becomes `DisposePeerUnlessReferenced(IJavaPeerable)`
* `Finalize(IJavaPeerable)` becomes `FinalizePeer(IJavaPeerable)`
* `Remove(IJavaPeerable)` becomes `RemovePeer(IJavaPeerable)`
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>
@github-actions github-actions bot locked and limited conversation to collaborators Feb 2, 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.

8 participants