|
1 | 1 | // Licensed to the .NET Foundation under one or more agreements. |
2 | 2 | // The .NET Foundation licenses this file to you under the MIT license. |
3 | 3 |
|
4 | | -using System; |
5 | | -using System.Threading; |
6 | | -using System.Threading.Tasks; |
7 | 4 | using Microsoft.CodeAnalysis; |
8 | 5 | using Microsoft.CodeAnalysis.CSharp; |
9 | 6 | using Microsoft.CodeAnalysis.CSharp.Syntax; |
|
12 | 9 | namespace Silk.NET.SilkTouch.Mods; |
13 | 10 |
|
14 | 11 | /// <summary> |
15 | | -/// Applies transformations to property signatures. |
| 12 | +/// Applies transformations to fields and properties. |
16 | 13 | /// </summary> |
17 | 14 | /// <remarks> |
18 | | -/// Today, this only includes transforming properties like <c>static ReadOnlySpan<byte> Thing => "thing"u8;</c> |
19 | | -/// to be <c>static Utf8String Thing => "thing"u8;</c>. |
| 15 | +/// Despite the name of the name, fields are also handled here because |
| 16 | +/// they often need to be transformed alongside properties. |
| 17 | +/// <para/> |
| 18 | +/// This currently does the following changes: |
| 19 | +/// 1. Transform string constant properties like |
| 20 | +/// <c>static ReadOnlySpan<byte> Thing => "thing"u8;</c> to be |
| 21 | +/// <c>static Utf8String Thing => "thing"u8;</c>. |
| 22 | +/// 2. Transform fields and properties that are recognised |
| 23 | +/// to be akin to booleans to use the <c>MaybeBool</c> type. |
20 | 24 | /// </remarks> |
21 | 25 | public class TransformProperties : IMod |
22 | 26 | { |
@@ -48,7 +52,7 @@ private class Rewriter : CSharpSyntaxRewriter |
48 | 52 | is GenericNameSyntax |
49 | 53 | { |
50 | 54 | TypeArgumentList.Arguments: [PredefinedTypeSyntax pt], |
51 | | - Identifier.Text: "ReadOnlySpan" |
| 55 | + Identifier.Text: "ReadOnlySpan", |
52 | 56 | } |
53 | 57 | && ( |
54 | 58 | pt.Keyword.IsKind(SyntaxKind.ByteKeyword) |
|
0 commit comments