Terminal.Gui icon indicating copy to clipboard operation
Terminal.Gui copied to clipboard

Border: Class uses `string` for `title`, not `ustring`

Open tig opened this issue 3 years ago • 7 comments
trafficstars

image

In addition, strings (both string and ustring) should be initizlied to .Empty and not null.

Fixing this may be a breaking change.

tig avatar Jun 17 '22 16:06 tig

But you are having some issue with this? If so, then you can do ustring.Make(title) that return a ustring.

BDisp avatar Jun 17 '22 17:06 BDisp

But you are having some issue with this? If so, then you can do ustring.Make(title) that return a ustring.

Yes. In tests Assert.Equal((ustring)null, (string)null) causes an exception because Assert.Equal is not supposed to be used for checking null.

tig avatar Jun 17 '22 17:06 tig

Why not adding it in the NStack? Do you want I do that?

BDisp avatar Jun 17 '22 17:06 BDisp

Why not adding it in the NStack? Do you want I do that?

I believe:

  1. Classes should always explicitly initialize members (so private type foo is BAD and private type foo = bar is good.
  2. strings (both string and ustring) should always be initialized to .Empty instead of null.

Changing Nstack to do this encourages bad developer behavior. So no, I don't think you should do this to NStack.

tig avatar Jun 17 '22 17:06 tig

In addition, strings (both string and ustring) should be initizlied to .Empty and not null.

we cant initialize with a default string.Empty, see the error:

imagem

BDisp avatar Jul 30 '22 15:07 BDisp

we cant initialize with a default string.Empty, see the error:

You could do

public TopLevelContainer (Border border, string title = null)
{
    Initialize(Rect.Empty,border, title ?? string.Empty);
}

tznind avatar Jul 31 '22 06:07 tznind

@tig does this issue can be closed per #1862?

BDisp avatar Aug 02 '22 12:08 BDisp