-
Notifications
You must be signed in to change notification settings - Fork 130
Project Windows Runtime struct fields as C# fields #2505
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
Open
Sergio Pedri (Sergio0694)
wants to merge
6
commits into
staging/3.0
Choose a base branch
from
user/sergiopedri/project-struct-fields-as-fields
base: staging/3.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2985b27
Project Windows Runtime struct fields as C# fields
Sergio0694 406e158
Project manually projected struct fields as C# fields
Sergio0694 b093a9a
Project mapped struct fields as C# fields in addition files
Sergio0694 36a275a
Update docs for struct fields being projected as C# fields
Sergio0694 1ee1f73
Refresh stale comments about mapped struct field layouts
Sergio0694 b1d3a76
Allow negative values in the GridLength constructors
Sergio0694 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using ProjectionWriterTest.Helpers; | ||
|
|
||
| namespace ProjectionWriterTest; | ||
|
|
||
| /// <summary> | ||
| /// Tests for how the projection writer projects the members of Windows Runtime struct types. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// Windows Runtime structs are plain data: their members are fields in metadata, and they must be | ||
| /// projected as C# fields. Projecting them as properties breaks authoring (the WinMD generator only | ||
| /// maps public instance fields back to Windows Runtime struct fields, so an authored struct using | ||
| /// properties would produce an empty struct in metadata), and it prevents callers from taking a | ||
| /// reference to a member. | ||
| /// </remarks> | ||
| [TestClass] | ||
| public class Test_ProjectedStructs | ||
| { | ||
| /// <summary> | ||
| /// Every field of a projected struct is emitted as a public C# field. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// <c>Windows.Foundation.Numerics.Rational</c> is the only non-mapped struct in the projected | ||
| /// namespace, so it is the anchor for both assertions. | ||
| /// </remarks> | ||
| [TestMethod] | ||
| [DataRow(true)] | ||
| [DataRow(false)] | ||
| public void StructFields_AreProjectedAsFields(bool referenceProjection) | ||
| { | ||
| string sources = ProjectionWriterRunner.GetSources(referenceProjection); | ||
|
|
||
| StringAssert.Contains(sources, "public uint Numerator;", "'Rational.Numerator' should be projected as a field."); | ||
| StringAssert.Contains(sources, "public uint Denominator;", "'Rational.Denominator' should be projected as a field."); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// No projected struct member is emitted as an auto-property. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// Guards against a regression to the <c>{ readonly get; set; }</c> form that projected struct | ||
| /// members used to be emitted with. | ||
| /// </remarks> | ||
| [TestMethod] | ||
| [DataRow(true)] | ||
| [DataRow(false)] | ||
| public void StructFields_AreNotProjectedAsProperties(bool referenceProjection) | ||
| { | ||
| string sources = ProjectionWriterRunner.GetSources(referenceProjection); | ||
|
|
||
| Assert.IsFalse(sources.Contains("readonly get; set;"), "Struct members should be projected as fields, not as auto-properties."); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.