Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot change certain Editor.Options when the TestApp is compiled with .NET Native toolchain #49

Closed
WelterDevelopment opened this issue Jun 16, 2020 · 5 comments
Milestone

Comments

@WelterDevelopment
Copy link

Steps to reproduce:

  1. Add a toggle button to the ItemsControl in MainPage.xaml in the TestApp:
<Button Content="Line Numbers" Click="Numbers_Click" />
  1. Add the click event handler to MainPage.xaml.cs:
private void Numbers_Click(object sender, RoutedEventArgs e)
{
    options.LineNumbers = options.LineNumbers == LineNumbersType.On ? LineNumbersType.Off : LineNumbersType.On;
}
  1. Run the TestApp without compiling with the .NET Native toolchain. Clicking the button a few times will toggle the line numbers on and off as expected.
  2. Run the TestApp with compiling with the .NET Native toolchain. Now you see that reenabling the line numbers will not work, so they disappeared permanently.

This issue also occurs e.g. with Editor.Options.WordWrap and maybe even for more Editor.Options. I have not tested them all.
And turning off the .NET Native Compiler is of course not an option since all UWP apps you want to submit to the Microsoft Store need to be compiled with this toolchain.

@WelterDevelopment WelterDevelopment changed the title Cannot change certain Editor.Options when the TestApp is compiled with .NET toolchain Cannot change certain Editor.Options when the TestApp is compiled with .NET Native toolchain Jun 16, 2020
@WelterDevelopment
Copy link
Author

There is some rd.xml madness going on and I could not find any clue in the documentation on how to solve this. <Namespace Name="Monaco.Editor" Serialize="All" Dynamic="All"/> does not seem to work with JsonConverters (like LineNumbersTypeConverter). A quick workaround for me was to reset the LineNumbers Property back to the old string type in IEditorOptions:

 [JsonProperty("lineNumbers", NullValueHandling = NullValueHandling.Ignore)]
 string LineNumbers { get; set; }

@hawkerm
Copy link
Owner

hawkerm commented Jul 8, 2020

Thanks for digging in and finding the cause @WelterDevelopment. There may be some rd.xml stuff we can do in the component, I'll have to take a look.

@hawkerm hawkerm added this to the v0.9-beta milestone Jul 8, 2020
@hawkerm
Copy link
Owner

hawkerm commented Oct 26, 2021

I've added toggling this option in the sample app. I can see what you see in Release mode that it's updating on the C# side, but then just being turned off in the Monaco editor (and never turning back on); even though it's fine in Debug.

It's fine up until the point of serialization. I'm going to try debugging on the script side now to see what might be going on there on the receiving end to confirm.

@hawkerm
Copy link
Owner

hawkerm commented Oct 26, 2021

Ok, from the script side it's still getting called to update, but in Debug it's getting passed the string value like "on", "off", "relative", etc... In Release mode it's being passed an int like 0, 1, 2 instead... 🤔

@hawkerm
Copy link
Owner

hawkerm commented Oct 26, 2021

For whatever reason it seems like Json.NET can't infer the JsonTypeConverter defined from the interface itself. If I declare the converter on the property, it works fine... No idea why. For now will just declare on property as well as that should resolve the issue.

hawkerm added a commit that referenced this issue Oct 26, 2021
…onverter when running in .NET Native

No idea why the existing declaration on the interface isn't being used/picked-up properly and ignored by Json.NET... config issue or quirk?
@hawkerm hawkerm closed this as completed Oct 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants