Skip to content

Commit e7c55af

Browse files
authored
Update documentation (#39)
1 parent 0be0cfd commit e7c55af

File tree

5 files changed

+40
-8
lines changed

5 files changed

+40
-8
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,5 +365,26 @@ public partial class MyReactiveControl : UserControl
365365
}
366366
```
367367

368+
## Platform specific Attributes
369+
370+
### WinForms
371+
372+
#### RoutedControlHost
373+
```csharp
374+
using ReactiveUI.SourceGenerators.WinForms;
375+
376+
[RoutedControlHost("YourNameSpace.CustomControl")]
377+
public partial class MyCustomRoutedControlHost;
378+
```
379+
380+
#### ViewModelControlHost
381+
```csharp
382+
using ReactiveUI.SourceGenerators.WinForms;
383+
384+
[ViewModelControlHost("YourNameSpace.CustomControl")]
385+
public partial class MyCustomViewModelControlHost;
386+
```
387+
388+
368389
### TODO:
369390
- Add ObservableAsProperty to generate from a IObservable method with parameters.

src/ReactiveUI.SourceGenerators/IViewFor/IViewForGenerator.Execute.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Microsoft.CodeAnalysis;
99
using Microsoft.CodeAnalysis.CSharp;
1010
using Microsoft.CodeAnalysis.CSharp.Syntax;
11+
using ReactiveUI.SourceGenerators.Helpers;
1112
using ReactiveUI.SourceGenerators.Input.Models;
1213
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
1314

@@ -66,7 +67,7 @@ internal static CompilationUnitSyntax GetIViewForWpfWinUiUno(IViewForInfo iViewF
6667
IdentifierName(iViewForInfo.ViewModelTypeName))))))
6768
.AddModifiers([.. iViewForInfo.DeclarationSyntax.Modifiers])
6869
.AddAttributeLists(AttributeList(SingletonSeparatedList(
69-
Attribute(IdentifierName(GeneratedCode))
70+
Attribute(IdentifierName(AttributeDefinitions.GeneratedCode))
7071
.AddArgumentListArguments(
7172
AttributeArgument(LiteralExpression(SyntaxKind.StringLiteralExpression, Literal(typeof(IViewForGenerator).FullName))),
7273
AttributeArgument(LiteralExpression(SyntaxKind.StringLiteralExpression, Literal(typeof(IViewForGenerator).Assembly.GetName().Version.ToString())))))))))
@@ -159,7 +160,7 @@ internal static CompilationUnitSyntax GetIViewForWinForms(IViewForInfo iViewForI
159160
IdentifierName(iViewForInfo.ViewModelTypeName))))))
160161
.AddModifiers([.. iViewForInfo.DeclarationSyntax.Modifiers])
161162
.AddAttributeLists(AttributeList(SingletonSeparatedList(
162-
Attribute(IdentifierName(GeneratedCode))
163+
Attribute(IdentifierName(AttributeDefinitions.GeneratedCode))
163164
.AddArgumentListArguments(
164165
AttributeArgument(LiteralExpression(SyntaxKind.StringLiteralExpression, Literal(typeof(IViewForGenerator).FullName))),
165166
AttributeArgument(LiteralExpression(SyntaxKind.StringLiteralExpression, Literal(typeof(IViewForGenerator).Assembly.GetName().Version.ToString())))))))))
@@ -232,7 +233,7 @@ internal static CompilationUnitSyntax GetIViewForAvalonia(IViewForInfo iViewForI
232233
IdentifierName(iViewForInfo.ViewModelTypeName))))))
233234
.AddModifiers([.. iViewForInfo.DeclarationSyntax.Modifiers])
234235
.AddAttributeLists(AttributeList(SingletonSeparatedList(
235-
Attribute(IdentifierName(GeneratedCode))
236+
Attribute(IdentifierName(AttributeDefinitions.GeneratedCode))
236237
.AddArgumentListArguments(
237238
AttributeArgument(LiteralExpression(SyntaxKind.StringLiteralExpression, Literal(typeof(IViewForGenerator).FullName))),
238239
AttributeArgument(LiteralExpression(SyntaxKind.StringLiteralExpression, Literal(typeof(IViewForGenerator).Assembly.GetName().Version.ToString())))))))))
@@ -346,7 +347,7 @@ internal static CompilationUnitSyntax GetIViewForMaui(IViewForInfo iViewForInfo)
346347
IdentifierName(iViewForInfo.ViewModelTypeName))))))
347348
.AddModifiers([.. iViewForInfo.DeclarationSyntax.Modifiers])
348349
.AddAttributeLists(AttributeList(SingletonSeparatedList(
349-
Attribute(IdentifierName(GeneratedCode))
350+
Attribute(IdentifierName(AttributeDefinitions.GeneratedCode))
350351
.AddArgumentListArguments(
351352
AttributeArgument(LiteralExpression(SyntaxKind.StringLiteralExpression, Literal(typeof(IViewForGenerator).FullName))),
352353
AttributeArgument(LiteralExpression(SyntaxKind.StringLiteralExpression, Literal(typeof(IViewForGenerator).Assembly.GetName().Version.ToString())))))))))

src/ReactiveUI.SourceGenerators/IViewFor/IViewForGenerator.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ namespace ReactiveUI.SourceGenerators;
2626
[Generator(LanguageNames.CSharp)]
2727
public sealed partial class IViewForGenerator : IIncrementalGenerator
2828
{
29-
private const string GeneratedCode = "global::System.CodeDom.Compiler.GeneratedCode";
30-
3129
/// <inheritdoc/>
3230
public void Initialize(IncrementalGeneratorInitializationContext context)
3331
{

src/ReactiveUI.SourceGenerators/RoutedControlHost/RoutedControlHostGenerator.Execute.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Microsoft.CodeAnalysis;
1010
using Microsoft.CodeAnalysis.CSharp;
1111
using Microsoft.CodeAnalysis.CSharp.Syntax;
12+
using ReactiveUI.SourceGenerators.Helpers;
1213
using ReactiveUI.SourceGenerators.Input.Models;
1314
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
1415

@@ -82,7 +83,12 @@ internal static CompilationUnitSyntax GetRoutedControlHost(RoutedControlHostInfo
8283
SimpleBaseType(IdentifierName(vmcInfo.ViewModelTypeName)),
8384
Token(SyntaxKind.CommaToken),
8485
SimpleBaseType(IdentifierName("IReactiveObject"))
85-
})))))))
86+
})))
87+
.AddAttributeLists(AttributeList(SingletonSeparatedList(
88+
Attribute(IdentifierName(AttributeDefinitions.GeneratedCode))
89+
.AddArgumentListArguments(
90+
AttributeArgument(LiteralExpression(SyntaxKind.StringLiteralExpression, Literal(typeof(RoutedControlHostGenerator).FullName))),
91+
AttributeArgument(LiteralExpression(SyntaxKind.StringLiteralExpression, Literal(typeof(RoutedControlHostGenerator).Assembly.GetName().Version.ToString())))))))))))
8692
.NormalizeWhitespace().ToFullString();
8793

8894
// Remove the last 4 characters to remove the closing brackets

src/ReactiveUI.SourceGenerators/ViewModelControlHost/ViewModelControlHostGenerator.Execute.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Microsoft.CodeAnalysis;
1010
using Microsoft.CodeAnalysis.CSharp;
1111
using Microsoft.CodeAnalysis.CSharp.Syntax;
12+
using ReactiveUI.SourceGenerators.Helpers;
1213
using ReactiveUI.SourceGenerators.Input.Models;
1314
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
1415

@@ -84,7 +85,12 @@ internal static CompilationUnitSyntax GetViewModelControlHost(ViewModelControlHo
8485
SimpleBaseType(IdentifierName("IReactiveObject")),
8586
Token(SyntaxKind.CommaToken),
8687
SimpleBaseType(IdentifierName("IViewFor"))
87-
})))))))
88+
})))
89+
.AddAttributeLists(AttributeList(SingletonSeparatedList(
90+
Attribute(IdentifierName(AttributeDefinitions.GeneratedCode))
91+
.AddArgumentListArguments(
92+
AttributeArgument(LiteralExpression(SyntaxKind.StringLiteralExpression, Literal(typeof(ViewModelControlHostGenerator).FullName))),
93+
AttributeArgument(LiteralExpression(SyntaxKind.StringLiteralExpression, Literal(typeof(ViewModelControlHostGenerator).Assembly.GetName().Version.ToString())))))))))))
8894
.NormalizeWhitespace().ToFullString();
8995

9096
// Remove the last 4 characters to remove the closing brackets

0 commit comments

Comments
 (0)