Reputation: 660
I downloaded a Github project and upon opening it in VS 2012 an automatic upgrade took place. I am getting an error that I do not understant. It is related to quotations.
This is the file which I copy pasted below: https://github.com/dmitry-a-morozov/fsharp-wpf-mvc-series/blob/master/Chapter%2012%20-%20BindingMicroDSL/BindingMicroDSL/StockPricesChart.fs
The error is "A quotation may not involve an assignment to or taking the address of a captured local variable"
The offending codes are this key and value:
this.Control.DetailsName, <@@ stockProperty.Key @@>
this.Control.DetailsValue, <@@ stockProperty.Value @@>
namespace FSharp.Windows.Sample
open System.Windows.Data
open System.Drawing
open System.Windows.Forms.DataVisualization.Charting
open System.Collections.ObjectModel
open FSharp.Windows
open FSharp.Windows.UIElements
[<AbstractClass>]
type StockPricesChartModel() =
inherit Model()
abstract StocksInfo : ObservableCollection<StockInfoModel> with get, set
abstract SelectedStock : StockInfoModel with get, set
type StockPricesChartView(control) as this =
inherit PartialView<unit, StockPricesChartModel, StockPricesChartControl>(control)
do
let area = new ChartArea()
area.AxisX.MajorGrid.LineColor <- Color.LightGray
area.AxisY.MajorGrid.LineColor <- Color.LightGray
this.Control.StockPricesChart.ChartAreas.Add area
let series =
new Series(
ChartType = SeriesChartType.Column,
Palette = ChartColorPalette.EarthTones,
XValueMember = "Symbol",
YValueMembers = "LastPrice")
this.Control.StockPricesChart.Series.Add series
override this.EventStreams =
[
this.Control.AddStock.Click |> Observable.mapTo()
]
override this.SetBindings model =
this.Control.StockPricesChart.DataSource <- model.StocksInfo
model.StocksInfo.CollectionChanged.Add(fun _ -> this.Control.StockPricesChart.DataBind())
this.Control.Symbol.SetBindings(
itemsSource = <@ model.StocksInfo @>,
selectedItem = <@ model.SelectedStock @>,
displayMember = <@ fun m -> m.Symbol @>
)
this.Control.Details.SetBindings(
itemsSource = <@ model.SelectedStock.Details @>,
////////////////// OFFENDING CODE ///////////////////
columnBindings = fun stockProperty ->
[
this.Control.DetailsName, <@@ stockProperty.Key @@>
this.Control.DetailsValue, <@@ stockProperty.Value @@>
]
)
type StockPricesChartController() =
inherit Controller<unit, StockPricesChartModel>()
override this.InitModel model =
model.StocksInfo <- ObservableCollection()
override this.Dispatcher = fun() ->
Async <| fun model ->
async {
let! result = Mvc.startWindow(StockPickerView(), StockPickerController())
result |> Option.iter(fun newItem ->
model.StocksInfo.Add newItem
model.SelectedStock <- newItem
)
}
Upvotes: 0
Views: 308
Reputation: 170
It's breaking change in F# 3.0 http://msdn.microsoft.com/en-us/library/hh416791.aspx As Leaf Garland pointed it's not direct answer to your question but have a look at upgraded to VS 2012 code https://github.com/dmitry-a-morozov/fsharp-wpf-mvc-series/wiki/Visual-Studio-2012
Upvotes: 5