Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/ReactiveUI.SourceGenerators.sln
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
# 17
VisualStudioVersion = 17.10.35027.167
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionConfig", "SolutionConfig", "{F29AF2F3-DEC8-58BC-043A-1447862C832D}"
Expand Down
88 changes: 46 additions & 42 deletions src/ReactiveUI.SourceGenerators/AnalyzerReleases.Shipped.md
Original file line number Diff line number Diff line change
@@ -1,78 +1,82 @@
; Shipped analyzer releases
; https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md

## Release 1.0

### New Rules

Rule ID | Category | Severity | Notes
--------|----------|----------|-------
RXUISG0001 | ReactiveUI.SourceGenerators.UnsupportedCSharpLanguageVersionAnalyzer | Error | See https://www.reactiveui.net/docs/handbook/view-models/boilerplate-code.html
RXUISG0002 | ReactiveUI.SourceGenerators.ReactiveCommandGenerator | Error | See https://www.reactiveui.net/docs/handbook/view-models/boilerplate-code.html
RXUISG0003 | ReactiveUI.SourceGenerators.ReactiveCommandGenerator | Error | See https://www.reactiveui.net/docs/handbook/view-models/boilerplate-code.html
RXUISG0004 | ReactiveUI.SourceGenerators.ReactiveCommandGenerator | Error | See https://www.reactiveui.net/docs/handbook/view-models/boilerplate-code.html
RXUISG0005 | ReactiveUI.SourceGenerators.ReactiveCommandGenerator | Error | See https://www.reactiveui.net/docs/handbook/view-models/boilerplate-code.html
RXUISG0006 | ReactiveUI.SourceGenerators.ReactiveCommandGenerator | Error | See https://www.reactiveui.net/docs/handbook/view-models/boilerplate-code.html
RXUISG0007 | ReactiveUI.SourceGenerators.ReactiveCommandGenerator | Error | See https://www.reactiveui.net/docs/handbook/view-models/boilerplate-code.html
RXUISG0008 | ReactiveUI.SourceGenerators.AsyncVoidReturningReactiveCommandMethodAnalyzer | Error | See https://www.reactiveui.net/docs/handbook/view-models/boilerplate-code.html
RXUISG0009 | ReactiveUI.SourceGenerators.ReactiveGenerator | Error | See https://www.reactiveui.net/docs/handbook/view-models/boilerplate-code.html
RXUISG0010 | ReactiveUI.SourceGenerators.ReactiveGenerator | Error | See https://www.reactiveui.net/docs/handbook/view-models/boilerplate-code.html
RXUISG0011 | ReactiveUI.SourceGenerators.ReactiveGenerator | Error | See https://www.reactiveui.net/docs/handbook/view-models/boilerplate-code.html
RXUISG0012 | ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator | Error | See https://www.reactiveui.net/docs/handbook/view-models/boilerplate-code.html
RXUISG0013 | ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator | Error | See https://www.reactiveui.net/docs/handbook/view-models/boilerplate-code.html
RXUISG0014 | ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator | Error | See https://www.reactiveui.net/docs/handbook/view-models/boilerplate-code.html
RXUISG0015 | ReactiveUI.SourceGenerators.ReactiveGenerator | Error | See https://www.reactiveui.net/docs/handbook/view-models/boilerplate-code.html
RXUISG0016 | ReactiveUI.SourceGenerators.PropertyToReactiveFieldCodeFixProvider | Info | See https://www.reactiveui.net/docs/handbook/view-models/boilerplate-code.html
RXUISG0017 | ReactiveUI.SourceGenerators.ObservableAsPropertyFromObservableGenerator | Error | See https://www.reactiveui.net/docs/handbook/view-models/boilerplate-code.html


## Rules
Shipped in ReactiveUI.SourceGenerators

### RXUISG0001 - Unsupported C# Language Version
This rule checks if the project is using an unsupported C# language version. The supported versions are C# 7.3 and above. If the project is using an unsupported version, the rule will raise an error.
- RXUISG0001 - Unsupported C# Language Version
This rule checks if the project is using an unsupported C# language version. The supported versions are C# 12.0 and above. If the project is using an unsupported version, the rule will raise an error.

### RXUISG0002 - ReactiveCommandGenerator
- RXUISG0002 - ReactiveCommandGenerator
This rule checks if the `ReactiveCommand` has a Invalid ReactiveCommand method signature.

### RXUISG0003 - ReactiveCommandGenerator
- RXUISG0003 - ReactiveCommandGenerator
This rule checks if the `ReactiveCommand` has a Invalid ReactiveCommand.CanExecute member name.

### RXUISG0004 - ReactiveCommandGenerator
- RXUISG0004 - ReactiveCommandGenerator
This rule checks if the `ReactiveCommand` has Multiple ReactiveCommand.CanExecute member name matches.

### RXUISG0005 - ReactiveCommandGenerator
- RXUISG0005 - ReactiveCommandGenerator
This rule checks if the `ReactiveCommand` has No valid ReactiveCommand.CanExecute member match.

### RXUISG0006 - ReactiveCommandGenerator
- RXUISG0006 - ReactiveCommandGenerator
This rule checks if the `ReactiveCommand` has Invalid field or property targeted attribute type.

### RXUISG0007 - ReactiveCommandGenerator
- RXUISG0007 - ReactiveCommandGenerator
This rule checks if the `ReactiveCommand` has Invalid field or property targeted attribute expression.

### RXUISG0008 - AsyncVoidReturningReactiveCommandMethodAnalyzer
- RXUISG0008 - AsyncVoidReturningReactiveCommandMethodAnalyzer
This rule checks if the `ReactiveCommand` has Async void returning method annotated with ReactiveCommand.

### RXUISG0009 - ReactiveGenerator
- RXUISG0009 - ReactiveGenerator
This rule checks if the `Reactive` has Name collision for generated property.

### RXUISG0010 - ReactiveGenerator
- RXUISG0010 - ReactiveGenerator
This rule checks if the `Reactive` has Invalid property targeted attribute type.

### RXUISG0011 - ReactiveGenerator
- RXUISG0011 - ReactiveGenerator
This rule checks if the `Reactive` has Invalid property targeted attribute expression.

### RXUISG0012 - ObservableAsPropertyGenerator
- RXUISG0012 - ObservableAsPropertyGenerator
This rule checks if the `ObservableAsProperty` has Invalid property targeted attribute type.

### RXUISG0013 - ObservableAsPropertyGenerator
- RXUISG0013 - ObservableAsPropertyGenerator
This rule checks if the `ObservableAsProperty` has Invalid property targeted attribute expression.

### RXUISG0014 - ObservableAsPropertyGenerator
- RXUISG0014 - ObservableAsPropertyGenerator
This rule checks if the `ObservableAsProperty` has Invalid generated property declaration.

### RXUISG0015 - ReactiveGenerator
- RXUISG0015 - ReactiveGenerator
This rule checks if the `Reactive` attribute is being used correctly. If the `Reactive` has Invalid generated property declaration.

### RXUISG0016 - PropertyToReactiveFieldCodeFixProvider
- RXUISG0016 - PropertyToReactiveFieldCodeFixProvider
This rule checks if there are any Properties to change to Reactive Field, change to [Reactive] private type _fieldName;.

### RXUISG0017 - ObservableAsPropertyFromObservableGenerator
- RXUISG0017 - ObservableAsPropertyFromObservableGenerator
This rule checks if the `ObservableAsProperty` has Invalid generated property declaration.


## Release 1.0

### New Rules

Rule ID | Category | Severity | Notes
--------|----------|----------|-------
RXUISG0001 | ReactiveUI.SourceGenerators.UnsupportedCSharpLanguageVersionAnalyzer | Error | See https://www.reactiveui.net/docs/handbook/view-models/boilerplate-code.html
RXUISG0002 | ReactiveUI.SourceGenerators.ReactiveCommandGenerator | Error | See https://www.reactiveui.net/docs/handbook/view-models/boilerplate-code.html
RXUISG0003 | ReactiveUI.SourceGenerators.ReactiveCommandGenerator | Error | See https://www.reactiveui.net/docs/handbook/view-models/boilerplate-code.html
RXUISG0004 | ReactiveUI.SourceGenerators.ReactiveCommandGenerator | Error | See https://www.reactiveui.net/docs/handbook/view-models/boilerplate-code.html
RXUISG0005 | ReactiveUI.SourceGenerators.ReactiveCommandGenerator | Error | See https://www.reactiveui.net/docs/handbook/view-models/boilerplate-code.html
RXUISG0006 | ReactiveUI.SourceGenerators.ReactiveCommandGenerator | Error | See https://www.reactiveui.net/docs/handbook/view-models/boilerplate-code.html
RXUISG0007 | ReactiveUI.SourceGenerators.ReactiveCommandGenerator | Error | See https://www.reactiveui.net/docs/handbook/view-models/boilerplate-code.html
RXUISG0008 | ReactiveUI.SourceGenerators.AsyncVoidReturningReactiveCommandMethodAnalyzer | Error | See https://www.reactiveui.net/docs/handbook/view-models/boilerplate-code.html
RXUISG0009 | ReactiveUI.SourceGenerators.ReactiveGenerator | Error | See https://www.reactiveui.net/docs/handbook/view-models/boilerplate-code.html
RXUISG0010 | ReactiveUI.SourceGenerators.ReactiveGenerator | Error | See https://www.reactiveui.net/docs/handbook/view-models/boilerplate-code.html
RXUISG0011 | ReactiveUI.SourceGenerators.ReactiveGenerator | Error | See https://www.reactiveui.net/docs/handbook/view-models/boilerplate-code.html
RXUISG0012 | ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator | Error | See https://www.reactiveui.net/docs/handbook/view-models/boilerplate-code.html
RXUISG0013 | ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator | Error | See https://www.reactiveui.net/docs/handbook/view-models/boilerplate-code.html
RXUISG0014 | ReactiveUI.SourceGenerators.ObservableAsPropertyGenerator | Error | See https://www.reactiveui.net/docs/handbook/view-models/boilerplate-code.html
RXUISG0015 | ReactiveUI.SourceGenerators.ReactiveGenerator | Error | See https://www.reactiveui.net/docs/handbook/view-models/boilerplate-code.html
RXUISG0016 | ReactiveUI.SourceGenerators.PropertyToReactiveFieldCodeFixProvider | Info | See https://www.reactiveui.net/docs/handbook/view-models/boilerplate-code.html
RXUISG0017 | ReactiveUI.SourceGenerators.ObservableAsPropertyFromObservableGenerator | Error | See https://www.reactiveui.net/docs/handbook/view-models/boilerplate-code.html
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
[Unshipped analyzer release](https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md)
; Unshipped analyzer releases
; https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,76 @@ public static string FormatAttributes(this PropertyAttributeData attr)

return $"[{namespacePrefix}{attr.AttributeSyntax}]";
}

/// <summary>
/// Gathers the forwarded attributes from class.
/// </summary>
/// <param name="attributeData">The attribute data.</param>
/// <param name="semanticModel">The semantic model.</param>
/// <param name="classDeclaration">The class declaration.</param>
/// <param name="token">The token.</param>
/// <param name="classAttributesInfo">The class attributes information.</param>
public static void GatherForwardedAttributesFromClass(
this AttributeData attributeData,
SemanticModel semanticModel,
ClassDeclarationSyntax classDeclaration,
CancellationToken token,
out ImmutableArray<AttributeInfo> classAttributesInfo)
{
using var classAttributesInfoBuilder = ImmutableArrayBuilder<AttributeInfo>.Rent();

static void GatherForwardedAttributes(
AttributeData attributeData,
SemanticModel semanticModel,
ClassDeclarationSyntax classDeclaration,
CancellationToken token,
ImmutableArrayBuilder<AttributeInfo> classAttributesInfo)
{
// Gather explicit forwarded attributes info
foreach (var attributeList in classDeclaration.AttributeLists)
{
foreach (var attribute in attributeList.Attributes)
{
if (!semanticModel.GetSymbolInfo(attribute, token).TryGetAttributeTypeSymbol(out var attributeTypeSymbol))
{
continue;
}

var attributeArguments = attribute.ArgumentList?.Arguments ?? Enumerable.Empty<AttributeArgumentSyntax>();

// Try to extract the forwarded attribute
if (!AttributeInfo.TryCreate(attributeTypeSymbol, semanticModel, attributeArguments, token, out var attributeInfo))
{
continue;
}

var ignoreAttribute = attributeData.AttributeClass?.GetFullyQualifiedMetadataName();
if (attributeInfo.TypeName.Contains(ignoreAttribute))
{
continue;
}

// Add the new attribute info to the right builder
classAttributesInfo.Add(attributeInfo);
}
}
}

// If the method is not a partial definition/implementation, just gather attributes from the method with no modifications
GatherForwardedAttributes(attributeData, semanticModel, classDeclaration, token, classAttributesInfoBuilder);

classAttributesInfo = classAttributesInfoBuilder.ToImmutable();
}

/// <summary>
/// Gets the type of the generic.
/// </summary>
/// <param name="attributeData">The attribute data.</param>
/// <returns>A String.</returns>
public static string? GetGenericType(this AttributeData attributeData)
{
var success = attributeData?.AttributeClass?.ToDisplayString();
var start = success?.IndexOf('<') + 1 ?? 0;
return success?.Substring(start, success.Length - start - 1);
}
}
Loading