Skip to content

Port BindingSourceDesigner, BindingNavigatorDesigner to runtime#9749

Merged
SimonZhao888 merged 5 commits intodotnet:mainfrom
SimonZhao888:Issue_4908_Port_BindingNavigatorDesignerAndBindingSourceDesigner
Aug 28, 2023
Merged

Port BindingSourceDesigner, BindingNavigatorDesigner to runtime#9749
SimonZhao888 merged 5 commits intodotnet:mainfrom
SimonZhao888:Issue_4908_Port_BindingNavigatorDesignerAndBindingSourceDesigner

Conversation

@SimonZhao888
Copy link
Copy Markdown
Member

@SimonZhao888 SimonZhao888 commented Aug 18, 2023

Related to #4908

Proposed changes

  • Port BindingSourceDesigner, BindingNavigatorDesigner to runtime.

Customer Impact

  • BindingSourceDesigner can be designed in runtime

Regression?

  • No

Risk

  • Minimal

Screenshots

Before

image

After

BindingSourceDesigner can be designed in runtime.
image

Test methodology

  • Manually (add BindingSourceDesigner to DemoConsole test app)

Accessibility testing

Test environment(s)

  • .Net 8.0.100-rc.1.23377.5
Microsoft Reviewers: Open in CodeFlow

@SimonZhao888 SimonZhao888 requested a review from a team as a code owner August 18, 2023 02:42
@ghost ghost assigned SimonZhao888 Aug 18, 2023
Copy link
Copy Markdown
Contributor

@Tanya-Solyanik Tanya-Solyanik left a comment

Choose a reason for hiding this comment

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

Looks good, I added some style comments only.


private void RaiseItemsChanged()
{
BindingNavigator dn = (BindingNavigator)Component;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please use full words in variable names, i.e. dn -> navigator. Thic comment applies in multiple places in this PR.

Copy link
Copy Markdown
Contributor

@Tanya-Solyanik Tanya-Solyanik left a comment

Choose a reason for hiding this comment

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

I added a couple more style suggestions. Please coordinate your work with @Epica3055 who is editing the same files.

private void RaiseItemsChanged()
{
BindingNavigator navigator = (BindingNavigator)Component;
IComponentChangeService componentChangeSvc = (IComponentChangeService)GetService(typeof(IComponentChangeService));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please don't use abbreviations in variable names, i.e. Svc -> Service. This applies to multiple places in this PR

{
BindingNavigator navigator = (BindingNavigator)Component;

if (item == navigator.MoveFirstItem)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This code would be more readable if you used a switch

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Since navigator.MoveFirstItem etc. are not constants, switch cannot be used here.


if (changeService is not null)
{
if (descriptor is not null)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The 2 if conditions could be combined into a single one to improve readability of this code. And the same applies to if statements below as well.

base.InitializeNewComponent(defaultValues);

BindingNavigator navigator = (BindingNavigator)Component;
IDesignerHost? host = Component?.Site?.GetService(typeof(IDesignerHost)) as IDesignerHost;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The code here could be simpler: IDesignerHost? host = Component?.Site?.GetService();

private void RaiseItemsChanged()
{
BindingNavigator navigator = (BindingNavigator)Component;
IComponentChangeService componentChangeSvc = (IComponentChangeService)GetService(typeof(IComponentChangeService));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The code here could be simpler: IComponentChangeService componentChangeSvc = GetService();

{
MemberDescriptor? itemsProp = TypeDescriptor.GetProperties(navigator)["Items"];
componentChangeSvc.OnComponentChanging(navigator, itemsProp);
componentChangeSvc.OnComponentChanged(navigator, itemsProp, null, null);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Add a variable name prefix to make passing parameters clearer

{
if (descriptor is not null)
{
changeService.OnComponentChanged(bingSource, descriptor, previousDataMember, "");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

"" can be instead of with string.Empty

@SimonZhao888
Copy link
Copy Markdown
Member Author

I added a couple more style suggestions. Please coordinate your work with @Epica3055 who is editing the same files.

Yeah, we will communicate for this.

@SimonZhao888 SimonZhao888 requested a review from LeafShi1 August 23, 2023 07:04
@Epica3055
Copy link
Copy Markdown
Member

looks good ~

@SimonZhao888 SimonZhao888 requested a review from lonitra August 25, 2023 02:06
Copy link
Copy Markdown
Member

@lonitra lonitra left a comment

Choose a reason for hiding this comment

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

LGTM! 👍

@lonitra lonitra added the ready-to-merge PRs that are ready to merge but worth notifying the internal team. label Aug 25, 2023
@SimonZhao888 SimonZhao888 merged commit 52228ae into dotnet:main Aug 28, 2023
@ghost ghost removed the ready-to-merge PRs that are ready to merge but worth notifying the internal team. label Aug 28, 2023
@Philip-Wang01
Copy link
Copy Markdown
Contributor

Philip-Wang01 commented Sep 1, 2023

Verified this PR in main branch, now BindingSourceDesigner is supported in runtime, we can see that the ListBox is already bound to the BindingSource.
test9749

@ghost ghost locked as resolved and limited conversation to collaborators Oct 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants