Skip to content

Commit 78b492d

Browse files
committed
Workaround for a XAML codegen issue
{x:Bind OneWay} still creates the code to set the bound properties in XamlTypeInfo.g.cs even though that's never actually used. If that property is init-only, that fails to build. Ideally these bindings should just omit those methods entirely.
1 parent 51c6bab commit 78b492d

File tree

3 files changed

+6
-23
lines changed

3 files changed

+6
-23
lines changed

samples/MvvmSample.Core/Models/Post.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public sealed class PostsQueryResponse
1717
/// Gets or sets the listing data for the response.
1818
/// </summary>
1919
[JsonPropertyName("data")]
20-
public PostListing? Data { get; init; }
20+
public PostListing? Data { get; set; }
2121
}
2222

2323
/// <summary>
@@ -29,7 +29,7 @@ public sealed class PostListing
2929
/// Gets or sets the items in this listing.
3030
/// </summary>
3131
[JsonPropertyName("children")]
32-
public IList<PostData>? Items { get; init; }
32+
public IList<PostData>? Items { get; set; }
3333
}
3434

3535
/// <summary>
@@ -41,7 +41,7 @@ public sealed class PostData
4141
/// Gets or sets the <see cref="Post"/> instance.
4242
/// </summary>
4343
[JsonPropertyName("data")]
44-
public Post? Data { get; init; }
44+
public Post? Data { get; set; }
4545
}
4646

4747
/// <summary>
@@ -53,13 +53,13 @@ public sealed class Post
5353
/// Gets or sets the title of the post.
5454
/// </summary>
5555
[JsonPropertyName("title")]
56-
public string? Title { get; init; }
56+
public string? Title { get; set; }
5757

5858
/// <summary>
5959
/// Gets or sets the URL to the post thumbnail, if present.
6060
/// </summary>
6161
[JsonPropertyName("thumbnail")]
62-
public string? Thumbnail { get; init; }
62+
public string? Thumbnail { get; set; }
6363

6464
/// <summary>
6565
/// Gets the text of the post.

samples/MvvmSample.Core/Models/System.Runtime.CompilerServices/IsExternalInit.cs

Lines changed: 0 additions & 17 deletions
This file was deleted.

samples/MvvmSampleUwp/MvvmSampleUwp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
1919
<WindowsXamlEnableOverview>true</WindowsXamlEnableOverview>
2020
<AppxPackageSigningEnabled>false</AppxPackageSigningEnabled>
21-
<LangVersion>8.0</LangVersion>
21+
<LangVersion>9.0</LangVersion>
2222
</PropertyGroup>
2323
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
2424
<DebugSymbols>true</DebugSymbols>

0 commit comments

Comments
 (0)