@@ -50,6 +50,7 @@ public void GenerateCode(SourceProductionContext context)
5050 . WithAttributeLists ( [
5151 GeneratedCodeAttribute ( typeof ( QuantityStructGenerator ) )
5252 ] )
53+ . WithXmlComment ( )
5354 . WithParameterList ( ParameterList (
5455 [
5556 Parameter ( Identifier ( "left" ) ) . WithType ( IdentifierName ( leftType . Name ) ) ,
@@ -203,6 +204,7 @@ public void GenerateCode(SourceProductionContext context)
203204 PropertyDeclaration ( IdentifierName ( quantity . Name ) , Identifier ( "Zero" ) )
204205 . WithModifiers ( TokenList ( Token ( SyntaxKind . PublicKeyword ) , Token ( SyntaxKind . StaticKeyword ) ) )
205206 . WithAttributeLists ( [ GeneratedCodeAttribute ( typeof ( QuantityStructGenerator ) ) ] )
207+ . WithXmlCommentInheritDoc ( ( string ? ) null )
206208 . WithExpressionBody ( ArrowExpressionClause ( CastExpression (
207209 IdentifierName ( quantity . Name ) ,
208210 LiteralExpression ( SyntaxKind . NumericLiteralExpression , Literal ( 0 ) ) ) ) )
@@ -211,6 +213,7 @@ public void GenerateCode(SourceProductionContext context)
211213 PropertyDeclaration ( IdentifierName ( quantity . Name ) , Identifier ( "One" ) )
212214 . WithModifiers ( TokenList ( Token ( SyntaxKind . PublicKeyword ) , Token ( SyntaxKind . StaticKeyword ) ) )
213215 . WithAttributeLists ( [ GeneratedCodeAttribute ( typeof ( QuantityStructGenerator ) ) ] )
216+ . WithXmlCommentInheritDoc ( ( string ? ) null )
214217 . WithExpressionBody ( ArrowExpressionClause ( CastExpression (
215218 IdentifierName ( quantity . Name ) ,
216219 LiteralExpression ( SyntaxKind . NumericLiteralExpression , Literal ( 1 ) ) ) ) )
@@ -773,6 +776,7 @@ public void GenerateCode(SourceProductionContext context)
773776 OperatorDeclaration ( IdentifierName ( quantity . Name ) , Token ( SyntaxKind . MinusToken ) )
774777 . WithModifiers ( TokenList ( Token ( SyntaxKind . PublicKeyword ) , Token ( SyntaxKind . StaticKeyword ) ) )
775778 . WithAttributeLists ( [ GeneratedCodeAttribute ( typeof ( QuantityStructGenerator ) ) ] )
779+ . WithXmlComment ( )
776780 . WithParameterList ( ParameterList (
777781 [
778782 Parameter ( Identifier ( "value" ) ) . WithType ( IdentifierName ( quantity . Name ) )
@@ -786,6 +790,7 @@ public void GenerateCode(SourceProductionContext context)
786790 OperatorDeclaration ( IdentifierName ( quantity . Name ) , Token ( SyntaxKind . PlusToken ) )
787791 . WithModifiers ( TokenList ( Token ( SyntaxKind . PublicKeyword ) , Token ( SyntaxKind . StaticKeyword ) ) )
788792 . WithAttributeLists ( [ GeneratedCodeAttribute ( typeof ( QuantityStructGenerator ) ) ] )
793+ . WithXmlComment ( )
789794 . WithParameterList ( ParameterList (
790795 [
791796 Parameter ( Identifier ( "left" ) ) . WithType ( IdentifierName ( quantity . Name ) ) ,
@@ -806,6 +811,7 @@ public void GenerateCode(SourceProductionContext context)
806811 OperatorDeclaration ( IdentifierName ( quantity . Name ) , Token ( SyntaxKind . PercentToken ) )
807812 . WithModifiers ( TokenList ( Token ( SyntaxKind . PublicKeyword ) , Token ( SyntaxKind . StaticKeyword ) ) )
808813 . WithAttributeLists ( [ GeneratedCodeAttribute ( typeof ( QuantityStructGenerator ) ) ] )
814+ . WithXmlComment ( )
809815 . WithParameterList ( ParameterList (
810816 [
811817 Parameter ( Identifier ( "left" ) ) . WithType ( IdentifierName ( quantity . Name ) ) ,
@@ -827,6 +833,7 @@ public void GenerateCode(SourceProductionContext context)
827833 . WithModifiers ( TokenList ( Token ( SyntaxKind . PublicKeyword ) ,
828834 Token ( SyntaxKind . StaticKeyword ) ) )
829835 . WithAttributeLists ( [ GeneratedCodeAttribute ( typeof ( QuantityStructGenerator ) ) ] )
836+ . WithXmlComment ( )
830837 . WithParameterList ( ParameterList (
831838 [
832839 Parameter ( Identifier ( "left" ) ) . WithType ( IdentifierName ( quantity . Name ) ) ,
@@ -847,6 +854,7 @@ public void GenerateCode(SourceProductionContext context)
847854 . WithAttributeLists ( [
848855 GeneratedCodeAttribute ( typeof ( QuantityStructGenerator ) )
849856 ] )
857+ . WithXmlComment ( )
850858 . WithParameterList ( ParameterList (
851859 [
852860 Parameter ( Identifier ( "left" ) ) . WithType ( IdentifierName ( quantity . Name ) ) ,
@@ -863,6 +871,7 @@ public void GenerateCode(SourceProductionContext context)
863871 . WithModifiers ( TokenList ( Token ( SyntaxKind . PublicKeyword ) ,
864872 Token ( SyntaxKind . StaticKeyword ) ) )
865873 . WithAttributeLists ( [ GeneratedCodeAttribute ( typeof ( QuantityStructGenerator ) ) ] )
874+ . WithXmlComment ( )
866875 . WithParameterList ( ParameterList (
867876 [
868877 Parameter ( Identifier ( "left" ) ) . WithType ( IdentifierName ( typeName . FullName ) ) ,
@@ -941,6 +950,28 @@ private ExpressionSyntax GetSystemUnitName()
941950 Literal ( quantity . Name ) ) ;
942951 }
943952
953+ if ( quantitySymbol ? . GetAttributes ( ) . FirstOrDefault ( a =>
954+ a . AttributeClass is { IsGenericType : true } attributeClass
955+ && attributeClass . ConstructUnboundGenericType ( ) . GetName ( ) . FullName is
956+ "global::TedToolkit.Quantities.QuantityDisplayUnitAttribute<>" ) is { } displayUnitAttribute )
957+ {
958+ var syntax = displayUnitAttribute . ApplicationSyntaxReference ? . GetSyntax ( )
959+ as AttributeSyntax ;
960+ var argSyntax = syntax ? . ArgumentList ? . Arguments [ 0 ] . Expression ;
961+ var argText = argSyntax ? . ToString ( ) ;
962+ if ( argText is not null )
963+ return InvocationExpression (
964+ MemberAccessExpression (
965+ SyntaxKind . SimpleMemberAccessExpression ,
966+ IdentifierName ( argText ) ,
967+ IdentifierName ( "ToString" ) ) )
968+ . WithArgumentList ( ArgumentList (
969+ [
970+ Argument ( IdentifierName ( "index" ) ) ,
971+ Argument ( IdentifierName ( "formatProvider" ) )
972+ ] ) ) ;
973+ }
974+
944975 if ( quantity . IsNoDimensions )
945976 {
946977 var memberName = allUnits
0 commit comments