Skip to content

Commit

Permalink
fix: Added Uno5 support. Closes #28.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Nov 7, 2023
1 parent d9958c6 commit a392681
Show file tree
Hide file tree
Showing 72 changed files with 42 additions and 100 deletions.
4 changes: 2 additions & 2 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<PackageVersion Include="H.Resources.Generator" Version="1.5.1" />
<PackageVersion Include="IsExternalInit" Version="1.0.3" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.3.1" />
<PackageVersion Include="H.Generators.Extensions" Version="1.19.0" />
<PackageVersion Include="H.Generators.Extensions" Version="1.20.0" />
<PackageVersion Include="ConventionalCommitsGitInfo" Version="0.3.6" />
<PackageVersion Include="DotNet.ReproducibleBuilds" Version="1.1.1" />
</ItemGroup>
Expand All @@ -21,6 +21,6 @@
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.7.0" />
<PackageVersion Include="Verify.MSTest" Version="22.1.4" />
<PackageVersion Include="Verify.SourceGenerators" Version="2.2.0" />
<PackageVersion Include="H.Generators.Tests.Extensions" Version="1.19.0" />
<PackageVersion Include="H.Generators.Tests.Extensions" Version="1.20.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ private static (string Name, bool IsChanged0, bool IsChanged1, bool IsChanged2,
: $"On{property.Name}Changed";

var (isChanged0, isChanged1, isChanged2, isChanged3) = CheckMethods(name, @class, property);
isChanged2 |= !isCustom && !property.IsAttached && property.BindEvents.Any();
isChanged3 |= !isCustom && property.IsAttached && property.BindEvents.Any();
isChanged2 |= !isCustom && property is { IsAttached: false, BindEvents.IsEmpty: false };
isChanged3 |= !isCustom && property is { IsAttached: true, BindEvents.IsEmpty: false };

return (name, isChanged0, isChanged1, isChanged2, isChanged3);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,24 +149,25 @@ private static string GeneratePropertyMetadata(ClassData @class, DependencyPrope

var parameterName = (@class.Framework, property.IsAttached) switch
{
(Framework.Wpf, true) or (Framework.Uwp, true) or (Framework.WinUi, true) => "defaultMetadata",
(Framework.Avalonia, _) => "metadata",
_ => "typeMetadata",
(Framework.Wpf, true) or (Framework.Uwp, true) or (Framework.WinUi, true) => "defaultMetadata: ",
(Framework.Avalonia, _) => "metadata: ",
(Framework.Uno, true) or (Framework.UnoWinUi, true) => string.Empty,
_ => "typeMetadata: ",
};
switch (@class.Framework)
{
case Framework.Wpf:
if (property.DefaultUpdateSourceTrigger == null)
{
return $@"{parameterName}: new global::System.Windows.FrameworkPropertyMetadata(
return $@"{parameterName}new global::System.Windows.FrameworkPropertyMetadata(
defaultValue: {GenerateDefaultValue(property)},
flags: {GenerateOptions(property)},
propertyChangedCallback: {GeneratePropertyChangedCallback(@class, property)},
coerceValueCallback: {GenerateCoerceValueCallback(@class, property)},
isAnimationProhibited: {property.IsAnimationProhibited.ToString().ToLower(CultureInfo.InvariantCulture)})";
}

return $@"{parameterName}: new global::System.Windows.FrameworkPropertyMetadata(
return $@"{parameterName}new global::System.Windows.FrameworkPropertyMetadata(
defaultValue: {GenerateDefaultValue(property)},
flags: {GenerateOptions(property)},
propertyChangedCallback: {GeneratePropertyChangedCallback(@class, property)},
Expand All @@ -182,7 +183,7 @@ private static string GeneratePropertyMetadata(ClassData @class, DependencyPrope
var type = GenerateTypeByPlatform(@class.Framework, "PropertyMetadata");
if (property.CreateDefaultValueCallback)
{
return $@"{parameterName}: {type}.Create(
return $@"{parameterName}{type}.Create(
createDefaultValueCallback: {GenerateCreateDefaultValueCallbackValueCallback(property)},
propertyChangedCallback: {GeneratePropertyChangedCallback(@class, property)})";
}
Expand All @@ -193,7 +194,7 @@ private static string GeneratePropertyMetadata(ClassData @class, DependencyPrope
Framework.Uno or Framework.UnoWinUi => $"new {type}",
_ => $"{type}.Create",
};
return $@"{parameterName}: {create}(
return $@"{parameterName}{create}(
defaultValue: {GenerateDefaultValue(property)},
propertyChangedCallback: {GeneratePropertyChangedCallback(@class, property)})";
}
Expand All @@ -202,7 +203,7 @@ private static string GeneratePropertyMetadata(ClassData @class, DependencyPrope
{
var metadataType = GenerateTypeByPlatform(@class.Framework, $"StyledPropertyMetadata<{property.Type}>");

return $@"{parameterName}: new {metadataType}(
return $@"{parameterName}new {metadataType}(
defaultValue: {GenerateDefaultValue(property)},
defaultBindingMode: global::Avalonia.Data.BindingMode.Default,
coerce: {GenerateCoerceValueCallback(@class, property)},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ private static string GenerateOnChangedMethodCall(string name, DependencyPropert

private static string GenerateBindEventMethod(DependencyPropertyData property)
{
if (!property.BindEvents.Any())
if (property.BindEvents.IsEmpty)
{
return " ";
}
Expand Down Expand Up @@ -243,7 +243,7 @@ private static string GenerateOptions(DependencyPropertyData property)
values.Add(nameof(property.SubPropertiesDoNotAffectRender));
}

if (!values.Any())
if (values.Count == 0)
{
values.Add("None");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ namespace H.Generators;

internal static partial class Sources
{
private readonly static char[] Separator = { '\r', '\n' };

private static string GenerateXmlDocumentationFrom(string value)
{
var lines = value.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
var lines = value.Split(Separator, StringSplitOptions.RemoveEmptyEntries);

return string.Join(Environment.NewLine, lines.Select(static line => $" /// {line}"));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<NoWarn>$(NoWarn);CS3021</NoWarn>
<DefineConstants>$(DefineConstants);HAS_AVALONIA</DefineConstants>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Severity: Hidden,
WarningLevel: 1,
Location: : (0,0)-(0,15),
Description: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS8019),
MessageFormat: Unnecessary using directive.,
Message: Unnecessary using directive.,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Severity: Hidden,
WarningLevel: 1,
Location: : (1,0)-(1,21),
Description: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS8019),
MessageFormat: Unnecessary using directive.,
Message: Unnecessary using directive.,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Severity: Hidden,
WarningLevel: 1,
Location: : (0,0)-(0,15),
Description: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS8019),
MessageFormat: Unnecessary using directive.,
Message: Unnecessary using directive.,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Severity: Hidden,
WarningLevel: 1,
Location: : (1,0)-(1,21),
Description: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS8019),
MessageFormat: Unnecessary using directive.,
Message: Unnecessary using directive.,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Severity: Hidden,
WarningLevel: 1,
Location: : (0,0)-(0,30),
Description: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS8019),
MessageFormat: Unnecessary using directive.,
Message: Unnecessary using directive.,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static partial class GridExtensions
name: "SomeProperty",
propertyType: typeof(object),
ownerType: typeof(global::H.Generators.IntegrationTests.GridExtensions),
typeMetadata: new global::Windows.UI.Xaml.PropertyMetadata(
new global::Windows.UI.Xaml.PropertyMetadata(
defaultValue: default(object),
propertyChangedCallback: null));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static partial class GridExtensions
name: "SomeProperty",
propertyType: typeof(object),
ownerType: typeof(global::H.Generators.IntegrationTests.GridExtensions),
typeMetadata: new global::Microsoft.UI.Xaml.PropertyMetadata(
new global::Microsoft.UI.Xaml.PropertyMetadata(
defaultValue: default(object),
propertyChangedCallback: null));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static partial class GridExtensions
name: "AttachedReadOnlyProperty",
propertyType: typeof(object),
ownerType: typeof(global::H.Generators.IntegrationTests.GridExtensions),
typeMetadata: new global::Windows.UI.Xaml.PropertyMetadata(
new global::Windows.UI.Xaml.PropertyMetadata(
defaultValue: default(object),
propertyChangedCallback: null));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static partial class GridExtensions
name: "AttachedReadOnlyProperty",
propertyType: typeof(object),
ownerType: typeof(global::H.Generators.IntegrationTests.GridExtensions),
typeMetadata: new global::Microsoft.UI.Xaml.PropertyMetadata(
new global::Microsoft.UI.Xaml.PropertyMetadata(
defaultValue: default(object),
propertyChangedCallback: null));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Severity: Warning,
WarningLevel: 2,
Location: DependencyPropertyGenerator/H.Generators.DependencyPropertyGenerator/H.Generators.IntegrationTests.MyControl.Properties.AttributedProperty.g.cs: (33,23)-(33,41),
Description: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS3021),
MessageFormat: '{0}' does not need a CLSCompliant attribute because the assembly does not have a CLSCompliant attribute,
Message: 'MyControl.AttributedProperty' does not need a CLSCompliant attribute because the assembly does not have a CLSCompliant attribute,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Severity: Warning,
WarningLevel: 2,
Location: DependencyPropertyGenerator/H.Generators.DependencyPropertyGenerator/H.Generators.IntegrationTests.MyGrid.Properties.AttributedProperty.g.cs: (37,23)-(37,41),
Description: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS3021),
MessageFormat: '{0}' does not need a CLSCompliant attribute because the assembly does not have a CLSCompliant attribute,
Message: 'MyGrid.AttributedProperty' does not need a CLSCompliant attribute because the assembly does not have a CLSCompliant attribute,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Severity: Warning,
WarningLevel: 2,
Location: DependencyPropertyGenerator/H.Generators.DependencyPropertyGenerator/H.Generators.IntegrationTests.MyControl.Properties.AttributedProperty.g.cs: (33,23)-(33,41),
Description: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS3021),
MessageFormat: '{0}' does not need a CLSCompliant attribute because the assembly does not have a CLSCompliant attribute,
Message: 'MyControl.AttributedProperty' does not need a CLSCompliant attribute because the assembly does not have a CLSCompliant attribute,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Severity: Warning,
WarningLevel: 2,
Location: DependencyPropertyGenerator/H.Generators.DependencyPropertyGenerator/H.Generators.IntegrationTests.MyControl.Properties.AttributedProperty.g.cs: (33,23)-(33,41),
Description: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS3021),
MessageFormat: '{0}' does not need a CLSCompliant attribute because the assembly does not have a CLSCompliant attribute,
Message: 'MyControl.AttributedProperty' does not need a CLSCompliant attribute because the assembly does not have a CLSCompliant attribute,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Severity: Warning,
WarningLevel: 2,
Location: DependencyPropertyGenerator/H.Generators.DependencyPropertyGenerator/H.Generators.IntegrationTests.MyControl.Properties.AttributedProperty.g.cs: (38,23)-(38,41),
Description: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS3021),
MessageFormat: '{0}' does not need a CLSCompliant attribute because the assembly does not have a CLSCompliant attribute,
Message: 'MyControl.AttributedProperty' does not need a CLSCompliant attribute because the assembly does not have a CLSCompliant attribute,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Severity: Hidden,
WarningLevel: 1,
Location: : (0,0)-(0,15),
Description: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS8019),
MessageFormat: Unnecessary using directive.,
Message: Unnecessary using directive.,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Severity: Hidden,
WarningLevel: 1,
Location: : (0,0)-(0,15),
Description: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS8019),
MessageFormat: Unnecessary using directive.,
Message: Unnecessary using directive.,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Severity: Hidden,
WarningLevel: 1,
Location: : (0,0)-(0,15),
Description: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS8019),
MessageFormat: Unnecessary using directive.,
Message: Unnecessary using directive.,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Severity: Hidden,
WarningLevel: 1,
Location: : (0,0)-(0,15),
Description: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS8019),
MessageFormat: Unnecessary using directive.,
Message: Unnecessary using directive.,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Severity: Error,
WarningLevel: 0,
Location: : (18,17)-(18,41),
Description: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS0759),
MessageFormat: No defining declaration found for implementing declaration of partial method '{0}',
Message: No defining declaration found for implementing declaration of partial method 'TropicalAquarium.OnAquariumGraphicChanged()',
Expand All @@ -22,7 +21,6 @@
Severity: Hidden,
WarningLevel: 1,
Location: : (0,0)-(0,15),
Description: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS8019),
MessageFormat: Unnecessary using directive.,
Message: Unnecessary using directive.,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Severity: Error,
WarningLevel: 0,
Location: : (18,17)-(18,41),
Description: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS0759),
MessageFormat: No defining declaration found for implementing declaration of partial method '{0}',
Message: No defining declaration found for implementing declaration of partial method 'TropicalAquarium.OnAquariumGraphicChanged()',
Expand All @@ -22,7 +21,6 @@
Severity: Hidden,
WarningLevel: 1,
Location: : (0,0)-(0,15),
Description: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS8019),
MessageFormat: Unnecessary using directive.,
Message: Unnecessary using directive.,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Severity: Hidden,
WarningLevel: 1,
Location: : (0,0)-(0,15),
Description: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS8019),
MessageFormat: Unnecessary using directive.,
Message: Unnecessary using directive.,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Severity: Warning,
WarningLevel: 2,
Location: : (9,21)-(9,30),
Description: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS3021),
MessageFormat: '{0}' does not need a CLSCompliant attribute because the assembly does not have a CLSCompliant attribute,
Message: 'MyControl' does not need a CLSCompliant attribute because the assembly does not have a CLSCompliant attribute,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Severity: Hidden,
WarningLevel: 1,
Location: : (0,0)-(0,15),
Description: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS8019),
MessageFormat: Unnecessary using directive.,
Message: Unnecessary using directive.,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Severity: Hidden,
WarningLevel: 1,
Location: : (1,0)-(1,21),
Description: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS8019),
MessageFormat: Unnecessary using directive.,
Message: Unnecessary using directive.,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Severity: Hidden,
WarningLevel: 1,
Location: : (1,0)-(1,21),
Description: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS8019),
MessageFormat: Unnecessary using directive.,
Message: Unnecessary using directive.,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Severity: Hidden,
WarningLevel: 1,
Location: : (1,0)-(1,21),
Description: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS8019),
MessageFormat: Unnecessary using directive.,
Message: Unnecessary using directive.,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Severity: Hidden,
WarningLevel: 1,
Location: : (1,0)-(1,21),
Description: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS8019),
MessageFormat: Unnecessary using directive.,
Message: Unnecessary using directive.,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Severity: Hidden,
WarningLevel: 1,
Location: : (1,0)-(1,21),
Description: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS8019),
MessageFormat: Unnecessary using directive.,
Message: Unnecessary using directive.,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Severity: Error,
WarningLevel: 0,
Location: : (19,17)-(19,41),
Description: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS0759),
MessageFormat: No defining declaration found for implementing declaration of partial method '{0}',
Message: No defining declaration found for implementing declaration of partial method 'TropicalAquarium.OnAquariumGraphicChanged()',
Expand All @@ -22,7 +21,6 @@
Severity: Hidden,
WarningLevel: 1,
Location: : (1,0)-(1,21),
Description: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS8019),
MessageFormat: Unnecessary using directive.,
Message: Unnecessary using directive.,
Expand Down
Loading

0 comments on commit a392681

Please sign in to comment.