Visual Studio Preview 9 (7.0 build 2943)
Xcode 8.3.2 (8E2002)
I have a set of generic classes which encapsulate a bunch of NSTable code
For example, there's a NSGeneralSingleSelectionTableView which displays a collection of T and allows the selection of a single item, for which there's
public event EventHandler SelectionChanged;
The code NSGeneralSingleSelectionTableView is pretty simple (the entire thing appears below).
In debug mode, this works exactly as I expect.
When I built in release mode, though, I get a System.NotSupportedException on the line this.DataSource = _dataSource; (exception output also included below)
Suggestions?
public class NSGeneralSingleSelectionTableView<T> : NSTableView where T : class
{
private readonly NSGeneralTableSpecification<T> TableSpecification;
private IReadOnlyList<T> _dataset;
private NSGeneralTableDataSource<T> _dataSource;
private NSGeneralTableDelegate<T> _tableDelegate;
public NSGeneralSingleSelectionTableView(NSGeneralTableSpecification<T> tableSpec)
{
this.TableSpecification = tableSpec;
foreach (NSTableColumn column in this.TableSpecification.ColumnSpecifications) {
this.AddColumn(column);
}
_dataset = null;
_dataSource = new NSGeneralTableDataSource<T>();
_tableDelegate = new NSGeneralTableDelegate<T>(this.TableSpecification.SetCellContent);
this.DataSource = _dataSource;
this.Delegate = _tableDelegate;
this.SelectionHighlightStyle = NSTableViewSelectionHighlightStyle.None;
this.AllowsColumnResizing = true;
this.AllowsColumnSelection = false;
this.AllowsMultipleSelection = false;
this.DoubleClick += (sender, e) => {
this.DoubleClicked?.Invoke(this, this.CurrentSelection);
};
_tableDelegate.SelectionChanged += (sender, e) => {
this.SelectionChanged?.Invoke(this, this.CurrentSelection);
};
}
public event EventHandler<T> DoubleClicked;
public event EventHandler<T> SelectionChanged;
private T CurrentSelection
{
get { return (_dataset == null ? null : _dataset[(int)(this.SelectedRow)]); }
}
public void SetDataset(IReadOnlyList<T> dataset)
{
_dataset = dataset;
_dataSource.SetDataset(_dataset);
_tableDelegate.SetDataset(_dataset);
this.ReloadData();
}
private class DataSourceClass : NSGeneralTableDataSource<T> { }
}
And the exception thrown:
Unhandled Exception:
System.NotSupportedException: Specified method is not supported.
at ObjCRuntime.Runtime.get_generic_method_from_token (System.IntPtr obj, System.UInt32 token_ref, System.Int32& exception_gchandle) [0x00005] in <223ccc77178f474cb3428fd6ae894e8b>:0
--- End of stack trace from previous location where exception was thrown ---
at (wrapper managed-to-native) ObjCRuntime.Messaging:void_objc_msgSendSuper_IntPtr (intptr,intptr,intptr)
at AppKit.NSTableView.set_WeakDataSource (Foundation.NSObject value) [0x0005c] in <223ccc77178f474cb3428fd6ae894e8b>:0
at AppKit.NSTableView.set_DataSource (AppKit.INSTableViewDataSource value) [0x0002f] in <223ccc77178f474cb3428fd6ae894e8b>:0
at TBS.MacOSKit.NSGeneralSingleSelectionTableView`1[T]..ctor (TBS.MacOSKit.NSGeneralTableSpecification`1[T] tableSpec) [0x0005a] in <092d2c96c98743ad886f86b7e91d0f00>:0
at TBS.MacViewOutstanding.PlayerListWindowView.InstantiateSubviews () [0x00007] in <092d2c96c98743ad886f86b7e91d0f00>:0
at TBS.MacViewOutstanding.PlayerListWindowView.InitializeLayout () [0x00000] in <092d2c96c98743ad886f86b7e91d0f00>:0
at TBS.MacViewOutstanding.PlayerListWindowView..ctor (CoreGraphics.CGRect frame) [0x0000d] in <092d2c96c98743ad886f86b7e91d0f00>:0
at TBS.MacViewOutstanding.PlayerListWindowController..ctor (ReportBuilderDataManager dataManager) [0x0005b] in <092d2c96c98743ad886f86b7e91d0f00>:0
at TBS.MacViewOutstanding.AppDelegate.DidFinishLaunching (Foundation.NSNotification notification) [0x00074] in <092d2c96c98743ad886f86b7e91d0f00>:0
at (wrapper managed-to-native) AppKit.NSApplication:NSApplicationMain (int,string[])
at AppKit.NSApplication.Main (System.String[] args) [0x0003d] in <223ccc77178f474cb3428fd6ae894e8b>:0
at TBS.MacViewOutstanding.MainClass.Main (System.String[] args) [0x0000a] in <092d2c96c98743ad886f86b7e91d0f00>:0