Skip to content

DependencyObject is interface #25

Closed

Description

@queequac

In assembly Uno.UI, Windows.UI.Xaml.DependencyObject is defined as an interface. This is different from regular UWP, where DependencyObject is a class being derived from interfaces IDependencyObject and IDependencyObject2.

I have classes derived from DependencyObject and this prevents code-sharing between UWP and my evaluation port.

Any specific reason for doing so and violating UWP naming conventions? In the first place I did not even realize this is just an interface in Uno...

Activity

  1. jeromelaban commented on Jun 5, 2018

    @jeromelaban
    Member

    DependencyObject is an interface to give the ability for Xaml controls to inherit directly from native controls, for performance reasons.

    That being said, there should not be any significant issue from porting code that uses DependencyObject, aside from where DependencyObject is used a generic constraint.

    Do you use UWP's IDependencyObject and IDependencyObject2, and if so why ?

  2. queequac commented on Jun 5, 2018

    @queequac
    Author

    I have classes being derived directly from DependencyObject, to be used in Xaml just like Behaviors.

  3. jeromelaban commented on Jun 5, 2018

    @jeromelaban
    Member

    Then it should be supported without any difference. Inherit from DependencyObject like you would in UWP, the code generator will fill the gaps.

    You'll notice that Intellisense will flag the interface as not implemented until you build the first time, then the warning should go away.

    This is a known VS limitation that you can address using this: https://github.com/nventive/Uno.SourceGeneration#generated-code--intellisense

  4. queequac commented on Jun 5, 2018

    @queequac
    Author

    Thanks for pointing this out! Was completely unaware of this. :)

  5. queequac commented on Jun 5, 2018

    @queequac
    Author

    Just one more questions: Do I have to make my classes partial then?
    I can see that the intellisense no more flags the DependencyObject related issues, but the build fails

    error CS0260: Missing partial modifier on declaration of type 'XY'; another partial declaration of this type exists

    If I add the partial modifier, it compiles without any errors.

  6. jeromelaban commented on Jun 5, 2018

    @jeromelaban
    Member

    Correct, I missed that part in my original answer. The only way for the generator to fill the gaps is through partial classes. This change is transparent for UWP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions