Steps to reproduce:
- Open Visual Studio 2017 with latest update.
- Create a UWP project targetin 10240 (this is not mandatory, it's broken in all builds)
- Install
System.Memory
from nuget packages (click include prerelease) Copy paste this code in to MainPage.cs
private void MainPage_Loaded(object sender, RoutedEventArgs e) { void Recursive(ReadOnlySpan<char> param) { if (param.Length == 0) return; tx1.Text += Environment.NewLine; tx1.Text += new string(param.ToArray()); Recursive(param.Slice(1)); } ReadOnlySpan<char> mySpan = "Why things are always broken in Visual Studio".AsSpan(); Recursive(mySpan); }
Copy paste this to MainPage.xaml
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <TextBlock x:Name="tx1" HorizontalAlignment="Left" FontSize="48" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top"/> </Grid>
Switch from Debug to Release x64 and make sure "Compile with .Net Native tool chain".
Click Play.
Receive this error:
------ Build started: Project: App12, Configuration: Release x64 ------
App12 c:\Users\myuser\documents\visual studio 2017\Projects\App12\App12\bin\x64\Release\App12.exe
Processing application code
C:\Users\myuser.nuget\packages\microsoft.net.native.compiler\1.7.3\tools\Microsoft.NetNative.targets(697,5): error : Internal compiler error: Object reference not set to an instance of an object.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Deploy: 0 succeeded, 0 failed, 0 skipped ==========
What I'm doing wrong? This works in Debug and release without .NET Native. Thanks.
Span<T>
and friends", how did you get to that conclusion? Does it compile if you remove those references? What about without recursion? – Enterpriserchar[]
type? – Ultrasound