Skip to content

Commit

Permalink
fix(vs): Restore intellisense for non-windows targets
Browse files Browse the repository at this point in the history
(cherry picked from commit 6f6d027)
  • Loading branch information
jeromelaban authored and mergify[bot] committed Aug 24, 2023
1 parent 8217fda commit 50255d5
Showing 1 changed file with 49 additions and 34 deletions.
83 changes: 49 additions & 34 deletions src/Uno.UI/XmlnsDefinitionAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,63 @@
using System.Diagnostics;
using System.Windows.Markup;

[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml", System.Windows.Markup.XamlConstants.BaseXamlNamespace, AssemblyName = "Uno.UI")]
[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", System.Windows.Markup.XamlConstants.BaseXamlNamespace, AssemblyName = "Uno.UI")]
[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", System.Windows.Markup.XamlConstants.RootUINamespace, AssemblyName = "Uno.UI")]
[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", System.Windows.Markup.XamlConstants.RootUINamespace, AssemblyName = "Uno")]
[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", System.Windows.Markup.XamlConstants.Namespaces.Controls, AssemblyName = "Uno.UI")]
[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", System.Windows.Markup.XamlConstants.Namespaces.Primitives, AssemblyName = "Uno.UI")]
[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", System.Windows.Markup.XamlConstants.Namespaces.Text, AssemblyName = "Uno.UI")]
[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", System.Windows.Markup.XamlConstants.Namespaces.Data, AssemblyName = "Uno.UI")]
[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", System.Windows.Markup.XamlConstants.Namespaces.Documents, AssemblyName = "Uno.UI")]
[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", System.Windows.Markup.XamlConstants.Namespaces.Media, AssemblyName = "Uno.UI")]
[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", System.Windows.Markup.XamlConstants.Namespaces.MediaAnimation, AssemblyName = "Uno.UI")]
[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", System.Windows.Markup.XamlConstants.Namespaces.Shapes, AssemblyName = "Uno.UI")]

[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml", "System", AssemblyName = "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml", "System", AssemblyName = "System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]

namespace System.Windows.Markup
[assembly: Microsoft.UI.Xaml.XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml", Microsoft.UI.Xaml.XamlConstants.BaseXamlNamespace)]
[assembly: Microsoft.UI.Xaml.XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", Microsoft.UI.Xaml.XamlConstants.BaseXamlNamespace)]
[assembly: Microsoft.UI.Xaml.XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", Microsoft.UI.Xaml.XamlConstants.RootUINamespace)]
[assembly: Microsoft.UI.Xaml.XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", Microsoft.UI.Xaml.XamlConstants.RootUINamespace)]
[assembly: Microsoft.UI.Xaml.XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", Microsoft.UI.Xaml.XamlConstants.Namespaces.Controls)]
[assembly: Microsoft.UI.Xaml.XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", Microsoft.UI.Xaml.XamlConstants.Namespaces.Primitives)]
[assembly: Microsoft.UI.Xaml.XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", Microsoft.UI.Xaml.XamlConstants.Namespaces.Text)]
[assembly: Microsoft.UI.Xaml.XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", Microsoft.UI.Xaml.XamlConstants.Namespaces.Data)]
[assembly: Microsoft.UI.Xaml.XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", Microsoft.UI.Xaml.XamlConstants.Namespaces.Documents)]
[assembly: Microsoft.UI.Xaml.XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", Microsoft.UI.Xaml.XamlConstants.Namespaces.Media)]
[assembly: Microsoft.UI.Xaml.XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", Microsoft.UI.Xaml.XamlConstants.Namespaces.MediaAnimation)]
[assembly: Microsoft.UI.Xaml.XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", Microsoft.UI.Xaml.XamlConstants.Namespaces.Shapes)]

[assembly: Microsoft.UI.Xaml.XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml", "System")]
[assembly: Microsoft.UI.Xaml.XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml", "System")]

namespace Microsoft.UI.Xaml;

// This attribute is aligned with https://github.com/dotnet/maui/blob/312948086267cf6c529dfeb2ec0eeae7e7aa57ae/src/Graphics/src/Graphics/XmlnsDefinitionAttribute.cs#L8
// Visual studio now expects this attribute to be present in order to provide intellisense for the types
// in the namespace, and must not have the `Assembly` property.
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
[DebuggerDisplay("{XmlNamespace}, {ClrNamespace}")]
internal sealed class XmlnsDefinitionAttribute : Attribute
{
internal static class XamlConstants
public string XmlNamespace { get; }
public string ClrNamespace { get; }

public XmlnsDefinitionAttribute(string xmlNamespace, string clrNamespace)
{
ClrNamespace = clrNamespace ?? throw new ArgumentNullException(nameof(xmlNamespace));
XmlNamespace = xmlNamespace ?? throw new ArgumentNullException(nameof(clrNamespace));
}
}

internal static class XamlConstants
{
#if HAS_UNO_WINUI
public const string RootUINamespace = "Microsoft.UI";
public const string RootUINamespace = "Microsoft.UI";
#else
public const string RootUINamespace = "Windows.UI";
public const string RootUINamespace = "Windows.UI";
#endif

public const string WindowsUINamespace = "Windows.UI";
public const string WindowsUINamespace = "Windows.UI";

public const string BaseXamlNamespace = RootUINamespace + ".Xaml";
public const string BaseXamlNamespace = RootUINamespace + ".Xaml";

internal static class Namespaces
{
public const string Controls = BaseXamlNamespace + ".Controls";
public const string Primitives = Controls + ".Primitives";
public const string Text = WindowsUINamespace + ".Text";
public const string Data = BaseXamlNamespace + ".Data";
public const string Documents = BaseXamlNamespace + ".Documents";
public const string Media = BaseXamlNamespace + ".Media";
public const string MediaAnimation = BaseXamlNamespace + ".Media.Animation";
public const string Shapes = BaseXamlNamespace + ".Shapes";
internal static class Namespaces
{
public const string Controls = BaseXamlNamespace + ".Controls";
public const string Primitives = Controls + ".Primitives";
public const string Text = WindowsUINamespace + ".Text";
public const string Data = BaseXamlNamespace + ".Data";
public const string Documents = BaseXamlNamespace + ".Documents";
public const string Media = BaseXamlNamespace + ".Media";
public const string MediaAnimation = BaseXamlNamespace + ".Media.Animation";
public const string Shapes = BaseXamlNamespace + ".Shapes";

}
}
}

0 comments on commit 50255d5

Please sign in to comment.