question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Enhancement] We need a way to see if a property was set (perf & defaults)

See original GitHub issue

Description

Initially this was just an issue for bad padding logic, however, this does expose a bigger issue: we have no way of actually knowing if a property was set.

This has 2 major benefits:

  1. Performance: no use setting a value to the default when not doing anything is cheaper
  2. Default: if nothing was set, then we are using default

An added bonus is if there is a way to unset a value and revert to OS defaults.

Maybe this is as simple as having a nullable properties on IView:

interface IView
{
    Thickness? Padding { get; }
    IBrush? Background { get; }
}

**SEMI-OLD COMMENT**

```csharp
interface IView
{
    IBrush Background { get; }
    Thickness Padding { get; }
    bool IsSet(string property);
}

The default implementation for say Controls could be:

class View : IView
{
    BindableProperty BackgroundProperty = BindablePropert.Create();
    IBrush Background => GetValue(BackgroundProperty);
    Thickness Padding => GetValue(PaddingProp);
    bool IsSet(string property)
    {
        if (property == BackgroundProperty.Name)
            return IsSet(BackgroundProperty);
        return true;
    }
}

OLD COMMENT

Button padding logic is incorrect.

On iOS, there is no default padding so this is not an issue. On Windows and Android, there is a default padding based on various factors. Windows is just a nice padding, but Android has this related to the drawable. However, since we implemented padding, all this goes away and we just wing it. Android ignores the padding, and since we always set it, there is never any padding. Windows tried to keep it as a base, but now we will always have a padding - even when set to 0.

Not sure what the solution is here, since all we have is a double and all values are valid - unless we say that all padding >= 0 and thus a negative padding == default? Will this break old renderers? Is a negative padding valid - like the content must hang over the edge of the control? If we go with -1 == default and somebody doesn’t like it, they can always override this method…

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Clanceycommented, Apr 6, 2021

Comet uses nulls. If null, reset the value. I am not a fan of IsSet(string property) All of our structs have a default value as well. If not, lets make them nullable.

1reaction
mattleibowcommented, Apr 6, 2021

I also realise that padding is a Thickness, so we could add a NaN just like there is for Zero. And if you want a default for just one side, you can set that. This will also work for things like corner radius and pretty much most things 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Linux perf Examples
Start by adding that, then running "perf" to see if you get the USAGE message. ... These may work by default in your...
Read more >
Get acquainted with HDRP settings for enhanced ...
Learn how to leverage High Definition Render Pipeline (HDRP) settings to maximize performance and achieve powerful graphics all at once.
Read more >
Manage 3D Settings (reference)
Manage 3D Settings. The Manage 3D Settings page enables you to. Establish default 3D settings to use for all your Direct3D or OpenGL...
Read more >
Intel Core i9 13900K: Impact of MultiCore Enhancement ...
The question we want to answer is twofold: What kind of performance are we giving up by disabling this auto-overclocking, and what impact...
Read more >
Optimize your build speed | Android Studio
The easiest way to determine the optimal heap size is to increase the limit by a small amount and then test for sufficient...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found