Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions WinUI.TableView.slnx
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
<Solution>
<Folder Name="/samples/">
<Project Path="samples/AotTestApp/AotTestApp.csproj">
<Platform Project="x64" />
<Deploy />
</Project>
<Project Path="samples/WinUI.TableView.SampleApp.Uno/WinUI.TableView.SampleApp.Uno.csproj" />
<Project Path="samples/WinUI.TableView.SampleApp/WinUI.TableView.SampleApp.csproj">
<Platform Project="x64" />
<Deploy />
</Project>
</Folder>
<Project Path="generators/WinUI.TableView.SourceGenerators.csproj" />
<Project Path="src/WinUI.TableView.csproj" />
<Project Path="tests/WinUI.TableView.Tests.csproj">
<Platform Project="x64" />
Expand Down
11 changes: 11 additions & 0 deletions generators/AnalyzerReleases.Shipped.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
; Shipped analyzer releases
; https://github.com/dotnet/roslyn/blob/main/docs/analyzers/Analyzer%20Release%20Tracking.md

## Release 1.0.0
### New Rules
Rule ID | Category | Severity | Notes
--------|----------|----------|------
TV0001 | WinUI.TableView.SourceGenerators | Error | TableView must define x:Name or Name to enable generated connector code.
TV0002 | WinUI.TableView.SourceGenerators | Error | Unable to resolve TableView item type from x:Bind ItemsSource.
TV0003 | WinUI.TableView.SourceGenerators | Error | Window roots with generated TableView connectors must call ConnectTableViews() manually after InitializeComponent().
TV0004 | WinUI.TableView.SourceGenerators | Error | TableView member path could not be resolved for the inferred item type.
6 changes: 6 additions & 0 deletions generators/AnalyzerReleases.Unshipped.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
; Unshipped analyzer release
; https://github.com/dotnet/roslyn/blob/main/docs/analyzers/Analyzer%20Release%20Tracking.md

### New Rules
Rule ID | Category | Severity | Notes
--------|----------|----------|------
128 changes: 128 additions & 0 deletions generators/TableViewBindingProviderGenerator.Definitions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
using Microsoft.CodeAnalysis;
using System.Text.RegularExpressions;
namespace WinUI.TableView.SourceGenerators;
public sealed partial class TableViewBindingProviderGenerator
{
private static readonly DiagnosticDescriptor TableViewNameRequiredDescriptor =
new(
id: "TV0001",
title: "TableView requires a name for source generation",
messageFormat: "TableView in '{0}' must define x:Name or Name to enable generated code",
category: "WinUI.TableView.SourceGenerators",
defaultSeverity: DiagnosticSeverity.Error,
isEnabledByDefault: true);

private static readonly DiagnosticDescriptor UnableToResolveItemsTypeDescriptor =
new(
id: "TV0002",
title: "Unable to resolve TableView item type",
messageFormat: "TableView in '{0}' uses x:Bind ItemsSource '{1}', but the item type could not be resolved to a typed generic collection",
category: "WinUI.TableView.SourceGenerators",
defaultSeverity: DiagnosticSeverity.Error,
isEnabledByDefault: true);

private static readonly DiagnosticDescriptor WindowRequiresManualConnectDescriptor =
new(
id: "TV0003",
title: "Window containing TableView must call ConnectTableViews",
messageFormat: "Class '{0}' contains TableView in a Window. Call ConnectTableViews() in code-behind after InitializeComponent().",
category: "WinUI.TableView.SourceGenerators",
defaultSeverity: DiagnosticSeverity.Error,
isEnabledByDefault: true);

private static readonly DiagnosticDescriptor UnableToResolveMemberPathDescriptor =
new(
id: "TV0004",
title: "Unable to resolve TableView member path",
messageFormat: "TableView in '{0}' could not resolve member path '{1}' for item type '{2}'",
category: "WinUI.TableView.SourceGenerators",
defaultSeverity: DiagnosticSeverity.Error,
isEnabledByDefault: true);

private static readonly Regex XamlClassRegex =
new(
@"x:Class\s*=\s*[""'](?<className>[A-Za-z_][A-Za-z0-9_]*(?:\.[A-Za-z_][A-Za-z0-9_]*)*)[""']",
RegexOptions.Compiled | RegexOptions.IgnoreCase);

private static readonly Regex TableViewTagRegex =
new(
@"<\s*(?:(?<prefix>[A-Za-z_][A-Za-z0-9_]*)\:)?TableView(?=\s|/|>)",
RegexOptions.Compiled | RegexOptions.IgnoreCase);

private static readonly Regex XmlnsPrefixRegex =
new(
@"xmlns\:(?<prefix>[A-Za-z_][A-Za-z0-9_]*)\s*=\s*[""']using:WinUI\.TableView(?:;[^""']*)?[""']",
RegexOptions.Compiled | RegexOptions.IgnoreCase);

private static readonly Regex XmlnsDefaultRegex =
new(
@"xmlns\s*=\s*[""']using:WinUI\.TableView(?:;[^""']*)?[""']",
RegexOptions.Compiled | RegexOptions.IgnoreCase);

private static readonly Regex TableViewNameRegex =
new(
@"(?:x:Name|Name)\s*=\s*[""'](?<name>[A-Za-z_][A-Za-z0-9_]*)[""']",
RegexOptions.Compiled | RegexOptions.IgnoreCase);

private static readonly Regex ItemsSourceBindingRegex =
new(
@"ItemsSource\s*=\s*[""']\{(?<kind>x:Bind|Binding)\s*(?<body>[^}]*)\}[""']",
RegexOptions.Compiled | RegexOptions.IgnoreCase);

private static readonly Regex SortMemberPathRegex =
new(
@"SortMemberPath\s*=\s*[""'](?<path>[^""']+)[""']",
RegexOptions.Compiled | RegexOptions.IgnoreCase);

private static readonly Regex ClipboardBindingRegex =
new(
@"ClipboardContentBinding\s*=\s*[""']\{Binding\s*(?<body>[^}]*)\}[""']",
RegexOptions.Compiled | RegexOptions.IgnoreCase);

private static readonly Regex ContentBindingRegex =
new(
@"(?<![A-Za-z0-9_])ContentBinding\s*=\s*[""']\{Binding\s*(?<body>[^}]*)\}[""']",
RegexOptions.Compiled | RegexOptions.IgnoreCase);

private static readonly Regex DisplayMemberPathRegex =
new(
@"DisplayMemberPath\s*=\s*[""'](?<path>[^""']+)[""']",
RegexOptions.Compiled | RegexOptions.IgnoreCase);


private static readonly Regex CellBindingRegex =
new(
@"\bBinding\s*=\s*[""']\{Binding\s*(?<body>[^}]*)\}[""']",
RegexOptions.Compiled | RegexOptions.IgnoreCase);

private static readonly Regex BindingPathTokenRegex =
new(
@"(?:^|,)\s*Path\s*=\s*(?<path>[^,\s]+)",
RegexOptions.Compiled | RegexOptions.IgnoreCase);

private static readonly Regex BindingModeTokenRegex =
new(
@"(?:^|,)\s*Mode\s*=\s*(?<mode>[^,\s]+)",
RegexOptions.Compiled | RegexOptions.IgnoreCase);

private static readonly Regex NonSimpleBindingTokenRegex =
new(
@"(?:^|,)\s*(?:Source|RelativeSource|ElementName)\s*=",
RegexOptions.Compiled | RegexOptions.IgnoreCase);

private static readonly Regex ColumnTagRegex =
new(
@"<\s*(?:(?<prefix>[A-Za-z_][A-Za-z0-9_]*)\:)?(?<columnType>[A-Za-z_][A-Za-z0-9_]*Column)\b(?<attrs>[^>]*)>",
RegexOptions.Compiled | RegexOptions.IgnoreCase);

private static readonly Regex CSharpMemberPathRegex =
new(
@"^[A-Za-z_][A-Za-z0-9_]*(?:\.[A-Za-z_][A-Za-z0-9_]*)*$",
RegexOptions.Compiled);

private static readonly SymbolDisplayFormat FullyQualifiedNonAliasedTypeFormat =
SymbolDisplayFormat.FullyQualifiedFormat.WithMiscellaneousOptions(
SymbolDisplayFormat.FullyQualifiedFormat.MiscellaneousOptions
& ~SymbolDisplayMiscellaneousOptions.UseSpecialTypes);

}
Loading
Loading