Xamarin/Android: F# scoping - how do I see a namespace in a different file?
I know this sounds really basic, but I can't seem to get it to work. I will illustrate with an example:
I start a new solution, I select a new F# Android App and call it FSScopeTest1, giving me MainActivity.fs
namespace FSScopeTest1
open System
open Android.Content
open Android.OS
open Android.Runtime
open Android.Views
open Adroid.Widget
[<Activity (Label = "FSScopeTest1", MainLauncher = true)>]
type MainActivity () =
inherit Activity ()
let mutable count:int = 1
override this.OnCreate (bundle) =
base.OnCreate (bundle)
// Set our view from the "main" layout resource
this.SetContentView (Resource_Layout.Main)
// Get our button from the layout resource, and attach an event to it
let button = this.FindViewById<Button>(Resource_Id.myButton)
button.Click.Add (fun args ->
button.Text <- sprintf "%d clicks" count
count <- count + 1
)
I then add a new F# Source file, ScopeTestNS.fs
namespace ScopeTestNS
module ScopeTestMod =
let astr = "some text"
I then add to MainActivity.fs, on the second line:
open ScopeTestNS
and change the lamba expression for button.Click.Add to read
button.Click.Add (fun args ->
// button.Text <- sprintf "%d clicks!" count
// count <- count + 1
button.Text <- ScopeTestMod.astr
)
now, when I build the solution, I get the error:
The namespace or module "ScopeTestMod" is not defined.
How do I make my namespace ScopeTestNS visible in MainActivity.fs so I can see any modules I define there?
Many thanks, Ross