Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nuget package badge and link #384

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
781967f
Add nuget package badge and link
WeihanLi Aug 17, 2022
c3077b2
Use table for better experience
WeihanLi Aug 18, 2022
83f1365
Update README.md
WeihanLi Aug 18, 2022
8bf3e7a
Merge branch 'main' into nuget-package-enhancement
WeihanLi Aug 19, 2022
730f53a
Code cleanup
heku Aug 20, 2022
c6b3a7f
Correct a typo in Converters.ToFileSizeString and add unit tests
heku Aug 20, 2022
783b5d1
Fix for using C# 8.0 projects (e.g. UWP projects stuck on .NET Core 3…
zhuman Aug 23, 2022
10e1e09
Fix ObservableValidatorValidateAllPropertiesGenerator and IMessengerR…
zhuman Aug 24, 2022
c3a784b
Update source generator tests to actually generate the compiled outpu…
zhuman Aug 24, 2022
54e1063
Code style tweaks
Sergio0694 Sep 8, 2022
1a71112
Fix unit tests for generators
Sergio0694 Sep 8, 2022
0f848dc
Enable Roslyn multi-targeting in the MVVM Toolkit generator
Sergio0694 Sep 8, 2022
27bf804
Enable multi-targeting Roslyn for unit test projects
Sergio0694 Sep 8, 2022
ebf8430
Run multi-targeted Roslyn projects in CI
Sergio0694 Sep 8, 2022
fa5bfcd
Only set OutputPath in generators during packing
Sergio0694 Sep 8, 2022
49a2d1c
Add draft UnsupportedCSharpLanguageVersionAnalyzer
Sergio0694 Sep 9, 2022
74a1bc8
Check parse options in UnsupportedCSharpLanguageVersionAnalyzer
Sergio0694 Sep 9, 2022
6594599
Remove FilterWithLanguageVersion method
Sergio0694 Sep 9, 2022
b8a6f8f
Fix condition in UnsupportedCSharpLanguageVersionAnalyzer
Sergio0694 Sep 9, 2022
5cb9d47
Add CSharpAnalyzerWithLanguageVersionTest<TAnalyzer> test helper
Sergio0694 Sep 9, 2022
07be158
Defer UnsupportedCSharpLanguageVersionAnalyzer symbol action registra…
Sergio0694 Sep 9, 2022
ad71dc7
Disable IMessenger and ObservableValidator when not on C# 8
Sergio0694 Sep 9, 2022
c16ffcf
Don't emit repeated diagnostics for same symbols
Sergio0694 Sep 9, 2022
bd05d12
Update generator/analyzer diagnostics unit tests
Sergio0694 Sep 9, 2022
92370ac
Adjust analyzer diagnostics unit tests to work on all TFMs
Sergio0694 Sep 9, 2022
579a77a
Fix Roslyn 4.0.1 unit test runs in CI script
Sergio0694 Sep 9, 2022
d234d01
Add FieldWithOrphanedDependentObservablePropertyAttributesAnalyzer
Sergio0694 Sep 10, 2022
a617061
Switch orphaned fields diagnostics to analyzer
Sergio0694 Sep 10, 2022
17da578
Don't propagate symbols in RelayCommandGenerator
Sergio0694 Sep 8, 2022
8df3bca
Don't propagate symbols in IMessengerRegisterAllGenerator
Sergio0694 Sep 8, 2022
815b9e5
Don't propagate symbols in ObservablePropertyGenerator
Sergio0694 Sep 10, 2022
9b1988f
Don't propagate symbols in ObservableValidatorValidateAllPropertiesGe…
Sergio0694 Sep 10, 2022
512187e
Don't propagate symbols in TransitiveMembersGenerator
Sergio0694 Sep 10, 2022
8e5c8d4
Improve syntactical filtering for messaging/validator generators
Sergio0694 Sep 10, 2022
240a724
Update URLs for Status Badges in Readme
michael-hawker Sep 13, 2022
90f4129
Add polyfills for ForAttributeWithMetadataName
Sergio0694 Sep 10, 2022
cc51581
Use ForAttributeWithMetadataName whenever possible
Sergio0694 Sep 10, 2022
6441e56
Fix Roslyn multi-targeting and testing
Sergio0694 Sep 10, 2022
344f83a
Restructure source generator into shared project
Sergio0694 Sep 12, 2022
beb370b
Switch to expression for project name Roslyn version
Sergio0694 Sep 12, 2022
e31561b
Remove custom output paths, fix assembly paths
Sergio0694 Sep 12, 2022
b95a09c
Fix embedded resource filenames
Sergio0694 Sep 12, 2022
f4e9e35
Restructure test projects into shared projects for multi-targeting
Sergio0694 Sep 13, 2022
e5f6f36
Add workaround for Roslyn 4.3 issues
Sergio0694 Sep 14, 2022
79b6317
Suppress IL2091 warnings where not needed
Sergio0694 Sep 14, 2022
a780a2f
Install .NET SDK from CI script
Sergio0694 Sep 16, 2022
3b16228
Workaround for ILLinker analyzer crash, fix trimming annotations
Sergio0694 Sep 16, 2022
58a6a86
Suppress CA1001 warnings in MVVM Toolkit
Sergio0694 Sep 16, 2022
a1a812d
Suppress CA2252 warnings
Sergio0694 Sep 16, 2022
0b837bc
Install the .NET 6 SDK in CI script
Sergio0694 Sep 16, 2022
2f8dae6
Install the .NET Core 3.1 SDK in CI script
Sergio0694 Sep 16, 2022
0c74a7a
Remove the source generator since not a package
WeihanLi Sep 17, 2022
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
2 changes: 1 addition & 1 deletion CommunityToolkit.Common/Converters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static string ToFileSizeString(long size)
}
else
{
return ((size >> 50) / 1024F).ToString("F0") + " EB";
return ((size >> 50) / 1024F).ToString("F1") + " EB";
}
}
}
4 changes: 2 additions & 2 deletions CommunityToolkit.Common/Extensions/EventHandlerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ public static Task InvokeAsync<T>(this EventHandler<T>? eventHandler, object sen
invocationDelegate(sender, eventArgs);

#pragma warning disable CS0618 // Type or member is obsolete
EventDeferral? deferral = eventArgs.GetCurrentDeferralAndReset();
EventDeferral? deferral = eventArgs.GetCurrentDeferralAndReset();

return deferral?.WaitForCompletion(cancellationToken) ?? Task.CompletedTask;
#pragma warning restore CS0618 // Type or member is obsolete
})
})
.ToArray();

return Task.WhenAll(tasks);
Expand Down
6 changes: 2 additions & 4 deletions CommunityToolkit.Common/Extensions/TaskExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ public static class TaskExtensions
/// and uses reflection to access the <see cref="Task{TResult}.Result"/> property and boxes the result if it's
/// a value type, which adds overhead. It should only be used when using generics is not possible.
/// </remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static object? GetResultOrDefault(
#if NET6_0_OR_GREATER
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)]
[RequiresUnreferencedCode("This method uses reflection to try to access the Task<T>.Result property of the input Task instance.")]
#endif
this Task task)
public static object? GetResultOrDefault(this Task task)
{
// Check if the instance is a completed Task
if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ public interface IIncrementalSource<TSource>
/// <returns>
/// Returns a collection of <typeparamref name="TSource"/>.
/// </returns>
Task<IEnumerable<TSource>> GetPagedItemsAsync(int pageIndex, int pageSize, CancellationToken cancellationToken = default(CancellationToken));
Task<IEnumerable<TSource>> GetPagedItemsAsync(int pageIndex, int pageSize, CancellationToken cancellationToken = default);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="..\CommunityToolkit.Mvvm.SourceGenerators\CommunityToolkit.Mvvm.SourceGenerators.props" />
<Import Project="..\CommunityToolkit.Mvvm.SourceGenerators\CommunityToolkit.Mvvm.SourceGenerators.projitems" Label="Shared" />

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="..\CommunityToolkit.Mvvm.SourceGenerators\CommunityToolkit.Mvvm.SourceGenerators.props" />
<Import Project="..\CommunityToolkit.Mvvm.SourceGenerators\CommunityToolkit.Mvvm.SourceGenerators.projitems" Label="Shared" />

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
private static string LoadAttributeSourceWithMetadataName(string typeFullName)
{
string typeName = typeFullName.Split('.').Last();
string filename = $"CommunityToolkit.Mvvm.SourceGenerators.EmbeddedResources.{typeName}.cs";
string filename = $"{typeName}.cs";

Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(filename);
StreamReader reader = new(stream);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects Condition="'$(MSBuildVersion)' == '' Or '$(MSBuildVersion)' &lt; '16.0'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<HasSharedItems>true</HasSharedItems>
<SharedGUID>5e7f1212-a54b-40ca-98c5-1ff5cd1a1638</SharedGUID>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<Import_RootNamespace>CommunityToolkit.Mvvm.SourceGenerators</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)EmbeddedResources\INotifyPropertyChanged.cs">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<LogicalName>INotifyPropertyChanged.cs</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)EmbeddedResources\NotNullAttribute.cs">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<LogicalName>NotNullAttribute.cs</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)EmbeddedResources\NotNullIfNotNullAttribute.cs">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<LogicalName>NotNullIfNotNullAttribute.cs</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)EmbeddedResources\ObservableObject.cs">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<LogicalName>ObservableObject.cs</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)EmbeddedResources\ObservableRecipient.cs">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<LogicalName>ObservableRecipient.cs</LogicalName>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)Attributes\NotNullWhenAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Attributes\NullabilityAttributesGenerator.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ComponentModel\INotifyPropertyChangedGenerator.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ComponentModel\Models\AttributeInfo.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ComponentModel\Models\INotifyPropertyChangedInfo.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ComponentModel\Models\ObservableRecipientInfo.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ComponentModel\Models\PropertyInfo.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ComponentModel\Models\TypedConstantInfo.Comparer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ComponentModel\Models\TypedConstantInfo.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ComponentModel\Models\TypedConstantInfo.Factory.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ComponentModel\Models\ValidationInfo.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ComponentModel\ObservableObjectGenerator.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ComponentModel\ObservablePropertyGenerator.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ComponentModel\ObservablePropertyGenerator.Execute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ComponentModel\ObservableRecipientGenerator.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ComponentModel\ObservableValidatorValidateAllPropertiesGenerator.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ComponentModel\ObservableValidatorValidateAllPropertiesGenerator.Execute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ComponentModel\TransitiveMembersGenerator.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ComponentModel\TransitiveMembersGenerator.Execute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Diagnostics\Analyzers\FieldWithOrphanedDependentObservablePropertyAttributesAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Diagnostics\Analyzers\UnsupportedCSharpLanguageVersionAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Diagnostics\DiagnosticDescriptors.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Diagnostics\DiagnosticExtensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Extensions\AttributeDataExtensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Extensions\CompilationExtensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Extensions\HashCodeExtensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Extensions\IEqualityComparerExtensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Extensions\INamedTypeSymbolExtensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Extensions\IncrementalGeneratorInitializationContextExtensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Extensions\IncrementalValuesProviderExtensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Extensions\ISymbolExtensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Extensions\ITypeSymbolExtensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Extensions\MemberDeclarationSyntaxExtensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Extensions\SyntaxNodeExtensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Extensions\TypeDeclarationSyntaxExtensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Helpers\Comparer{T,TSelf}.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Helpers\HashCode.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Input\Models\CanExecuteExpressionType.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Input\Models\CommandInfo.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Input\RelayCommandGenerator.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Input\RelayCommandGenerator.Execute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Messaging\IMessengerRegisterAllGenerator.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Messaging\IMessengerRegisterAllGenerator.Execute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Messaging\Models\RecipientInfo.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Models\HierarchyInfo.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Models\HierarchyInfo.Syntax.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Models\Result.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Models\TypeInfo.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Polyfills\GeneratorAttributeSyntaxContext.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Polyfills\SyntaxValueProviderExtensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System.Runtime.CompilerServices\IsExternalInit.cs" />
</ItemGroup>
<ItemGroup>
<AdditionalFiles Include="$(MSBuildThisFileDirectory)AnalyzerReleases.Shipped.md" />
<AdditionalFiles Include="$(MSBuildThisFileDirectory)AnalyzerReleases.Unshipped.md" />
</ItemGroup>
<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)CommunityToolkit.Mvvm.SourceGenerators.props" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<Project>

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

<!--
The MVVM Toolkit source generators rely on Roslyn multi-targeting to support multiple versions of the Microsoft.CodeAnalysis.CSharp package.
This package reference actually needs a matching version of Roslyn to be available for consumers of the source generator, so if we always
used the latest version, the MVVM Toolkit would just fail to load for users of eg. an older version of Visual Studio. Thankfully, Roslyn
supports analyzers that bundle multiple versions in the same NuGet package, each in a subfolder with a name matching the Roslyn version.
To leverage this, this project receives the MvvmToolkitSourceGeneratorRoslynVersion property as input, so that the MVVM Toolkit can build
it multiple times with multiple versions during packing, to then extract each .dll and copy it to the right NuGet package folder.
-->
<PropertyGroup>

<!-- Set the assembly name to always be the same, regardless of the Roslyn version being targeted (cut the trailing ".RoslynXYZ" suffix) -->
<AssemblyName>$(MSBuildProjectName.Substring(0, $([MSBuild]::Subtract($(MSBuildProjectName.Length), 10))))</AssemblyName>

<!--
Get the Roslyn version to use from the name of the project importing this .props file.
All projects will use the "<PROJECT_NAME>.Roslyn<MAJOR><MINOR><PATCH>.csproj" naming scheme.
-->
<MvvmToolkitSourceGeneratorRoslynMajorVersion>$(MSBuildProjectName.Substring($([MSBuild]::Subtract($(MSBuildProjectName.Length), 3)), 1))</MvvmToolkitSourceGeneratorRoslynMajorVersion>
<MvvmToolkitSourceGeneratorRoslynMinorVersion>$(MSBuildProjectName.Substring($([MSBuild]::Subtract($(MSBuildProjectName.Length), 2)), 1))</MvvmToolkitSourceGeneratorRoslynMinorVersion>
<MvvmToolkitSourceGeneratorRoslynPatchVersion>$(MSBuildProjectName.Substring($([MSBuild]::Subtract($(MSBuildProjectName.Length), 1)), 1))</MvvmToolkitSourceGeneratorRoslynPatchVersion>
<MvvmToolkitSourceGeneratorRoslynVersion>$(MvvmToolkitSourceGeneratorRoslynMajorVersion).$(MvvmToolkitSourceGeneratorRoslynMinorVersion).$(MvvmToolkitSourceGeneratorRoslynPatchVersion)</MvvmToolkitSourceGeneratorRoslynVersion>

<!-- Workaround for https://github.com/dotnet/roslyn/issues/63919 -->
<MvvmToolkitSourceGeneratorRoslynVersion Condition="'$(MvvmToolkitSourceGeneratorRoslynVersion)' == '4.3.0'">4.4.0-1.final</MvvmToolkitSourceGeneratorRoslynVersion>

<!-- Also define "ROSLYN_<MAJOR>_<MINOR>_OR_GREATER" build constants, so the generator code can multi-target whenever needed and add any required polyfills -->
<DefineConstants Condition="$([MSBuild]::VersionGreaterThanOrEquals($(MvvmToolkitSourceGeneratorRoslynVersion), 4.3))">$(DefineConstants);ROSLYN_4_3_0_OR_GREATER</DefineConstants>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="$(MvvmToolkitSourceGeneratorRoslynVersion)" PrivateAssets="all" Pack="false" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>5e7f1212-a54b-40ca-98c5-1ff5cd1a1638</ProjectGuid>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
<PropertyGroup />
<Import Project="CommunityToolkit.Mvvm.SourceGenerators.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -23,38 +23,23 @@ public sealed class INotifyPropertyChangedGenerator : TransitiveMembersGenerator
/// Initializes a new instance of the <see cref="INotifyPropertyChangedGenerator"/> class.
/// </summary>
public INotifyPropertyChangedGenerator()
: base("global::CommunityToolkit.Mvvm.ComponentModel.INotifyPropertyChangedAttribute")
: base("CommunityToolkit.Mvvm.ComponentModel.INotifyPropertyChangedAttribute")
{
}

/// <inheritdoc/>
protected override IncrementalValuesProvider<(INamedTypeSymbol Symbol, INotifyPropertyChangedInfo Info)> GetInfo(
IncrementalGeneratorInitializationContext context,
IncrementalValuesProvider<(INamedTypeSymbol Symbol, AttributeData AttributeData)> source)
{
static INotifyPropertyChangedInfo GetInfo(INamedTypeSymbol typeSymbol, AttributeData attributeData)
{
bool includeAdditionalHelperMethods = attributeData.GetNamedArgument("IncludeAdditionalHelperMethods", true);

return new(includeAdditionalHelperMethods);
}

return source.Select(static (item, _) => (item.Symbol, GetInfo(item.Symbol, item.AttributeData)));
}

/// <inheritdoc/>
protected override bool ValidateTargetType(INamedTypeSymbol typeSymbol, INotifyPropertyChangedInfo info, out ImmutableArray<Diagnostic> diagnostics)
protected override INotifyPropertyChangedInfo? ValidateTargetTypeAndGetInfo(INamedTypeSymbol typeSymbol, AttributeData attributeData, Compilation compilation, out ImmutableArray<Diagnostic> diagnostics)
{
ImmutableArray<Diagnostic>.Builder builder = ImmutableArray.CreateBuilder<Diagnostic>();

INotifyPropertyChangedInfo? info = null;

// Check if the type already implements INotifyPropertyChanged
if (typeSymbol.AllInterfaces.Any(i => i.HasFullyQualifiedName("global::System.ComponentModel.INotifyPropertyChanged")))
{
builder.Add(DuplicateINotifyPropertyChangedInterfaceForINotifyPropertyChangedAttributeError, typeSymbol, typeSymbol);

diagnostics = builder.ToImmutable();

return false;
goto End;
}

// Check if the type uses [INotifyPropertyChanged] or [ObservableObject] already (in the type hierarchy too)
Expand All @@ -63,14 +48,17 @@ protected override bool ValidateTargetType(INamedTypeSymbol typeSymbol, INotifyP
{
builder.Add(InvalidAttributeCombinationForINotifyPropertyChangedAttributeError, typeSymbol, typeSymbol);

diagnostics = builder.ToImmutable();

return false;
goto End;
}

bool includeAdditionalHelperMethods = attributeData.GetNamedArgument("IncludeAdditionalHelperMethods", true);

info = new INotifyPropertyChangedInfo(includeAdditionalHelperMethods);

End:
diagnostics = builder.ToImmutable();

return true;
return info;
}

/// <inheritdoc/>
Expand Down
Loading