Skip to content

Commit

Permalink
Merge pull request #61 from idexus/net8
Browse files Browse the repository at this point in the history
net8.0 update
  • Loading branch information
idexus committed Feb 13, 2024
2 parents 1c3f651 + 7910293 commit 7213bae
Show file tree
Hide file tree
Showing 19 changed files with 655 additions and 991 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ void GenerateClassExtensionBody()

var properties = mainSymbol
.GetMembers()
.Where(e => e.Kind == SymbolKind.Property && e.DeclaredAccessibility == Accessibility.Public && !e.IsStatic);
.Where(e => e.Kind == SymbolKind.Property && e.DeclaredAccessibility == Accessibility.Public && !e.IsStatic && !Helpers.IsSymbolDeprecated(e));

var events = mainSymbol
.GetMembers()
.Where(e => e.Kind == SymbolKind.Event && e.DeclaredAccessibility == Accessibility.Public && !e.IsStatic);
.Where(e => e.Kind == SymbolKind.Event && e.DeclaredAccessibility == Accessibility.Public && !e.IsStatic && !Helpers.IsSymbolDeprecated(e));

foreach (var prop in properties)
GenerateExtensionMethod(prop as IPropertySymbol);
Expand Down Expand Up @@ -228,7 +228,7 @@ void GenerateAttachedPropertiesExtension()
{
var properties = inter
.GetMembers()
.Where(e => e.Kind == SymbolKind.Property);
.Where(e => e.Kind == SymbolKind.Property && !Helpers.IsSymbolDeprecated(e));

foreach (var prop in properties)
{
Expand Down Expand Up @@ -258,7 +258,7 @@ void GenerateBindablePropertyExtensionsFromInterface()
{
var properties = inter
.GetMembers()
.Where(e => e.Kind == SymbolKind.Property);
.Where(e => e.Kind == SymbolKind.Property && !Helpers.IsSymbolDeprecated(e));

foreach (var prop in properties)
{
Expand Down
13 changes: 13 additions & 0 deletions src/generators/shared/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CSharp.Syntax;

namespace Sharp.UI.Generator
{
Expand Down Expand Up @@ -139,6 +140,18 @@ public static bool IsBindableObject(INamedTypeSymbol symbol)

return isBindable;
}

public static bool IsSymbolDeprecated(ISymbol symbol)
{
foreach (var attribute in symbol.GetAttributes())
{
if (attribute.AttributeClass.ToDisplayString().Contains("Obsolete"))
{
return true;
}
}
return false;
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,38 @@ public static SettersContext<T> Content<T>(this SettersContext<T> self, Func<Pro
return self;
}

public static T HideSoftInputOnTapped<T>(this T self,
bool hideSoftInputOnTapped)
where T : Microsoft.Maui.Controls.ContentPage
{
self.SetValue(Microsoft.Maui.Controls.ContentPage.HideSoftInputOnTappedProperty, hideSoftInputOnTapped);
return self;
}

public static T HideSoftInputOnTapped<T>(this T self, Func<PropertyContext<bool>, IPropertyBuilder<bool>> configure)
where T : Microsoft.Maui.Controls.ContentPage
{
var context = new PropertyContext<bool>(self, Microsoft.Maui.Controls.ContentPage.HideSoftInputOnTappedProperty);
configure(context).Build();
return self;
}

public static SettersContext<T> HideSoftInputOnTapped<T>(this SettersContext<T> self,
bool hideSoftInputOnTapped)
where T : Microsoft.Maui.Controls.ContentPage
{
self.XamlSetters.Add(new Setter { Property = Microsoft.Maui.Controls.ContentPage.HideSoftInputOnTappedProperty, Value = hideSoftInputOnTapped });
return self;
}

public static SettersContext<T> HideSoftInputOnTapped<T>(this SettersContext<T> self, Func<PropertySettersContext<bool>, IPropertySettersBuilder<bool>> configure)
where T : Microsoft.Maui.Controls.ContentPage
{
var context = new PropertySettersContext<bool>(self.XamlSetters, Microsoft.Maui.Controls.ContentPage.HideSoftInputOnTappedProperty);
configure(context).Build();
return self;
}

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public static SettersContext<T> DragStartingCommandParameter<T>(this SettersCont
return self;
}

public static T OnDropCompleted<T>(this T self, System.EventHandler<Microsoft.Maui.Controls.DropCompletedEventArgs> handler)
public static T OnDropCompleted<T>(this T self, System.EventHandler<Microsoft.Maui.Controls.DropCompletedEventArgs>? handler)
where T : Microsoft.Maui.Controls.DragGestureRecognizer
{
self.DropCompleted += handler;
Expand All @@ -186,7 +186,7 @@ public static T OnDropCompleted<T>(this T self, System.Action<T> action)
return self;
}

public static T OnDragStarting<T>(this T self, System.EventHandler<Microsoft.Maui.Controls.DragStartingEventArgs> handler)
public static T OnDragStarting<T>(this T self, System.EventHandler<Microsoft.Maui.Controls.DragStartingEventArgs>? handler)
where T : Microsoft.Maui.Controls.DragGestureRecognizer
{
self.DragStarting += handler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,207 +44,6 @@ public static SettersContext<T> AutoSize<T>(this SettersContext<T> self, Func<Pr
return self;
}

public static T FontAttributes<T>(this T self,
Microsoft.Maui.Controls.FontAttributes fontAttributes)
where T : Microsoft.Maui.Controls.Editor
{
self.SetValue(Microsoft.Maui.Controls.Editor.FontAttributesProperty, fontAttributes);
return self;
}

public static T FontAttributes<T>(this T self, Func<PropertyContext<Microsoft.Maui.Controls.FontAttributes>, IPropertyBuilder<Microsoft.Maui.Controls.FontAttributes>> configure)
where T : Microsoft.Maui.Controls.Editor
{
var context = new PropertyContext<Microsoft.Maui.Controls.FontAttributes>(self, Microsoft.Maui.Controls.Editor.FontAttributesProperty);
configure(context).Build();
return self;
}

public static SettersContext<T> FontAttributes<T>(this SettersContext<T> self,
Microsoft.Maui.Controls.FontAttributes fontAttributes)
where T : Microsoft.Maui.Controls.Editor
{
self.XamlSetters.Add(new Setter { Property = Microsoft.Maui.Controls.Editor.FontAttributesProperty, Value = fontAttributes });
return self;
}

public static SettersContext<T> FontAttributes<T>(this SettersContext<T> self, Func<PropertySettersContext<Microsoft.Maui.Controls.FontAttributes>, IPropertySettersBuilder<Microsoft.Maui.Controls.FontAttributes>> configure)
where T : Microsoft.Maui.Controls.Editor
{
var context = new PropertySettersContext<Microsoft.Maui.Controls.FontAttributes>(self.XamlSetters, Microsoft.Maui.Controls.Editor.FontAttributesProperty);
configure(context).Build();
return self;
}

public static T IsTextPredictionEnabled<T>(this T self,
bool isTextPredictionEnabled)
where T : Microsoft.Maui.Controls.Editor
{
self.SetValue(Microsoft.Maui.Controls.Editor.IsTextPredictionEnabledProperty, isTextPredictionEnabled);
return self;
}

public static T IsTextPredictionEnabled<T>(this T self, Func<PropertyContext<bool>, IPropertyBuilder<bool>> configure)
where T : Microsoft.Maui.Controls.Editor
{
var context = new PropertyContext<bool>(self, Microsoft.Maui.Controls.Editor.IsTextPredictionEnabledProperty);
configure(context).Build();
return self;
}

public static SettersContext<T> IsTextPredictionEnabled<T>(this SettersContext<T> self,
bool isTextPredictionEnabled)
where T : Microsoft.Maui.Controls.Editor
{
self.XamlSetters.Add(new Setter { Property = Microsoft.Maui.Controls.Editor.IsTextPredictionEnabledProperty, Value = isTextPredictionEnabled });
return self;
}

public static SettersContext<T> IsTextPredictionEnabled<T>(this SettersContext<T> self, Func<PropertySettersContext<bool>, IPropertySettersBuilder<bool>> configure)
where T : Microsoft.Maui.Controls.Editor
{
var context = new PropertySettersContext<bool>(self.XamlSetters, Microsoft.Maui.Controls.Editor.IsTextPredictionEnabledProperty);
configure(context).Build();
return self;
}

public static T CursorPosition<T>(this T self,
int cursorPosition)
where T : Microsoft.Maui.Controls.Editor
{
self.SetValue(Microsoft.Maui.Controls.Editor.CursorPositionProperty, cursorPosition);
return self;
}

public static T CursorPosition<T>(this T self, Func<PropertyContext<int>, IPropertyBuilder<int>> configure)
where T : Microsoft.Maui.Controls.Editor
{
var context = new PropertyContext<int>(self, Microsoft.Maui.Controls.Editor.CursorPositionProperty);
configure(context).Build();
return self;
}

public static SettersContext<T> CursorPosition<T>(this SettersContext<T> self,
int cursorPosition)
where T : Microsoft.Maui.Controls.Editor
{
self.XamlSetters.Add(new Setter { Property = Microsoft.Maui.Controls.Editor.CursorPositionProperty, Value = cursorPosition });
return self;
}

public static SettersContext<T> CursorPosition<T>(this SettersContext<T> self, Func<PropertySettersContext<int>, IPropertySettersBuilder<int>> configure)
where T : Microsoft.Maui.Controls.Editor
{
var context = new PropertySettersContext<int>(self.XamlSetters, Microsoft.Maui.Controls.Editor.CursorPositionProperty);
configure(context).Build();
return self;
}

public static T SelectionLength<T>(this T self,
int selectionLength)
where T : Microsoft.Maui.Controls.Editor
{
self.SetValue(Microsoft.Maui.Controls.Editor.SelectionLengthProperty, selectionLength);
return self;
}

public static T SelectionLength<T>(this T self, Func<PropertyContext<int>, IPropertyBuilder<int>> configure)
where T : Microsoft.Maui.Controls.Editor
{
var context = new PropertyContext<int>(self, Microsoft.Maui.Controls.Editor.SelectionLengthProperty);
configure(context).Build();
return self;
}

public static SettersContext<T> SelectionLength<T>(this SettersContext<T> self,
int selectionLength)
where T : Microsoft.Maui.Controls.Editor
{
self.XamlSetters.Add(new Setter { Property = Microsoft.Maui.Controls.Editor.SelectionLengthProperty, Value = selectionLength });
return self;
}

public static SettersContext<T> SelectionLength<T>(this SettersContext<T> self, Func<PropertySettersContext<int>, IPropertySettersBuilder<int>> configure)
where T : Microsoft.Maui.Controls.Editor
{
var context = new PropertySettersContext<int>(self.XamlSetters, Microsoft.Maui.Controls.Editor.SelectionLengthProperty);
configure(context).Build();
return self;
}

public static T FontFamily<T>(this T self,
string fontFamily)
where T : Microsoft.Maui.Controls.Editor
{
self.SetValue(Microsoft.Maui.Controls.Editor.FontFamilyProperty, fontFamily);
return self;
}

public static T FontFamily<T>(this T self, Func<PropertyContext<string>, IPropertyBuilder<string>> configure)
where T : Microsoft.Maui.Controls.Editor
{
var context = new PropertyContext<string>(self, Microsoft.Maui.Controls.Editor.FontFamilyProperty);
configure(context).Build();
return self;
}

public static SettersContext<T> FontFamily<T>(this SettersContext<T> self,
string fontFamily)
where T : Microsoft.Maui.Controls.Editor
{
self.XamlSetters.Add(new Setter { Property = Microsoft.Maui.Controls.Editor.FontFamilyProperty, Value = fontFamily });
return self;
}

public static SettersContext<T> FontFamily<T>(this SettersContext<T> self, Func<PropertySettersContext<string>, IPropertySettersBuilder<string>> configure)
where T : Microsoft.Maui.Controls.Editor
{
var context = new PropertySettersContext<string>(self.XamlSetters, Microsoft.Maui.Controls.Editor.FontFamilyProperty);
configure(context).Build();
return self;
}

public static T FontSize<T>(this T self,
double fontSize)
where T : Microsoft.Maui.Controls.Editor
{
self.SetValue(Microsoft.Maui.Controls.Editor.FontSizeProperty, fontSize);
return self;
}

public static T FontSize<T>(this T self, Func<PropertyContext<double>, IPropertyBuilder<double>> configure)
where T : Microsoft.Maui.Controls.Editor
{
var context = new PropertyContext<double>(self, Microsoft.Maui.Controls.Editor.FontSizeProperty);
configure(context).Build();
return self;
}

public static SettersContext<T> FontSize<T>(this SettersContext<T> self,
double fontSize)
where T : Microsoft.Maui.Controls.Editor
{
self.XamlSetters.Add(new Setter { Property = Microsoft.Maui.Controls.Editor.FontSizeProperty, Value = fontSize });
return self;
}

public static SettersContext<T> FontSize<T>(this SettersContext<T> self, Func<PropertySettersContext<double>, IPropertySettersBuilder<double>> configure)
where T : Microsoft.Maui.Controls.Editor
{
var context = new PropertySettersContext<double>(self.XamlSetters, Microsoft.Maui.Controls.Editor.FontSizeProperty);
configure(context).Build();
return self;
}

public static Task<bool> AnimateFontSizeTo<T>(this T self, double value, uint length = 250, Easing? easing = null)
where T : Microsoft.Maui.Controls.Editor
{
double fromValue = self.FontSize;
var transform = (double t) => Transformations.DoubleTransform(fromValue, value, t);
var callback = (double actValue) => { self.FontSize = actValue; };
return Transformations.AnimateAsync<double>(self, "AnimateFontSizeTo", transform, callback, length, easing);
}

public static T HorizontalTextAlignment<T>(this T self,
Microsoft.Maui.TextAlignment horizontalTextAlignment)
where T : Microsoft.Maui.Controls.Editor
Expand Down Expand Up @@ -309,38 +108,6 @@ public static SettersContext<T> VerticalTextAlignment<T>(this SettersContext<T>
return self;
}

public static T FontAutoScalingEnabled<T>(this T self,
bool fontAutoScalingEnabled)
where T : Microsoft.Maui.Controls.Editor
{
self.SetValue(Microsoft.Maui.Controls.Editor.FontAutoScalingEnabledProperty, fontAutoScalingEnabled);
return self;
}

public static T FontAutoScalingEnabled<T>(this T self, Func<PropertyContext<bool>, IPropertyBuilder<bool>> configure)
where T : Microsoft.Maui.Controls.Editor
{
var context = new PropertyContext<bool>(self, Microsoft.Maui.Controls.Editor.FontAutoScalingEnabledProperty);
configure(context).Build();
return self;
}

public static SettersContext<T> FontAutoScalingEnabled<T>(this SettersContext<T> self,
bool fontAutoScalingEnabled)
where T : Microsoft.Maui.Controls.Editor
{
self.XamlSetters.Add(new Setter { Property = Microsoft.Maui.Controls.Editor.FontAutoScalingEnabledProperty, Value = fontAutoScalingEnabled });
return self;
}

public static SettersContext<T> FontAutoScalingEnabled<T>(this SettersContext<T> self, Func<PropertySettersContext<bool>, IPropertySettersBuilder<bool>> configure)
where T : Microsoft.Maui.Controls.Editor
{
var context = new PropertySettersContext<bool>(self.XamlSetters, Microsoft.Maui.Controls.Editor.FontAutoScalingEnabledProperty);
configure(context).Build();
return self;
}

public static T OnCompleted<T>(this T self, System.EventHandler handler)
where T : Microsoft.Maui.Controls.Editor
{
Expand Down

0 comments on commit 7213bae

Please sign in to comment.