xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.62k stars 1.87k forks source link

[Bug] Member not found on parent interface in Xaml #14031

Open AutumnEvans418 opened 3 years ago

AutumnEvans418 commented 3 years ago

Description

If a member of an interface is defined on the parent interface, it does not show up in the intellisense.

Steps to Reproduce

  1. Create an interface (A) with one member
  2. Create another interface (B) that inherits the one above
  3. Create a DataTemplate with DataType=B
  4. Add a binding to the member on interface A and you'll see the error
public interface A
{
    string Name { get; set; }
}
public interface B : A
{

}
<DataTemplate x:DataType="local:B">
    <Label Text="{Binding Name}"/>
</DataTemplate>

Expected Behavior

I expected it to find my member on the parent interface.

Actual Behavior

Member not found in datacontext appears and doesn't show up in intellisense The app, however, will run just fine. The designer just shows the error.

Basic Information

Environment

Show/Hide Visual Studio info ``` Microsoft Visual Studio Professional 2019 Version 16.9.0 VisualStudio.16.Release/16.9.0+31025.194 Microsoft .NET Framework Version 4.8.04084 Installed Version: Professional Microsoft Visual Studio Tools for Applications 2019 00435-60000-00000-AA316 Microsoft Visual Studio Tools for Applications 2019 Visual C++ 2019 00435-60000-00000-AA316 Microsoft Visual C++ 2019 ASP.NET and Web Tools 2019 16.9.687.37626 ASP.NET and Web Tools 2019 ASP.NET Core Razor Language Services 16.1.0.2107702+c4adaa061f13292143de82a96c71341e50bc4032 Provides languages services for ASP.NET Core Razor. ASP.NET Web Frameworks and Tools 2019 16.9.687.37626 For additional information, visit https://www.asp.net/ Azure App Service Tools v3.0.0 16.9.687.37626 Azure App Service Tools v3.0.0 Azure Functions and Web Jobs Tools 16.9.687.37626 Azure Functions and Web Jobs Tools C# Tools 3.9.0-6.21124.20+db94f4cc8c78a7cd8cf9cfdae091158d2ba9d974 C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used. CodeMaid 11.2.231 CodeMaid is an open source Visual Studio extension to cleanup and simplify our C#, C++, F#, VB, PHP, PowerShell, R, JSON, XAML, XML, ASP, HTML, CSS, LESS, SCSS, JavaScript and TypeScript coding. Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools. Cookiecutter 16.9.21026.1 Provides tools for finding, instantiating and customizing templates in cookiecutter format. DevExpress Reporting Extension 1.0 A Visual Studio extension that invokes the Report Designer editor for report definition REPX files. DevExpress Reporting Tools Extension 1.0 Extends Visual Studio with tools required for the Report Designer editor. DevExpress.DeploymentTool 1.0 A useful tool for deploying DevExpress assemblies. DevExpress.Win.LayoutAssistant Extension 1.0 DevExpress.Win.LayoutAssistant Visual Studio Extension Detailed Info Entity Framework 6 Power Tools 0.9.2 Preview of useful design-time DbContext features, added to the Visual Studio Solution Explorer context menu. When right-clicking on a file containing a derived DbContext class, the following context menu functions are supported: 1) View Entity Data Model (Read-only) - Displays a read-only view of the Code First model in the Entity Model Designer. 2) View Entity Data Model XML - Displays the EDMX XML representing the underlying Code First model. 3) View Entity Data Model DDL SQL - Displays the DDL SQL corresponding to the SSDL in the underlying EDM Model. 4) Generate Views - Generates pre-compiled views used by the EF runtime to improve start-up performance. Adds the generated views file to the containing project. When right-clicking on an Entity Data Model (*.edmx) file, the following context menu function is supported: Generate Views - Generates pre-compiled views used by the EF runtime to improve start-up performance. Adds the generated views file to the containing project. Extensibility Message Bus 1.2.6 (master@34d6af2) Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration. GitHub.VisualStudio 2.11.102.28613 A Visual Studio Extension that brings the GitHub Flow into Visual Studio. IntelliCode Extension 1.0 IntelliCode Visual Studio Extension Detailed Info Markdown Editor 1.12.253 A full featured Markdown editor with live preview and syntax highlighting. Supports GitHub flavored Markdown. Microsoft Azure Tools 2.9 Microsoft Azure Tools for Microsoft Visual Studio 2019 - v2.9.40218.1 Microsoft Continuous Delivery Tools for Visual Studio 0.4 Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE. Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines Microsoft Library Manager 2.1.113+g422d40002e.RR Install client-side libraries easily to any web project Microsoft MI-Based Debugger 1.0 Provides support for connecting Visual Studio to MI compatible debuggers Microsoft Visual C++ Wizards 1.0 Microsoft Visual C++ Wizards Microsoft Visual Studio Tools for Containers 1.1 Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container. Microsoft Visual Studio VC Package 1.0 Microsoft Visual Studio VC Package Mono Debugging for Visual Studio 16.9.7 (df23ba6) Support for debugging Mono processes with Visual Studio. NuGet Package Manager 5.9.0 NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/ ProjectServicesPackage Extension 1.0 ProjectServicesPackage Visual Studio Extension Detailed Info Python 16.9.21026.1 Provides IntelliSense, projects, templates, debugging, interactive windows, and other support for Python developers. Python - Conda support 16.9.21026.1 Conda support for Python projects. Python - Django support 16.9.21026.1 Provides templates and integration for the Django web framework. Python - IronPython support 16.9.21026.1 Provides templates and integration for IronPython-based projects. Python - Profiling support 16.9.21026.1 Profiling support for Python projects. SQL Server Data Tools 16.0.62102.01130 Microsoft SQL Server Data Tools SQL Server Integration Services 15.0.1301.433 Microsoft SQL Server Integration Services Designer Version 15.0.1301.433 TypeScript Tools 16.0.30201.2001 TypeScript Tools for Microsoft Visual Studio UnoPlatformPackage Extension 1.0 UnoPlatformPackage Visual Studio Extension Detailed Info Visual Basic Tools 3.9.0-6.21124.20+db94f4cc8c78a7cd8cf9cfdae091158d2ba9d974 Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used. Visual F# Tools 16.9.0-beta.21102.9+7ce7132f1459095e635194d09d6f73265352029a Microsoft Visual F# Tools Visual Studio Code Debug Adapter Host Package 1.0 Interop layer for hosting Visual Studio Code debug adapters in Visual Studio Visual Studio Container Tools Extensions 1.0 View, manage, and diagnose containers within Visual Studio. Visual Studio Tools for Containers 1.0 Visual Studio Tools for Containers VisualStudio.DeviceLog 1.0 Information about my package VisualStudio.Foo 1.0 Information about my package VisualStudio.Mac 1.0 Mac Extension for Visual Studio Vue.js Pack 2019 1.2.3 Contains HTML Intellisense and code snippets for the Vue.js JavaScript library WakaTime 1.0 Xamarin 16.9.000.271 (d16-9@863670b) Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android. Xamarin Designer 16.9.0.316 (remotes/origin/d16-9@fdbf64026) Visual Studio extension to enable Xamarin Designer tools in Visual Studio. Xamarin Templates 16.9.68 (8e9b569) Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms. Xamarin.Android SDK 11.2.0.21 (d16-9/93eab59) Xamarin.Android Reference Assemblies and MSBuild support. Mono: 5e9cb6d Java.Interop: xamarin/java.interop/d16-9@d6d86b2 ProGuard: Guardsquare/proguard/v7.0.1@912d149 SQLite: xamarin/sqlite/3.34.1@daff8f4 Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-9@9d8924d Xamarin.iOS and Xamarin.Mac SDK 14.14.2.5 (3836759d4) Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support. ```

Build Logs

Screenshots

Below is an example image

Reproduction Link

Workaround

If I use a concrete type that implements the interface B, then it works.

jsuarezruiz commented 3 years ago

If XAML finds it at runtime, intelisense should too. cc @mgoertz-msft

mgoertz-msft commented 3 years ago

How does the runtime work without a concrete type?

AutumnEvans418 commented 3 years ago

It works at runtime with a concrete type, but the intellisense doesn't recognize the that an interface that inherits another interface has properties of the interface it inherited.

rachelkang commented 3 years ago

Hi, @chrisevans9629 - thanks for submitting this issue. Unfortunately, I wasn't able to it :/ Could you try updating to the latest version of Visual Studio and seeing if that helps? If not, could you share your project or a sample project that reproduces the issue so that we can investigate further? Thanks :)

RFBomb commented 2 years ago

I'm currently dealing with this issue as well using an MVVM framework.

I have an interface that represents basic functionality of controls (visibility, enabled state, etc), and another one that extends that for use with IRelayCommand and provides a 'ButtonText' property.

IButtonDefinition.ButtonText is visibile via intellisense, but IButtonDefinition.Visibility is not (since Visibility is inherited from my base IControlDefinition

Another user has commented on the linked thread below with this same issue, and its pending release. Unknown if the fix that is pending resolves this issue or not, since the comment was potentially unrelated to the initial topic

https://developercommunity.visualstudio.com/t/intellisense-does-not-show-interfaces-when-autocom/1405793#T-N1406464

for reference, I am using VS2019, building a WPF app in Net5-windows, and below is a truncated view of my interface setup:


    public interface IButtonDefinition: IControlDefinition
    {
        /// <summary>
        /// Provide the ButtonText string
        /// </summary>
        string ButtonText { get; }        

        /// <summary>
        /// Provide a tooltip for some UI control
        /// </summary>
        string ToolTip { get; }
    }

    /// <summary>
    /// base interface for control binding definitions
    /// </summary>
    public interface IControlDefinition : IToolTipProvider, INotifyPropertyChanged
    {
        /// <summary>
        /// Flag to set the visibility of the control
        /// </summary>
        System.Windows.Visibility Visibility { get; set; }

        /// <inheritdoc cref="BaseControlDefinitions.BaseControlDefinition.IsVisible" path="*"/>
        bool IsVisible { get; set; }

    }

XAML:

<Button 
                Content="{Binding OpenAppSupportCommand.ButtonText, FallbackValue='App Support'}"
                Visibility="{Binding OpenAppSupportCommand.Visibility}"
                Command="{Binding OpenAppSupportCommand}"
                ToolTip="{Binding OpenAppSupportCommand.ToolTip}"
                />