dnnsoftware / Dnn.Platform

DNN (formerly DotNetNuke) is the leading open source web content management platform (CMS) in the Microsoft ecosystem.
https://dnncommunity.org/
MIT License
1.02k stars 746 forks source link

DotNetNuke.Abstractions.Prompt.ICommand Naming Conflict with System Library #4042

Open SkyeHoefling opened 4 years ago

SkyeHoefling commented 4 years ago

Description of bug

The DotNetNuke.Abstractions.Prompt.ICommand interface in the abstractions project creates a naming conflict with a system library in .NET. System.Windows.Input.ICommand is in the dotnet/runtime and has been for a long time since .NET Framework. It is commonly used in MVVM applications. It is something that may be useful in MVC or future Razor Pages, etc style projects that want to implement MVVM architecture. This naming conflict will require using aliases as a workaround.

This may not be a common scenario in DNN extensions, but I wanted to call it to attention.

Steps to reproduce

N/A

Current behavior

Naming conflict with system interface

Expected behavior

Use a different name other than ICommand

Screenshots

N/A

Error information

N/A

Additional context

This very well could be marked 'as designed' and 'wont fix'. I don't think we should have specialized classes have the exact same name as a system class. It will generate confusion amongst developers that are contributing to the platform or building extensions.

Affected version

latest

Affected browser

N/A

mitchelsellers commented 4 years ago

Great catch.

stale[bot] commented 3 years ago

We have detected this issue has not had any activity during the last 90 days. That could mean this issue is no longer relevant and/or nobody has found the necessary time to address the issue. We are trying to keep the list of open issues limited to those issues that are relevant to the majority and to close the ones that have become 'stale' (inactive). If no further activity is detected within the next 14 days, the issue will be closed automatically. If new comments are are posted and/or a solution (pull request) is submitted for review that references this issue, the issue will not be closed. Closed issues can be reopened at any time in the future. Please remember those participating in this open source project are volunteers trying to help others and creating a better DNN Platform for all. Thank you for your continued involvement and contributions!

SkyeHoefling commented 3 years ago

This should probably be pinned as it creates a conflict with the BCL.

Could we mark this as help wanted and good first issue? I think renaming the interface and making the updates would be a great way for someone to get started in DNN contributions

valadas commented 3 years ago

Done

You have any example of Alias usage, I am curious how that works ?

SkyeHoefling commented 3 years ago

Aliasing in C# allows you to use multiple objects in the same file with the same name. For example if you wanted to use the DNN ICommand and the BCL ICommand in the same file you would need to do something like this

// This is the namespace where ICommand exists in the BCL
using System.Windows.Input;

// Since there is a name conflict this alias statement allows this code file
// to use `IDnnICommand which maps to DotNetNuke.Abstractions.Prompt.ICommand
using IDnnICommand = DotNetNuke.Abstractions.Prompt.ICommand;

namespace MyProject
{
    public class CommandExample
    {
        // This is the standard System.Windows.Input.ICommand
        public ICommand Command { get; }

        // This is the DNN ICommand using the alias
        public IDnnCommand DnnCommand { get; }
    }
}

The official docs has some information on this topic as well

valadas commented 3 years ago

Oh got it :) Thanks for the example