Skip to content
Merged
Show file tree
Hide file tree
Changes from 74 commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
02716dd
Update IconTintColorBehavior.shared.cs
TheCodeTraveler Nov 6, 2025
65a7094
Update ImageTouchBehavior.shared.cs
TheCodeTraveler Nov 6, 2025
559dd63
Add `new` keyword functionality to `BindablePropertyAttributeSourceGe…
TheCodeTraveler Nov 5, 2025
fc41062
Update BindablePropertyAttributeSourceGenerator.cs
TheCodeTraveler Nov 6, 2025
7dc243c
Update StatusBarBehavior
TheCodeTraveler Nov 6, 2025
e55fe00
Properly Sanitize ReturnType and DeclaringType
TheCodeTraveler Nov 6, 2025
969836d
Return correct string for boolean operators
TheCodeTraveler Nov 6, 2025
7f5b206
Update StatusBarBehavior
TheCodeTraveler Nov 6, 2025
543b7d2
Update TouchBehavior
TheCodeTraveler Nov 6, 2025
7e17abe
Return correct string for boolean operators
TheCodeTraveler Nov 6, 2025
3f2142c
Update Expander.shared.cs
TheCodeTraveler Nov 6, 2025
618ec37
Add `GetEnumValueByNameAsString`
TheCodeTraveler Nov 6, 2025
ff12f59
Fix`GetEnumValueByNameAsString`
TheCodeTraveler Nov 6, 2025
b9dc3bb
Finish TouchBehavior
TheCodeTraveler Nov 6, 2025
ef4d904
Finish Behaviors
TheCodeTraveler Nov 6, 2025
8020d16
Finish Behaviors
TheCodeTraveler Nov 7, 2025
4d2dc30
Fix Declaring Type
TheCodeTraveler Nov 7, 2025
187d9d8
Fix ReturnType
TheCodeTraveler Nov 7, 2025
33523d6
Fix Enum Support
TheCodeTraveler Nov 7, 2025
28bbb8e
Add `PolySharp`
TheCodeTraveler Nov 7, 2025
3dd790d
Add `BindablePropertyModel .BindablePropertyName `
TheCodeTraveler Nov 7, 2025
81bed50
Fix Enum Support
TheCodeTraveler Nov 7, 2025
6928dc4
Add `BindablePropertyModel .BindablePropertyName `
TheCodeTraveler Nov 7, 2025
401214e
Ensure Floating Point Types include a decimal
TheCodeTraveler Nov 7, 2025
efc9d67
Fix TouchBehaviorTests
TheCodeTraveler Nov 7, 2025
b5bb11a
Fix TouchBehaviorTests
TheCodeTraveler Nov 7, 2025
523e58b
Add `GetNamedTypeArgumentsAttributeValueByNameAsCastedString` and `Ge…
TheCodeTraveler Nov 7, 2025
b7e1572
Fix ProgressBar
TheCodeTraveler Nov 7, 2025
b642931
Merge branch 'main' into Use-`-BindableProperty]`-for-Behaviors
TheCodeTraveler Nov 7, 2025
7a319d3
`dotnet format`
TheCodeTraveler Nov 7, 2025
fff02d8
Merge branch 'Use-`-BindableProperty]`-for-Behaviors' of https://gith…
TheCodeTraveler Nov 7, 2025
3af56cd
`dotnet format`
TheCodeTraveler Nov 7, 2025
2193584
Add `CommunityToolkit.Maui.SourceGenerators.Internal.UnitTests.csproj`
TheCodeTraveler Nov 9, 2025
cac3db8
Merge branch 'main' into Use-`-BindableProperty]`-for-Behaviors
TheCodeTraveler Nov 16, 2025
d111631
Update to Microsoft.CodeAnalysis.Testing.ReferenceAssemblies.Net.NET100
TheCodeTraveler Nov 16, 2025
07df7df
Update CommunityToolkit.Maui.slnx
TheCodeTraveler Nov 16, 2025
3558289
Merge branch 'main' into Use-`-BindableProperty]`-for-Behaviors
TheCodeTraveler Nov 17, 2025
f82a8fb
Add ReferenceAssembliesExtensions extension
TheCodeTraveler Nov 20, 2025
bff5c71
Update ReferenceAssembliesExtensions.cs
TheCodeTraveler Nov 20, 2025
6f35142
`dotnet format`
TheCodeTraveler Nov 20, 2025
e434acd
Create ReferenceAssembliesExtensions.cs
TheCodeTraveler Nov 20, 2025
4ad8da5
Fix `Microsoft.CodeAnalysis.Testing.ReferenceAssemblies.Net.NET100`
TheCodeTraveler Nov 20, 2025
2c7f400
Merge branch 'main' into Use-`-BindableProperty]`-for-Behaviors
TheCodeTraveler Nov 20, 2025
6eb998b
Update NuGet Packages
TheCodeTraveler Nov 20, 2025
1016a7d
Merge branch 'main' into Use-`-BindableProperty]`-for-Behaviors
TheCodeTraveler Nov 21, 2025
b3d81ca
Add `global::`
TheCodeTraveler Nov 21, 2025
01b32b9
Add `global::`
TheCodeTraveler Nov 21, 2025
f59ad5c
GenerateBindableProperty_SimpleExample_GeneratesCorrectCode Passing
TheCodeTraveler Nov 21, 2025
0ee552d
Add support for `SpecialType.System_String`
TheCodeTraveler Nov 21, 2025
75629f3
Finish BindablePropertyAttributeSourceGeneratorTests
TheCodeTraveler Nov 21, 2025
b35112a
Add Support for Keywords
TheCodeTraveler Nov 21, 2025
e640029
Update Namings
TheCodeTraveler Nov 21, 2025
83a0dc3
Update BindablePropertyAttributeSourceGenerator.cs
TheCodeTraveler Nov 21, 2025
29e7ecd
Add support for global namespaces
TheCodeTraveler Nov 21, 2025
0480ff0
Add support for global namespaces
TheCodeTraveler Nov 21, 2025
d787b32
`dotnet format`
TheCodeTraveler Nov 21, 2025
05bb99f
Finish Edge Cases
TheCodeTraveler Nov 21, 2025
fa566d9
Use constants for class and namespaces
TheCodeTraveler Nov 21, 2025
7b4ac1a
Complete GenerateBindableProperty_ComplexInheritanceScenario_Generate…
TheCodeTraveler Nov 21, 2025
1a4f893
Complete GenerateBindableProperty_MultipleClassesInSameFile_Generates…
TheCodeTraveler Nov 21, 2025
af89368
Complete GenerateBindableProperty_WithCustomTypes_GeneratesCorrectCode
TheCodeTraveler Nov 21, 2025
05fad06
Update IntegrationTests.cs
TheCodeTraveler Nov 21, 2025
ea64f86
Add support for nested classes
TheCodeTraveler Nov 21, 2025
ade68fe
Add support for nested classes
TheCodeTraveler Nov 21, 2025
4f92ecf
Add support for genericclasses
TheCodeTraveler Nov 21, 2025
dc28b6d
Update dotnet-build.yml
TheCodeTraveler Nov 21, 2025
c44a7c2
Update csproj
TheCodeTraveler Nov 21, 2025
d79bcb8
Update csproj
TheCodeTraveler Nov 21, 2025
83e1e96
Update csproj
TheCodeTraveler Nov 21, 2025
dbe75e2
Use `Path.Combine` for macos support
TheCodeTraveler Nov 21, 2025
c30a0f8
Fix support for nested classes
TheCodeTraveler Nov 21, 2025
1f97d27
Update BindablePropertyAttributeSourceGenerator.cs
TheCodeTraveler Nov 21, 2025
569213a
Revert "Update BindablePropertyAttributeSourceGenerator.cs"
TheCodeTraveler Nov 21, 2025
d5f68e7
Normalize Line Endings in Unit Test for Windows vs macOS
TheCodeTraveler Nov 21, 2025
bba4bc8
Revert "Normalize Line Endings in Unit Test for Windows vs macOS"
TheCodeTraveler Nov 21, 2025
14e8710
Only run Internal Source Generator Unit Tests on Windows
TheCodeTraveler Nov 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/dotnet-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ env:
PathToCommunityToolkitCameraAnalyzersCodeFixCsproj: 'src/CommunityToolkit.Maui.Camera.Analyzers.CodeFixes/CommunityToolkit.Maui.Camera.Analyzers.CodeFixes.csproj'
PathToCommunityToolkitMediaElementAnalyzersCodeFixCsproj: 'src/CommunityToolkit.Maui.MediaElement.Analyzers.CodeFixes/CommunityToolkit.Maui.MediaElement.Analyzers.CodeFixes.csproj'
PathToCommunityToolkitAnalyzersUnitTestProjectDirectory: 'src/CommunityToolkit.Maui.Analyzers.UnitTests'
PathToCommunityToolkitSourceGeneratorsInternalUnitTestDirectory: 'src/CommunityToolkit.Maui.SourceGenerators.Internal.UnitTests'
PathToCommunityToolkitSourceGeneratorsInternalUnitTestCsproj: 'src/CommunityToolkit.Maui.SourceGenerators.Internal.UnitTests/CommunityToolkit.Maui.SourceGenerators.Internal.UnitTests.csproj'
PathToCommunityToolkitAnalyzersBenchmarkCsproj: 'src/CommunityToolkit.Maui.Analyzers.Benchmarks/CommunityToolkit.Maui.Analyzers.Benchmarks.csproj'
CommunityToolkitLibrary_Xcode_Version: '26.1'

Expand Down Expand Up @@ -209,6 +211,11 @@ jobs:
run: |
cd ${{ env.PathToCommunityToolkitAnalyzersUnitTestProjectDirectory }}
dotnet run -c Release --results-directory "${{ runner.temp }}" --coverage --coverage-output "${{ runner.temp }}/ut-analyzers.cobertura.xml" --coverage-output-format cobertura --report-xunit

- name: Run CommunityToolkit Source Generators Internal UnitTests
run: |
cd ${{ env.PathToCommunityToolkitSourceGeneratorsInternalUnitTestDirectory }}
dotnet run -c Release --results-directory "${{ runner.temp }}" --coverage --coverage-output "${{ runner.temp }}/ut-sourcegenerators-internal.cobertura.xml" --coverage-output-format cobertura --report-xunit

- name: Run CommunityToolkit UnitTests
run: |
Expand Down
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@
<SupportedPlatform Include="Tizen" />
<InternalsVisibleTo Include="CommunityToolkit.Maui.UnitTests"/>
<InternalsVisibleTo Include="CommunityToolkit.Maui.Analyzers.UnitTests"/>
<InternalsVisibleTo Include="CommunityToolkit.Maui.SourceGenerators.Internal.UnitTests"/>
</ItemGroup>

<PropertyGroup Condition="('$(TF_BUILD)' == 'true' OR '$(GITHUB_ACTIONS)' == 'true') and $([MSBuild]::IsOSPlatform('windows')) == 'true'">
Expand Down
1 change: 1 addition & 0 deletions samples/CommunityToolkit.Maui.Sample.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
</Folder>
<Folder Name="/Tests/">
<Project Path="../src/CommunityToolkit.Maui.Analyzers.UnitTests/CommunityToolkit.Maui.Analyzers.UnitTests.csproj" />
<Project Path="../src/CommunityToolkit.Maui.SourceGenerators.Internal.UnitTests/CommunityToolkit.Maui.SourceGenerators.Internal.UnitTests.csproj" />
<Project Path="../src/CommunityToolkit.Maui.UnitTests/CommunityToolkit.Maui.UnitTests.csproj">
<Deploy />
</Project>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
<CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)\GF</CompilerGeneratedFilesOutputPath>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<OutputType>Exe</OutputType>
<RootNamespace>CommunityToolkit.Maui.Analyzers.UnitTests</RootNamespace>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace CommunityToolkit.Maui.Core;

static class ProgressBarAnimationBehaviorDefaults
{
public const double Progress = 0.0;
public const uint Length = 500;
public static Easing Easing { get; } = Easing.Linear;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace CommunityToolkit.Maui.Core;

static class UserStoppedTypingBehaviorDefaults
{
public const int StoppedTypingTimeThreshold = 1000;
public const int MinimumLengthThreshold = 0;
public const bool ShouldDismissKeyboardAutomatically = false;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Testing;
using Microsoft.CodeAnalysis.Testing;
using Xunit;

namespace CommunityToolkit.Maui.SourceGenerators.Internal.UnitTests;

public abstract class BaseTest
{
protected static async Task VerifySourceGeneratorAsync(string source, string expectedAttribute, params List<(string FileName, string GeneratedFile)> expectedGenerated)
{
const string sourceGeneratorNamespace = "CommunityToolkit.Maui.SourceGenerators.Internal";
const string bindablePropertyAttributeGeneratedFileName = "BindablePropertyAttribute.g.cs";
var sourceGeneratorFullName = typeof(BindablePropertyAttributeSourceGenerator).FullName ?? throw new InvalidOperationException("Source Generator Type Path cannot be null");

var test = new CSharpSourceGeneratorTest<BindablePropertyAttributeSourceGenerator, DefaultVerifier>
{
#if NET10_0
ReferenceAssemblies = Microsoft.CodeAnalysis.Testing.ReferenceAssemblies.Net.Net100,
#else
#error ReferenceAssemblies must be updated to current version of .NET
#endif
TestState =
{
Sources = { source },

AdditionalReferences =
{
MetadataReference.CreateFromFile(typeof(Microsoft.Maui.Controls.BindableObject).Assembly.Location),
MetadataReference.CreateFromFile(typeof(Microsoft.Maui.Controls.BindableProperty).Assembly.Location),
MetadataReference.CreateFromFile(typeof(Microsoft.Maui.Controls.BindingMode).Assembly.Location)
}
}
};


// Format as UTF 8 to match the default encoding used by Roslyn
var expectedAttributeText = OperatingSystem.IsWindows() switch
{
// Normalize line endings to LF to ensure consistent behavior across platforms, e.g. `<LF>` instead of `<CR><LF>`
false => Microsoft.CodeAnalysis.Text.SourceText.From(expectedAttribute.Replace("\r\n", "\n").Replace("\r", "\n"), System.Text.Encoding.UTF8),
true => Microsoft.CodeAnalysis.Text.SourceText.From(expectedAttribute, System.Text.Encoding.UTF8),
};
var bindablePropertyAttributeFilePath = Path.Combine(sourceGeneratorNamespace, sourceGeneratorFullName, bindablePropertyAttributeGeneratedFileName);
test.TestState.GeneratedSources.Add((bindablePropertyAttributeFilePath, expectedAttributeText));

foreach (var (FileName, GeneratedFile) in expectedGenerated.Where(static x => !string.IsNullOrEmpty(x.GeneratedFile)))
{
// Format as UTF 8 to match the default encoding used by Roslyn
var expectedGeneratedText = OperatingSystem.IsWindows() switch
{
// Normalize line endings to LF to ensure consistent behavior across platforms, e.g. `<LF>` instead of `<CR><LF>`
false => Microsoft.CodeAnalysis.Text.SourceText.From(GeneratedFile.Replace("\r\n", "\n").Replace("\r", "\n"), System.Text.Encoding.UTF8),
true => Microsoft.CodeAnalysis.Text.SourceText.From(GeneratedFile, System.Text.Encoding.UTF8)
};

var generatedFilePath = Path.Combine(sourceGeneratorNamespace, sourceGeneratorFullName, FileName);
test.TestState.GeneratedSources.Add((generatedFilePath, expectedGeneratedText));
}

await test.RunAsync(TestContext.Current.CancellationToken);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
namespace CommunityToolkit.Maui.SourceGenerators.Internal.UnitTests.BindablePropertyAttributeSourceGeneratorTests;

public class BaseBindablePropertyAttributeSourceGeneratorTest : BaseTest
{
protected const string defaultTestClassName = "TestView";
protected const string defaultTestNamespace = "TestNamespace";

protected const string expectedAttribute =
/* language=C#-test */
//lang=csharp
"""
// <auto-generated>
// See: CommunityToolkit.Maui.SourceGenerators.Internal.BindablePropertyAttributeSourceGenerator

#pragma warning disable
#nullable enable
namespace CommunityToolkit.Maui;

[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
[global::System.AttributeUsage(global::System.AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
sealed partial class BindablePropertyAttribute : global::System.Attribute
{
public string? PropertyName { get; }
public global::System.Type? DeclaringType { get; set; }
public object? DefaultValue { get; set; }
public global::Microsoft.Maui.Controls.BindingMode DefaultBindingMode { get; set; }
public string ValidateValueMethodName { get; set; } = string.Empty;
public string PropertyChangedMethodName { get; set; } = string.Empty;
public string PropertyChangingMethodName { get; set; } = string.Empty;
public string CoerceValueMethodName { get; set; } = string.Empty;
public string DefaultValueCreatorMethodName { get; set; } = string.Empty;
}
""";

protected static Task VerifySourceGeneratorAsync(string source, string expectedGenerated) =>
VerifySourceGeneratorAsync(source, expectedAttribute, ($"{defaultTestClassName}.g.cs", expectedGenerated));
}
Loading
Loading