Skip to content

Changes to fix issues in DemoConsole#9419

Merged
dreddy-work merged 12 commits intodotnet:mainfrom
elachlan:Fix-DemoConsole
Jul 7, 2023
Merged

Changes to fix issues in DemoConsole#9419
dreddy-work merged 12 commits intodotnet:mainfrom
elachlan:Fix-DemoConsole

Conversation

@elachlan
Copy link
Contributor

@elachlan elachlan commented Jul 4, 2023

Fixes #9412
Fixes #9416
Fixes #9420
Fixes #9389

Microsoft Reviewers: Open in CodeFlow

@elachlan elachlan requested a review from a team as a code owner July 4, 2023 07:07
@ghost ghost assigned elachlan Jul 4, 2023
@elachlan
Copy link
Contributor Author

elachlan commented Jul 4, 2023

CC: @Tanya-Solyanik

@elachlan
Copy link
Contributor Author

elachlan commented Jul 4, 2023

@MelonWang1 can you please test this?

@MelonWang1
Copy link
Contributor

@elachlan The two issues have been fixed, PictureBox can resize and add image successfully, and the most controls delete, undo, redo function use well.

fix.mp4

Except SplitContainer control cannot be deleted.

splitcontainer.mp4

@elachlan
Copy link
Contributor Author

elachlan commented Jul 4, 2023

Could you please create a separate issue for the SplitContainer not being able to be deleted?

@elachlan
Copy link
Contributor Author

elachlan commented Jul 4, 2023

image
This is the exception when you try and delete the splitcontainer. I'll look into it.

@MelonWang1
Copy link
Contributor

@elachlan Verified new commit, the SplitContainer control can delete, but an exception occurs when delete SplitContainer.Panel.

splitpanel.mp4

@MelonWang1
Copy link
Contributor

@elachlan I'm sorry I did not clearly description this. The SplitContainer.Panel should not be removed when click delete keyboard. In winforms .NET framework application, the behavior is the SplitContainer.Panel cannot be removed.

framework.mp4

@elachlan
Copy link
Contributor Author

elachlan commented Jul 4, 2023

I imagine we just need to not process it when a split panel is selected.

@dmitrii-drobotov
Copy link
Contributor

Great job @elachlan! Regarding SplitterPanel delete — I think it's a bug on application side. In VS Designer delete command is disabled:
image
But in DemoConsole app commands are invoked without status check:

IMenuCommandService ims = GetService(typeof(IMenuCommandService)) as IMenuCommandService;
try
{
switch (command.ToUpper())
{
case "CUT":
ims.GlobalInvoke(StandardCommands.Cut);
break;
case "COPY":
ims.GlobalInvoke(StandardCommands.Copy);
break;
case "PASTE":
ims.GlobalInvoke(StandardCommands.Paste);
break;
case "DELETE":
ims.GlobalInvoke(StandardCommands.Delete);
break;

We can update this part to include a condition for MenuCommand.Enabled, then the delete command won't do anything for splitter panel because it would have Enabled as false:

CommandID? commandId = command.ToUpper() switch
{
    "CUT" => StandardCommands.Cut,
    "COPY" => StandardCommands.Copy,
    "PASTE" => StandardCommands.Paste,
    "DELETE" => StandardCommands.Delete,
    _ => null,
};

if (commandId is not null)
{
    MenuCommand? menuCommand = ims?.FindCommand(commandId);
    if (menuCommand?.Enabled is true)
    {
        menuCommand.Invoke();
    }
}

@elachlan
Copy link
Contributor Author

elachlan commented Jul 5, 2023

@Nora-Zhou01 can you also verify #9389 is fixed please?

@Nora-Zhou01
Copy link
Contributor

@elachlan 9389 This issue is fixed and the item is displayed again after adding an item to ComboBox in DemoConsole application.

9419.mp4

public void Remove(Glyph value)
{
List.Remove(value);
if (List.Contains(value))
Copy link
Contributor Author

@elachlan elachlan Jul 5, 2023

Choose a reason for hiding this comment

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

This was because remove was throwing exceptions. But the exceptions were caught further up. Up to the team if they are happy with the exception.

Copy link
Member

Choose a reason for hiding this comment

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

@elachlan, Did you find a scenario where we are trying to call remove for a glyph that wasn't added to collection?

This change should be good.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it would have been when deleting and then performing an "undo" (I think). Do you want a debug.assert for when the value isn't in the list?

Copy link
Member

Choose a reason for hiding this comment

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

If it is a valid scenario, i would put a comment about it. Debug assert will be annoying for a valid scenario.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added comment.

Copy link
Member

@dreddy-work dreddy-work left a comment

Choose a reason for hiding this comment

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

thanks @elachlan for taking a look at these. Added comments and questions.

}

return _mergedMetadata.GetEnumerator();
return _mergedMetadata?.GetEnumerator();
Copy link
Member

Choose a reason for hiding this comment

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

can you enable nullability on this file or is it a big change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its a big change I think. I'd rather have it done in another PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@halgab / @gpetrou did either of you want to tackle null annotating ResourceCodeDomSerializer.SerializationResourceManager.cs?

Copy link
Contributor

Choose a reason for hiding this comment

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

I was waiting for #9099 to be merged to tackle CodeDomSerializer and then derived classes, but I can take care of this one file after this PR merges for sure

Copy link
Contributor

Choose a reason for hiding this comment

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

Here it is: #9457

public void Remove(Glyph value)
{
List.Remove(value);
if (List.Contains(value))
Copy link
Member

Choose a reason for hiding this comment

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

@elachlan, Did you find a scenario where we are trying to call remove for a glyph that wasn't added to collection?

This change should be good.

@dreddy-work dreddy-work added the waiting-author-feedback The team requires more information from the author label Jul 5, 2023
Tanya-Solyanik
Tanya-Solyanik previously approved these changes Jul 5, 2023
@ghost ghost removed the waiting-author-feedback The team requires more information from the author label Jul 5, 2023

public override string? ToString()
{
return Item.ToString();
Copy link
Contributor

@RussKie RussKie Jul 6, 2023

Choose a reason for hiding this comment

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

❗ This can NRE

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should it be Item.ToString()!?

Copy link
Contributor Author

@elachlan elachlan Jul 6, 2023

Choose a reason for hiding this comment

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

wait, Item.ToString() ?? string.Empty;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This has nullable types enabled and object is marked as non-nullable. So it shouldn't NRE?

Copy link
Contributor

Choose a reason for hiding this comment

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

This has nullable types enabled and object is marked as non-nullable. So it shouldn't NRE?

Item = null! 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

If we know for sure Item can't be a null then I retract my comment :)

@elachlan elachlan dismissed stale reviews from Tanya-Solyanik and dmitrii-drobotov via 2999908 July 6, 2023 03:05
@elachlan
Copy link
Contributor Author

elachlan commented Jul 6, 2023

I've done some refactoring based on the feedback. Hopefully that covers what people were worried about.

@dreddy-work dreddy-work added the ready-to-merge PRs that are ready to merge but worth notifying the internal team. label Jul 6, 2023
@dreddy-work dreddy-work merged commit 8a55875 into dotnet:main Jul 7, 2023
@ghost ghost added this to the 8.0 Preview7 milestone Jul 7, 2023
@ghost ghost removed the ready-to-merge PRs that are ready to merge but worth notifying the internal team. label Jul 7, 2023
@elachlan elachlan deleted the Fix-DemoConsole branch July 21, 2023 23:40
@ghost ghost locked as resolved and limited conversation to collaborators Aug 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

9 participants