Skip to content

Add 'Nullable' option to the build property page#5807

Merged
tmeschter merged 3 commits intodotnet:masterfrom
drewnoakes:nullable-property-page
Jan 22, 2020
Merged

Add 'Nullable' option to the build property page#5807
tmeschter merged 3 commits intodotnet:masterfrom
drewnoakes:nullable-property-page

Conversation

@drewnoakes
Copy link
Member

@drewnoakes drewnoakes commented Jan 20, 2020

Fixes #4058.

This option is only available when the language version is 8.0 or greater.


netcoreapp3.1 (LangVersion 8)

image

The dropdown has the following options:

image


net48 (LangVersion 7.3)

The nullable control is disabled:

image

This option is only available when the language version is 8.0 or greater.
@drewnoakes drewnoakes added the Feature-Legacy-Application-Designer The "Application Designer" otherwise known as the legacy project properties label Jan 20, 2020
@drewnoakes drewnoakes added this to the 16.5 milestone Jan 20, 2020
@drewnoakes drewnoakes requested a review from jcouv January 20, 2020 11:00
@drewnoakes drewnoakes requested a review from a team as a code owner January 20, 2020 11:00
@davkean
Copy link
Member

davkean commented Jan 20, 2020

I think we should consider coming up with a way for this property to visible but disabled when changing the TFM will cause it to be enabled.

  • What happens if I choose the Application tab, change from NET Core 2.2 -> 3.0 and then choose this tab?

Copy link
Member

@davidwengier davidwengier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth having a link to an article explaining what the various values mean? If we do the "visible but disabled" thing I think a link explaining why its disabled would be vital.

@drewnoakes
Copy link
Member Author

Changing it to disable rather than hide is straightforward to do, but I felt it would make the UI more confusing for users.

Currently the state of this UI is not updated based on changes to TFM (via either UI or file on disk). The page needs to be reloaded. I looked at PropertyControlData for hints on how to respond to such changes but didn't see anything.

We could justify sticking help links on every UI element on the page. Does this one deserve one just because it's new?

Once the UI here is finalised I'll update the docs.

@davkean
Copy link
Member

davkean commented Jan 20, 2020

We don't hide elements in other cases where changing the TFM would enable it - for example, Prefer 32-bit. Can you see how it reacts when you change from 4.0 -> 4.5 in legacy?

@davidwengier
Copy link
Member

Does this one deserve one just because it's new?

I think this one deserves something because "Enable", "Warnings" and "Annotations" don't mean much on their own.

@drewnoakes
Copy link
Member Author

Updated to respond to changes to LangVersion/TargetFramework, either through the UI or project file.

Also changed to disable rather than hide the UI.

@drewnoakes
Copy link
Member Author

I think this one deserves something because "Enable", "Warnings" and "Annotations" don't mean much on their own.

I think you could argue this about any of the options you weren't familiar with. For example, what does the TRACE constant mean? What's a constant? What does warning level '4' mean?

The property pages support F1 help, though it's not very discoverable and is currently broken (I filed #5815).

@drewnoakes
Copy link
Member Author

Documentation updated in https://github.com/MicrosoftDocs/visualstudio-docs-pr/pull/6024.

Copy link
Contributor

@tmeschter tmeschter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By putting this on the Build properties page you're making this a configuration- and platform-specific setting. Nullable doesn't seem like the kind of setting that you want to behave differently in debug and release builds, for example.

If you want it to be configuration-independent, the best option is the Advanced Build Options dialog.

</data>
<data name="PPG_BuildSettings_Nullable_Annotations" xml:space="preserve">
<value>Annotations</value>
</data>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By placing these values in .resx file we're choosing to localize them. Is that what you want, or would it make more sense to simply use the literal values understood by the compiler?

In the case of the latter you would hard-code them in the source and use the lower-case forms.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The drop down should be localized, what we persist in the project file shouldn't be.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered using the compiler's strings and ended up following the example set by the advanced build properties page (where I initially added this new UI before moving it to the regular build properties page).

image

image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and these were localized in response to a bug.

@davkean
Copy link
Member

davkean commented Jan 21, 2020

The "Advanced Build Options" page is also configuration-dependent. I think you can argue this for lots of options on that page, unsafe code, Prefer 32-bit, etc.

Copy link
Member

@dmonroym dmonroym left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@drewnoakes
Copy link
Member Author

@tmeschter

If you want it to be configuration-independent, the best option is the Advanced Build Options dialog.

To be clear, in this PR the setting behaves in a configuration-independent manner due to HasConfigurationCondition="False" on its data source.

The question is whether this behaviour is surprising to the user or not.

@davkean @davidwengier and I discussed placement on Monday and decided the setting was not really 'advanced', and that it deserved a more prominent position in the UI. So I moved it from the advanced build prop page to the regular build prop page.

But looking at it now I see that every other property on that page is actually configuration-dependent.

I agree that nullable shouldn't be configuration-dependent. It's a shame to hide the option further down, but on balance I think you're right so will move it back 🤦‍♂

@drewnoakes
Copy link
Member Author

drewnoakes commented Jan 22, 2020

Actually it turns out that every setting on the advanced property page is configuration-dependent too. So now I'm less sure that moving it does anything useful.

When language version was editable, it would have been the exception on the two build pages.

We could move it to the application page, but it's not clear it belongs there either.

@tmeschter
Copy link
Contributor

Sorry, I missed HasConfigurationCondition="False" on the data source--I'm so used to thinking about these pages through the lens of the old project system. :-) I agree that with that issue out of the way, the Build page is a much better choice than the Advanced dialog. Approved.

@tmeschter tmeschter merged commit 54d1c68 into dotnet:master Jan 22, 2020
@drewnoakes drewnoakes deleted the nullable-property-page branch January 22, 2020 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature-Legacy-Application-Designer The "Application Designer" otherwise known as the legacy project properties

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for Nullable build setting

5 participants