GenAPI produces invalid source code for record properties
See original GitHub issueRepro steps in SBRP
generate.sh --package "Microsoft.Build,16.10.0" --exclude-package-dependencies
./.dotnet/dotnet build src/referencePackages/src/microsoft.build/16.10.0/Microsoft.Build.16.10.0.csproj
GenAPI produces the following code:
public virtual GraphBuildOptions <Clone>$() { throw null; }
Errors
/home/vihofer/git/source-build-reference-packages/src/referencePackages/src/microsoft.build/16.10.0/lib/net472/Microsoft.Build.cs(2559,49): error CS1519: Invalid token '$' in class, record, struct, or interface member declaration [/home/vihofer/git/source-build-reference-packages/src/referencePackages/src/microsoft.build/16.10.0/Microsoft.Build.16.10.0.csproj::TargetFramework=net472]
/home/vihofer/git/source-build-reference-packages/src/referencePackages/src/microsoft.build/16.10.0/lib/net472/Microsoft.Build.cs(2559,49): error CS1056: Unexpected character '$' [/home/vihofer/git/source-build-reference-packages/src/referencePackages/src/microsoft.build/16.10.0/Microsoft.Build.16.10.0.csproj::TargetFramework=net472]
/home/vihofer/git/source-build-reference-packages/src/referencePackages/src/microsoft.build/16.10.0/lib/net472/Microsoft.Build.cs(2559,51): error CS8124: Tuple must contain at least two elements. [/home/vihofer/git/source-build-reference-packages/src/referencePackages/src/microsoft.build/16.10.0/Microsoft.Build.16.10.0.csproj::TargetFramework=net472]
/home/vihofer/git/source-build-reference-packages/src/referencePackages/src/microsoft.build/16.10.0/lib/net472/Microsoft.Build.cs(2559,53): error CS1519: Invalid token '{' in class, record, struct, or interface member declaration [/home/vihofer/git/source-build-reference-packages/src/referencePackages/src/microsoft.build/16.10.0/Microsoft.Build.16.10.0.csproj::TargetFramework=net472]
/home/vihofer/git/source-build-reference-packages/src/referencePackages/src/microsoft.build/16.10.0/lib/net472/Microsoft.Build.cs(2730,1): error CS1022: Type or namespace definition, or end-of-file expected [/home/vihofer/git/source-build-reference-packages/src/referencePackages/src/microsoft.build/16.10.0/Microsoft.Build.16.10.0.csproj::TargetFramework=net472]
/home/vihofer/git/source-build-reference-packages/src/referencePackages/src/microsoft.build/16.10.0/lib/net5.0/Microsoft.Build.cs(2555,49): error CS1519: Invalid token '$' in class, record, struct, or interface member declaration [/home/vihofer/git/source-build-reference-packages/src/referencePackages/src/microsoft.build/16.10.0/Microsoft.Build.16.10.0.csproj::TargetFramework=net5.0]
/home/vihofer/git/source-build-reference-packages/src/referencePackages/src/microsoft.build/16.10.0/lib/net5.0/Microsoft.Build.cs(2555,49): error CS1056: Unexpected character '$' [/home/vihofer/git/source-build-reference-packages/src/referencePackages/src/microsoft.build/16.10.0/Microsoft.Build.16.10.0.csproj::TargetFramework=net5.0]
/home/vihofer/git/source-build-reference-packages/src/referencePackages/src/microsoft.build/16.10.0/lib/net5.0/Microsoft.Build.cs(2555,51): error CS8124: Tuple must contain at least two elements. [/home/vihofer/git/source-build-reference-packages/src/referencePackages/src/microsoft.build/16.10.0/Microsoft.Build.16.10.0.csproj::TargetFramework=net5.0]
/home/vihofer/git/source-build-reference-packages/src/referencePackages/src/microsoft.build/16.10.0/lib/net5.0/Microsoft.Build.cs(2555,53): error CS1519: Invalid token '{' in class, record, struct, or interface member declaration [/home/vihofer/git/source-build-reference-packages/src/referencePackages/src/microsoft.build/16.10.0/Microsoft.Build.16.10.0.csproj::TargetFramework=net5.0]
/home/vihofer/git/source-build-reference-packages/src/referencePackages/src/microsoft.build/16.10.0/lib/net5.0/Microsoft.Build.cs(2726,1): error CS1022: Type or namespace definition, or end-of-file expected [/home/vihofer/git/source-build-reference-packages/src/referencePackages/src/microsoft.build/16.10.0/Microsoft.Build.16.10.0.csproj::TargetFramework=net5.0]
Issue Analytics
- State:
- Created 6 months ago
- Comments:10 (9 by maintainers)
Top Results From Across the Web
Microsoft.UI.Xaml.Markup.Compiler generates invalid code ...
Describe the bug Tried to use a record as a one way view model but it seems impossible. Microsoft.UI.Xaml.Markup.Compiler generates code ...
Read more >firebase_admin.auth module | Firebase - Google
ValueError – If the specified user properties are invalid. FirebaseError – If an error occurs while creating the user account.
Read more >pylon SDK Samples Manual | Basler Product Documentation
On Linux or macOS operating systems, the source code for the samples can be copied from the archive to any location on the...
Read more >Error codes – Quickbase Help
Code Message Possible Cause
0 No error No error
1 Unknown error
4 Bad ticket
Read more >Records - C# reference
When you declare a primary constructor on a record, the compiler generates public properties for the primary constructor parameters.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Fixed with https://github.com/dotnet/roslyn/issues/67335
It seems the following members would also need to be generated
but the
<Clone>$()
method is still a problem. If you consume the reference assembly with this kind of codethen it tries to call the
<Clone>$()
method, and fails to compile if that does not exist.So, I think GenAPI needs to generate the C#
record
syntax.