Skip to content
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

Restoring drivers with the structural changes. #3844

Merged
merged 156 commits into from
Nov 26, 2024

Conversation

BDisp
Copy link
Collaborator

@BDisp BDisp commented Nov 23, 2024

Fixes

  • Fixes #_____

Proposed Changes/Todos

  • Todo 1

Pull Request checklist:

  • I've named my PR in the form of "Fixes #issue. Terse description."
  • My code follows the style guidelines of Terminal.Gui - if you use Visual Studio, hit CTRL-K-D to automatically reformat your files before committing.
  • My code follows the Terminal.Gui library design guidelines
  • I ran dotnet test before commit
  • I have made corresponding changes to the API documentation (using /// style comments)
  • My changes generate no new warnings
  • I have checked my code and corrected any poor grammar or misspellings
  • I conducted basic QA to assure all features are working

BDisp and others added 30 commits October 15, 2024 19:17
@BDisp
Copy link
Collaborator Author

BDisp commented Nov 23, 2024

SetupFakeDriver still having issue. I'll try look at it.

  Passed Terminal.Gui.LayoutTests.DimAutoTests.With_Subview_And_Subview_Using_PosAnchorEnd(minWidth: 0, maxWidth: 0, minHeight: 0, maxHeight: 0, expectedWidth: 0, expectedHeight: 0) [< 1 ms]
  Failed Terminal.Gui.LayoutTests.DimAutoTests.With_Subview_Using_PosFunc [1 ms]
  Error Message:
   Assert.Equal() Failure: Values differ
Expected: 25
Actual:   20
  Stack Trace:
     at Terminal.Gui.LayoutTests.DimAutoTests.With_Subview_Using_PosFunc() in D:\a\Terminal.Gui\Terminal.Gui\UnitTests\View\Layout\Dim.AutoTests.PosTypes.cs:line 647
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)

Test Run Failed.
Total tests: 4895
     Passed: 4886
     Failed: 1
    Skipped: 8
 Total time: 1.2931 Minutes

@tig
Copy link
Collaborator

tig commented Nov 23, 2024

SetupFakeDriver still having issue. I'll try look at it.

  Passed Terminal.Gui.LayoutTests.DimAutoTests.With_Subview_And_Subview_Using_PosAnchorEnd(minWidth: 0, maxWidth: 0, minHeight: 0, maxHeight: 0, expectedWidth: 0, expectedHeight: 0) [< 1 ms]
  Failed Terminal.Gui.LayoutTests.DimAutoTests.With_Subview_Using_PosFunc [1 ms]
  Error Message:
   Assert.Equal() Failure: Values differ
Expected: 25
Actual:   20
  Stack Trace:
     at Terminal.Gui.LayoutTests.DimAutoTests.With_Subview_Using_PosFunc() in D:\a\Terminal.Gui\Terminal.Gui\UnitTests\View\Layout\Dim.AutoTests.PosTypes.cs:line 647
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)

Test Run Failed.
Total tests: 4895
     Passed: 4886
     Failed: 1
    Skipped: 8
 Total time: 1.2931 Minutes

I think I fixed this in #3841.

@BDisp
Copy link
Collaborator Author

BDisp commented Nov 23, 2024

I think I fixed this in #3841.

But I think the failure also happened after I merged your PR.

@tznind
Copy link
Collaborator

tznind commented Nov 24, 2024

I have created a PR into this @BDisp that adds IConsoleDriver interface

BDisp#209

Fixes #3846

@BDisp
Copy link
Collaborator Author

BDisp commented Nov 24, 2024

I have created a PR into this @BDisp that adds IConsoleDriver interface

BDisp#209

Fixes #3846

Thanks for that, I'll take a look. Does it also not going to cause conflicts with #3791 anymore?

@tznind
Copy link
Collaborator

tznind commented Nov 24, 2024

There will still be conflicts with ansi-parser but adding interface will not substantially increase the number of conflicts. The two are seperate issues.

@BDisp
Copy link
Collaborator Author

BDisp commented Nov 24, 2024

An abstract class doesn't act like an interface? The difference is that an abstract can have common code on it and the interface only can have declarations. Can you explain better because what I see is duplicated declarations on both files, ConsoleDriver and IConsoleDriver. But for sure it's escape me something. Thanks.

@tznind
Copy link
Collaborator

tznind commented Nov 24, 2024

An abstract class doesn't act like an interface? The difference is that an abstract can have common code on it and the interface only can have declarations. Can you explain better because what I see is duplicated declarations on both files, ConsoleDriver and IConsoleDriver. But for sure it's escape me something. Thanks.

Interface allows me to have 'composition' instead of inheritance

This is my new 'driver', I have split everything up into classes. In order to work with all the classes views etc in Terminal.Gui I have look like a driver without actually being one. I will write a 'facade' that implements IConsoleDriver and returns from properties etc all the bits out of my larger network of classes.

Also interfaces are essential even when there is an abstract class because it allows Moq in tests e.g. you pass a Moq driver to a view and assert view called various members on it (draw, layout etc) without having to deal with overheads of test classes like FakeDriver etc.

It also lets you write simple tests like "swithching tab when only 1 tab should not cause layout (assert method not called on mock)

389207793-8d9f790c-6c74-49fb-aa67-6530d791fcce

@BDisp
Copy link
Collaborator Author

BDisp commented Nov 24, 2024

I am more than clear. Thank you.

@tig
Copy link
Collaborator

tig commented Nov 25, 2024

CursesDriver has an issue with the Force16Colors that also happens in the v2_develop. Did you already see this @tig?

![WindowsTerminal_whokTx0eEl](https://private-user-images.githubusercontent.com/13117724/389212113-063ac302-c4c1-4603-9d49-6760f73786a7.gif?

nope.

@BDisp
Copy link
Collaborator Author

BDisp commented Nov 25, 2024

nope.

I confirm that this issue doesn't repro anymore and I really don't know how it was fixed because it also was reproducing in the v2_develop. Fortunately it's good now. Thanks for the feedback.

@tig
Copy link
Collaborator

tig commented Nov 25, 2024

nope.

I confirm that this issue doesn't repro anymore and I really don't know how it was fixed because it also was reproducing in the v2_develop. Fortunately it's good now. Thanks for the feedback.

It's possible that it's still there and just requires the unit tests to run in a particular order to cause. We have many unit tests that set static variables on Application and ConfigurationManager and don't call Applicaton.ResetState() or CM.Reset which cause these sort of issues.

@tig
Copy link
Collaborator

tig commented Nov 25, 2024

Is this PR ready for review/merge?

@BDisp
Copy link
Collaborator Author

BDisp commented Nov 25, 2024

Is this PR ready for review/merge?

Yes.

Copy link
Collaborator

@tig tig 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 possible to make IConsoleDriver internal and not public.

I feel pretty strongly that "ConsoleDriver" is an IMPLEMENTATION DETAIL of Application and View and should NOT be exposed as a public API.

I worked hard to fix about 80% of the cases where built-in Views and were using ConsoleDriver directly. I want to make it 100% before we ship v2.

Terminal.Gui/Application/MainLoop.cs Show resolved Hide resolved
Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs Show resolved Hide resolved
Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs Show resolved Hide resolved
@tig
Copy link
Collaborator

tig commented Nov 26, 2024

Thank you 10000x for doing this. I really appreciate it. See my review comments.

Copy link
Collaborator

@tig tig left a comment

Choose a reason for hiding this comment

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

docs/drivers.md is way out of date now. But we just just wait to make it right until after @tznind is done with his epic driver project.

@tig tig merged commit 92c546e into gui-cs:v2_develop Nov 26, 2024
3 of 4 checks passed
@BDisp BDisp deleted the v2_3767_restoring-drivers-and-fixes branch November 26, 2024 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants