Bug 24709 - F# reserved keyword 'end' being generated in member for resource.designer.fs
Summary: F# reserved keyword 'end' being generated in member for resource.designer.fs
Status: VERIFIED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild (show other bugs)
Version: 4.18.1
Hardware: PC Windows
: Normal normal
Target Milestone: 7.1 (C9)
Assignee: Jonathan Pryor
URL:
: 41254 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-11-20 17:09 UTC by fwaris
Modified: 2017-01-03 23:59 UTC (History)
20 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Resource.designer.fs (103.97 KB, text/plain)
2014-11-20 17:10 UTC, fwaris
Details
solution to repo the error (1.28 MB, application/x-zip-compressed)
2014-11-25 07:51 UTC, fwaris
Details
Fixed project (1.44 MB, application/zip)
2016-10-05 23:35 UTC, Jason Imison
Details

Description fwaris 2014-11-20 17:09:59 UTC
I have create a new Android F# project and have added google map v2 to it.

The resulting resources.designer.fs file generated from the names in the resource definitions contains an invalid member name 'end' as in:


            // aapt resource value: 0x7f070013
            static member end = 2131165203                    <------ error here
            
            // aapt resource value: 0x7f070038
            static member expand_activities_button = 2131165240
            


The generated resource file is attached.
Comment 1 fwaris 2014-11-20 17:10:49 UTC
Created attachment 8824 [details]
Resource.designer.fs
Comment 2 Shruti 2014-11-24 10:00:08 UTC
I have checked this issue and not able to reproduce it. To Reproduce this issue, I have created an Android app in F# and added component google map v2 to it. I checked resources.designer file but I did not see any invalid member here.

Screencast regarding same : http://screencast.com/t/CQSE3KaUjKjY

Environment Info :

=== Xamarin Studio ===

Version 5.5.4 (build 15)
Installation UUID: b5156fb6-e8d3-47e2-b3a5-0925a4054ffd
Runtime:
 Microsoft .NET 4.0.30319.0
 GTK+ 2.24.22 (MS-Windows theme)
 GTK# 2.12.26

=== Xamarin.Android ===

Version: 4.20.0 (Trial Edition)
Android SDK: C:\Program Files (x86)\Android\android-sdk
 Supported Android versions:
  2.1   (API level 7)
  2.2   (API level 8)
  2.3   (API level 10)
  3.1   (API level 12)
  4.0.3 (API level 15)
  4.4   (API level 19)
Java SDK: C:\Program Files\Java\jdk1.7.0_72
java version "1.7.0_72"
Java(TM) SE Runtime Environment (build 1.7.0_72-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.72-b04, mixed mode)

=== Build Information ===

Release ID: 505040015
Git revision: f93940a35458a18052f1a25e106e62ca970d9c40
Build date: 2014-11-19 13:26:21-05
Xamarin addins: dc23cbd91a3a0e1d326328e1229e86c942a49ec8

=== Operating System ===

Windows 6.2.9200.0 (64-bit)


Please let me know If I missed anything to reproduce this issue.
Comment 3 fwaris 2014-11-25 07:51:47 UTC
Created attachment 8860 [details]
solution to repo the error
Comment 4 fwaris 2014-11-25 08:00:36 UTC
Please see attached minimum repo solution.

I just created a new F# Android project and then added Google Play Services from the component store.

Then did "clean" and "re-build".

Note that I ran into Windows path length limits using the default folder location. Just create the solution under a shorter path (e.g. "c:\xa") as a workaround.

Note that "end" is an F# reserved keyword. To compile again you need to change it to ``end``   (double backquotes).

The resource designer generator should be updated to wrap reserve words in double backquotes.
Comment 5 fwaris 2014-12-20 08:18:13 UTC
Shruti, hopefully you are able to reproduce this issue.

Can you please let me know?

Thanks,

Faisal
Comment 6 Ram Chandra 2014-12-22 02:36:42 UTC
@fwaris : Thank you very much for the steps and test case.

I have checked this issue and with the help of steps mentioned in  Comment 4, I am able to reproduce this issue.

Steps I followed:

1. Create an Android project from F# template.
2.  Add the Google Play Service component(19.0.02) from Component Store
3. Clean and rebuild project.

When I rebuild the project I observed that I am getting following errors :

> error FS0010: Unexpected keyword 'end' in member definition

> error FS0010: Incomplete structured construct at or before this point in implementation file. Expected incomplete structured construct at or before this point or other token.

Screencast: http://www.screencast.com/t/AFjjveToZU

Build Output: https://gist.github.com/saurabh360/d703e5abe76d12baaa8e
IDE logs: https://gist.github.com/saurabh360/26e1212398c3380021f7

Environment Info:

=== Xamarin Studio ===

Version 5.7 (build 660)
Installation UUID: b6495454-eed9-49ee-a97b-abf8a686d664
Runtime:
 Microsoft .NET 4.0.30319.34003
 GTK+ 2.24.22 (MS-Windows theme)
 GTK# 2.12.26

=== Xamarin.Android ===

Version: 4.20.0 (Trial Edition)
Android SDK: D:\SDK\AndroidSDK
 Supported Android versions:
  1.6    (API level 4)
  2.1    (API level 7)
  2.2    (API level 8)
  2.3    (API level 10)
  3.1    (API level 12)
  4.0    (API level 14)
  4.0.3  (API level 15)
  4.1    (API level 16)
  4.2    (API level 17)
  4.3    (API level 18)
  4.4    (API level 19)
  4.4.87 (API level 20)
  5.0    (API level 21)
Java SDK: C:\Program Files (x86)\Java\jdk1.7.0_71
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) Client VM (build 24.71-b01, mixed mode)

=== Build Information ===

Release ID: 507000660
Git revision: 6a74f9bdb90d9415b597064d815c9be38b401fee
Build date: 2014-12-17 23:51:00-05
Xamarin addins: 57be0f5e1433cb58b70ea9b52e9dc77ad791be40

=== Operating System ===

Windows 6.2.9200.0 (64-bit)
Comment 7 Atsushi Eno 2015-01-05 02:36:41 UTC
In monodroid master we switched to NuGet packaged version of FSharp.Compiler.CodeDom that is supposed to handle those F# keywords gracefully. So that hopefully fixed the issue.

(Right now monodevelop fsharpbinding is broken with master mono so I cannot verify this by myself with master; it should be examined later when everything gets better state.)
Comment 8 fwaris 2015-02-12 21:15:20 UTC
I just updated to XS 5.7.1 (build 17) and this still broken.

Hopefully it will get fixed soon.
Comment 9 Atsushi Eno 2015-02-12 21:45:51 UTC
XS has nothing to do with the fix. It comes with Xamarin.Android.
Comment 10 Romain Flechner 2015-05-22 17:13:00 UTC
Hi,

Can we have a fix ?

When we clean and build project, we just need to have

static member `end` = ....

instead of 

static member end = ...

in Resource.designer.fs

Thanks.
Comment 11 Atsushi Eno 2015-05-23 03:13:48 UTC
Dave: I have updated Xamarin.Android to switch to FSharp.CodeDom.Compiler NuGet package to fix this issue as you suggested, but it doesn't seem to fix the issue.
Comment 12 fwaris 2015-05-24 20:50:43 UTC
I have updated and still have the same issue.
Comment 13 Gareth Lees 2015-11-06 10:49:44 UTC
This happens to me too, not with Play Services though, but with AppCompat V7 - I'm on the latest Alpha after trying on Stable and still not working correctly.
Comment 14 Jonathan Pryor 2015-11-30 13:53:30 UTC
We may need to file a bug with upstream FSharp.CodeDom.Compiler. They should be escaping keywords, yet they don't appear to be.
Comment 15 Andreas Willich 2015-12-30 19:07:30 UTC
Is there any plan when this is fixed? This bug makes working with Xamarin.Forms and F# very difficult.
Every time something on the Android Project level is changed, the Resource.designer.fs is regenerated and you have to fix it manual in the file.
Comment 16 Atsushi Eno 2016-01-05 08:46:17 UTC
It sounds like upstream bug in FSharp (CodeDom.Compiler) itself. Once they fixed the bug, we will bring their up-to-date their package.
Comment 17 Andreas Willich 2016-01-20 09:41:54 UTC
The bug is fixed upstream and they released a new version (0.9.4).

https://github.com/fsprojects/FSharp.Compiler.CodeDom/issues/10
Comment 18 Atsushi Eno 2016-01-20 11:38:39 UTC
Cool, thanks for the heads up. I have updated the internal reference to the package so it should be fixed in the next alpha release.

[master cdc1a3b]
Comment 19 Atsushi Eno 2016-01-21 09:37:32 UTC
cdc1a3b caused regression (as F# CodeDom fixed assembly attribute output issue which broke our workaround), so another fix is applied. [master a5604e8]
Comment 20 Mark Gray 2016-02-04 15:32:30 UTC
Is there an actual fix for this available or are we still waiting for the next build to pick it up? If there is a new package from nuget can you link the nuget version please?
Comment 21 Atsushi Eno 2016-02-04 19:36:22 UTC
No, the fix is part of Xamarin.Android build tasks, so only new releases contain the fix.
Comment 22 Andreas Willich 2016-02-24 20:43:42 UTC
When will be the release? Is it in the Alpha/Beta channel?
Comment 23 Atsushi Eno 2016-02-24 21:49:19 UTC
The latest alpha should contain the updated FSharp.Compiler.CodeDom.dll.
Comment 24 Peter Collins 2016-05-23 20:07:36 UTC
*** Bug 41254 has been marked as a duplicate of this bug. ***
Comment 25 Peter Collins 2016-05-23 20:09:20 UTC
This introduced bug #39520, and has since been reverted.
Comment 26 Atsushi Eno 2016-05-24 04:52:08 UTC
If the latet F# CodeDom cannot be applied, there is nothing we can do to fix this bug anymore.
Comment 27 Jonathan Pryor 2016-05-24 14:04:40 UTC
The reason we can't update FSharp.CodeDom.Compiler is because of a bug in their CodeDom support:

https://bugzilla.xamarin.com/show_bug.cgi?id=39520#c13

We should work to create a repro and file this bug with them so that they can fix it, at which point we can update to the fixed version, and everyone can be happy.
Comment 28 Dragan 2016-05-26 07:42:05 UTC
I am on BETA channel and this bug wasn't present in last several builds of XS 6.0. Unfortunately when I pulled last update 2 days ago bug is back :( 

Here is my current setup:

Xamarin Studio Enterprise
Version 6.0 (build 5166)
Installation UUID: 0b82817b-768a-41d0-b2ec-bdf9b1608b5d
Runtime:
	Mono 4.4.0 (mono-4.4.0-branch/67b89ea) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 404000176

Xamarin.Profiler
Not Installed

Xamarin.Android
Version: 6.1.0.69 (Visual Studio Enterprise)
Android SDK: /Users/dragan/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		4.0.3 (API level 15)
		4.4   (API level 19)
		5.0   (API level 21)
		6.0   (API level 23)

SDK Tools Version: 24.4.1
SDK Platform Tools Version: 23.0.1
SDK Build Tools Version: 23.0.1

Java SDK: /usr
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Xamarin Android Player
Version: 0.6.5
Location: /Applications/Xamarin Android Player.app

Xamarin Inspector
Version: 0.8.0.0
Hash: dc081aa
Branch: master
Build date: Tue Apr 26 23:07:44 UTC 2016

Apple Developer Tools
Xcode 7.3 (10183.3)
Build 7D175

Xamarin.iOS
Version: 9.8.0.319 (Visual Studio Enterprise)
Hash: 7b89851
Branch: cycle7
Build date: 2016-05-20 16:56:02-0400

Xamarin.Mac
Version: 2.8.0.319 (Visual Studio Enterprise)

Build Information
Release ID: 600005166
Git revision: ec4f06cfaa9debdca2539e19edeafffe88ccd0cc
Build date: 2016-05-20 18:51:15-04
Xamarin addins: c7761d054f38e9a210822aba6356398af0c36fa9
Build lane: monodevelop-lion-cycle7

Operating System
Mac OS X 10.11.5
Darwin Dragans-MacBook-Pro.local 15.5.0 Darwin Kernel Version 15.5.0
    Tue Apr 19 18:36:36 PDT 2016
    root:xnu-3248.50.21~8/RELEASE_X86_64 x86_64

Enabled user installed addins
Xamarin Inspector 0.8.0.0
Comment 29 Jonathan Pryor 2016-07-28 20:25:49 UTC
The problem is that how we generate Resource.Designer.* needs a serious re-thinking; see Bug #42436.
Comment 30 Jason Imison 2016-09-30 08:27:06 UTC
Fixed in master XS (XamarinStudio-6.2.0.655)
Comment 31 Mohit Kheterpal 2016-10-05 14:31:36 UTC
I have checked this issue with the attached project in comment 3 using master build of XS 6.2.0.720 and observed that this issue still exist as shown in screencast : http://www.screencast.com/t/vZz1PI13Uw7

Environment info : https://gist.github.com/Mohit-Kheterpal/576299d28449eabd3c64889e6b39e6bc

Build output : https://gist.github.com/Mohit-Kheterpal/ce72a88e68433ac6cbe8b33410e517b0

Hence, reopening this issue.

Thanks
Comment 32 Jason Imison 2016-10-05 22:59:21 UTC
@Mohit, Please create the project from scratch. You should not have a Resource.designer.fs file.
Comment 33 Jason Imison 2016-10-05 23:35:21 UTC
Created attachment 17896 [details]
Fixed project

@mohit, I've fixed the zip with the needed changes (that would have been applied automatically if you'd used the template)

For reference, these are the changes that I made.

diff --git a/ResourceErrorRepo/MainActivity.fs b/ResourceErrorRepo/MainActivity.fs
index ad6405f..ea304ea 100644
--- a/ResourceErrorRepo/MainActivity.fs
+++ b/ResourceErrorRepo/MainActivity.fs
@@ -8,6 +8,8 @@ open Android.Runtime
 open Android.Views
 open Android.Widget

+type Resources = ResourceErrorRepo.Resource^M
+^M
 [<Activity(Label = "ResourceErrorRepo", MainLauncher = true)>]
 type MainActivity() =
     inherit Activity()
@@ -15,9 +17,9 @@ type MainActivity() =
     override this.OnCreate(bundle) =
         base.OnCreate(bundle)
         // Set our view from the "main" layout resource
-        this.SetContentView(Resource_Layout.Main)
+        this.SetContentView(Resources.Layout.Main)^M
         // Get our button from the layout resource, and attach an event to it
-        let button = this.FindViewById<Button>(Resource_Id.myButton)
+        let button = this.FindViewById<Button>(Resources.Id.myButton)^M
         button.Click.Add(fun args ->
             button.Text <- sprintf "%d clicks!" count
             count <- count + 1)
diff --git a/ResourceErrorRepo/ResourceErrorRepo.fsproj b/ResourceErrorRepo/ResourceErrorRepo.fsproj
index e7d236e..3b50c62 100644
--- a/ResourceErrorRepo/ResourceErrorRepo.fsproj
+++ b/ResourceErrorRepo/ResourceErrorRepo.fsproj
@@ -11,10 +11,10 @@
     <MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
     <AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>
     <AndroidApplication>True</AndroidApplication>
-    <AndroidResgenFile>Resources\Resource.designer.fs</AndroidResgenFile>
+    <AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>^M
     <AndroidResgenClass>Resource</AndroidResgenClass>
     <AssemblyName>ResourceErrorRepo</AssemblyName>
-    <TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
+    <TargetFrameworkVersion>v7.0</TargetFrameworkVersion>^M
     <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@@ -64,9 +64,11 @@
     <Reference Include="Xamarin.Android.Support.v7.MediaRouter">
       <HintPath>..\packages\Xamarin.Android.Support.v7.MediaRouter.20.0.0.1\lib\MonoAndroid10\Xamarin.Android.Support.v7.MediaRouter.dll</HintPath>
     </Reference>
+    <Reference Include="Xamarin.Android.FSharp.ResourceProvider.Runtime">^M
+      <HintPath>..\packages\Xamarin.Android.FSharp.ResourceProvider.1.0.0.12\lib\Xamarin.Android.FSharp.ResourceProvider.Runtime.dll</HintPath>^M
+    </Reference>^M
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="Resources\Resource.designer.fs" />
     <Compile Include="Properties\AssemblyInfo.fs" />
     <Compile Include="MainActivity.fs" />
   </ItemGroup>
@@ -90,4 +92,4 @@
       <Visible>False</Visible>
     </XamarinComponentReference>
   </ItemGroup>
-</Project>
\ No newline at end of file
+</Project>^M
diff --git a/ResourceErrorRepo/packages.config b/ResourceErrorRepo/packages.config
index d217190..2ebcead 100644
--- a/ResourceErrorRepo/packages.config
+++ b/ResourceErrorRepo/packages.config
@@ -1,8 +1,9 @@
-<U+FEFF><?xml version="1.0" encoding="utf-8"?>
-<packages>
-  <package id="Xamarin.Android.Support.v13" version="20.0.0.4" targetFramework="MonoAndroid50" />
-  <package id="Xamarin.Android.Support.v4" version="20.0.0.4" targetFramework="MonoAndroid50" />
-  <package id="Xamarin.Android.Support.v7.AppCompat" version="20.0.0.2" targetFramework="MonoAndroid50" />
-  <package id="Xamarin.Android.Support.v7.MediaRouter" version="20.0.0.1" targetFramework="MonoAndroid50" />
-  <package id="Xamarin.GooglePlayServices" version="19.0.0.1" targetFramework="MonoAndroid50" />
+<U+FEFF><?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="Xamarin.Android.FSharp.ResourceProvider" version="1.0.0.12" targetFramework="monoandroid70" />
+  <package id="Xamarin.Android.Support.v13" version="20.0.0.4" targetFramework="MonoAndroid50" />
+  <package id="Xamarin.Android.Support.v4" version="20.0.0.4" targetFramework="MonoAndroid50" />
+  <package id="Xamarin.Android.Support.v7.AppCompat" version="20.0.0.2" targetFramework="MonoAndroid50" />
+  <package id="Xamarin.Android.Support.v7.MediaRouter" version="20.0.0.1" targetFramework="MonoAndroid50" />
+  <package id="Xamarin.GooglePlayServices" version="19.0.0.1" targetFramework="MonoAndroid50" />
 </packages>
Comment 34 Saurabh 2016-10-06 06:50:15 UTC
I have checked this Issue with latest master builds (XS 6.2.0.750 + X.Android 7.0.99.117), project getting build successfully.

Build output from Mac: https://gist.github.com/saurabh360/cbc79ed52898671135635f5b695d1a29

build Output from Windows:
https://gist.github.com/saurabh360/7214c53fec1601a866483a208922ef31

Environment Info: https://gist.github.com/saurabh360/d2d155ea87a824213a941c8669e23a01

Also noticed that when creating new Android F# template, It is not showing  Resource.designer.fs file
Comment 35 Cody Russell 2016-10-09 00:10:32 UTC
Just a heads up, there's a warning in the same file where it's generating this:

            // aapt resource value: 0x7f0b0023
            static member fixed = 2131427363

It says: "The identifier 'fixed' is reserved for future use by F#."
Comment 36 Jason Imison 2016-10-09 18:21:38 UTC
@Cody - Resource.designer.fs should no longer be part of the compilation with the new Android templates. It's not used any more.
Comment 37 Carsten Elton Sørensen 2016-11-06 15:39:40 UTC
Using Xamarin Studio 6.1.1 on Mac OS X, the template "Android App" for F# still includes Resources.Designer.fs.

Using the patch in Comment 33 makes the solution work properly.


Xamarin Studio Business
Version 6.1.1 (build 17)
Installation UUID: 4d1d704d-e2ee-4ab5-8fad-c11eac1363f9
Runtime:
	Mono 4.6.1 (mono-4.6.0-branch-c8sr0/ef43c15) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 406010005

Xamarin.Android
Version: 7.0.1.3 (Xamarin Business)
Android SDK: /Users/ces/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		4.0.3 (API level 15)
		4.4   (API level 19)
		5.0   (API level 21)
		6.0   (API level 23)
		7.0   (API level 24)

SDK Tools Version: 25.2.2
SDK Platform Tools Version: 24.0.3
SDK Build Tools Version: 23.0.1

Java SDK: /usr
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Build Information
Release ID: 601010017
Git revision: 44d481a9be9cf2bf7c01bfb99c59b77dfa08e712
Build date: 2016-10-25 14:27:24-04
Xamarin addins: 19cdb28081bf28d9688698030abb96e04e391f69
Build lane: monodevelop-lion-cycle8-sr0

Operating System
Mac OS X 10.12.1
Darwin Carstens-MBP.local 16.1.0 Darwin Kernel Version 16.1.0
    Thu Oct 13 21:26:57 PDT 2016
    root:xnu-3789.21.3~60/RELEASE_X86_64 x86_64
Comment 38 Carsten Elton Sørensen 2016-11-06 15:41:21 UTC
"Resource.designer.fs" not "Resources.Designer.fs" in Comment 37, sorry.
Comment 39 Jason Imison 2016-11-06 15:43:56 UTC
Hi Carsten, the fix is in XamarinStudio-6.2.0.655

For now you can test the new template here https://github.com/nosami/android-template-test
Comment 40 matt 2016-12-01 04:04:22 UTC
What about Visual Studio 2015? I'm hitting this issue there.
Comment 41 Jason Imison 2016-12-01 10:52:33 UTC
@matt you can use this template temporarily https://github.com/nosami/android-template-test

I'll check the VS templates
Comment 42 Rob Lyndon 2016-12-28 11:35:03 UTC
This is still an issue in Visual Studio 2015. It can be reproduced by cloning the repository https://github.com/SpiegelSoft/Astrid and performing a full rebuild.
Comment 43 Jason Imison 2016-12-29 16:40:46 UTC
@Rob - try my fix https://github.com/nosami/Astrid/commit/b97f2e898aa7fa4681d446c81e385aed3daeda90

I don't have Windows set up right now (and I'm on holiday) - but it _should_ work.
Comment 44 Rob Lyndon 2016-12-30 11:30:31 UTC
Thanks Jason.

I'll fire it up after the New Year, or if I can fit in some holiday development time while my girlfriend isn't looking.

Happy New Year.
-- Rob
Comment 45 Rob Lyndon 2017-01-03 23:59:29 UTC
I added a NuGet reference to Xamarin.Android.FSharp.ResourceProvider, and removed Resource.Designer.fs, and that seemed to do the trick.

Note You need to log in before you can comment on or make changes to this bug.