Skip to content

Commit daec701

Browse files
authored
Merge pull request #63 from Ted-Jin-Lab/development
✨Change the quantity to the property thing.
2 parents 3fc37a7 + 168d551 commit daec701

3 files changed

Lines changed: 19 additions & 13 deletions

File tree

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project>
33
<PropertyGroup>
4-
<Version>2025.11.20.1</Version>
4+
<Version>2025.11.20.2</Version>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<LangVersion>preview</LangVersion>

src/analyzers/TedToolkit.Quantities.Analyzer/QuantityStructGenerator.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -196,15 +196,15 @@ public void GenerateCode(SourceProductionContext context)
196196
LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(1)))))
197197
.WithSemicolonToken(Token(SyntaxKind.SemicolonToken)),
198198

199-
FieldDeclaration(
200-
VariableDeclaration(IdentifierName(typeName.FullName))
201-
.WithVariables(
202-
[
203-
VariableDeclarator(Identifier("Value"))
204-
]))
205-
.WithModifiers(TokenList(Token(SyntaxKind.PublicKeyword),
206-
Token(SyntaxKind.ReadOnlyKeyword)))
207-
.WithAttributeLists([GeneratedCodeAttribute(typeof(QuantityStructGenerator))]),
199+
PropertyDeclaration(IdentifierName(typeName.FullName), Identifier("Value"))
200+
.WithModifiers(TokenList(Token(SyntaxKind.PublicKeyword)))
201+
.WithAttributeLists([GeneratedCodeAttribute(typeof(QuantityStructGenerator))])
202+
.WithXmlCommentInheritDoc((string?)null)
203+
.WithAccessorList(AccessorList(
204+
[
205+
AccessorDeclaration(SyntaxKind.GetAccessorDeclaration)
206+
.WithSemicolonToken(Token(SyntaxKind.SemicolonToken))
207+
])),
208208

209209
ConstructorDeclaration(Identifier(quantity.Name))
210210
.WithModifiers(TokenList(Token(quantity.IsNoDimensions
@@ -462,7 +462,7 @@ public void GenerateCode(SourceProductionContext context)
462462
.WithSemicolonToken(Token(SyntaxKind.SemicolonToken)),
463463

464464
ConversionOperatorDeclaration(
465-
Token(quantitySymbol?.GetAttributes().Any(a => a.AttributeClass?.GetName().FullName
465+
Token(quantitySymbol?.GetAttributes().Any(a => a.AttributeClass?.GetName().FullName
466466
is "global::TedToolkit.Quantities.QuantityImplicitFromValueTypeAttribute") ?? false
467467
? SyntaxKind.ImplicitKeyword
468468
: SyntaxKind.ExplicitKeyword),

src/libraries/TedToolkit.Quantities/IQuantity.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,15 @@
55
/// </summary>
66
/// <typeparam name="TQuantity"></typeparam>
77
/// <typeparam name="TValue"></typeparam>
8-
public interface IQuantity<TQuantity, TValue> : IQuantity<TQuantity>
8+
public interface IQuantity<TQuantity, out TValue> : IQuantity<TQuantity>
99
where TValue : struct, IConvertible
10-
where TQuantity : IQuantity<TQuantity, TValue>;
10+
where TQuantity : IQuantity<TQuantity, TValue>
11+
{
12+
/// <summary>
13+
/// The Value. In the most case, you don't need it.
14+
/// </summary>
15+
TValue Value { get; }
16+
}
1117

1218
/// <summary>
1319
/// Quantity

0 commit comments

Comments
 (0)