question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GenAPI does not correctly handle System.Runtime

See original GitHub issue

Steps to Reproduce utilizing https://github.com/dotnet/source-build-reference-packages/blob/main/generate.sh

  1. ./generate -x -p System.Runtime,4.3.1 (also get the same results with 4.1.0 and 4.3.0)
  2. ./build -sb

Issues with generated code:

  1. const readonly - Generated code has const readonly which is not valid and causes compilation errors.
    public partial struct Decimal : IComparable, IComparable<Decimal>, IConvertible, IEquatable<Decimal>, IFormattable
    {
        public const readonly Decimal MaxValue = MaxValue;
        public const readonly Decimal MinusOne = -1M;
        public const readonly Decimal MinValue = MinValue;
        public const readonly Decimal One = 1M;
        public const readonly Decimal Zero = 0M;
  /repos/source-build-reference-packages/artifacts/source-build/self/src/src/referencePackages/src/system.runtime/4.3.1/ref/netstandard1.3/System.Runtime.cs(1065,22): error CS1001: Identifier expected [/repos/source-build-reference-packages/artifacts/source-build/self/src/src/referencePackages/src/system.runtime/4.3.1/System.Runtime.4.3.1.csproj::TargetFramework=netstandard1.3] [/root/.nuget/packages/microsoft.dotnet.arcade.sdk/8.0.0-beta.23371.1/tools/Build.proj]
  /repos/source-build-reference-packages/artifacts/source-build/self/src/src/referencePackages/src/system.runtime/4.3.1/ref/netstandard1.3/System.Runtime.cs(1065,22): error CS0145: A const field requires a value to be provided [/repos/source-build-reference-packages/artifacts/source-build/self/src/src/referencePackages/src/system.runtime/4.3.1/System.Runtime.4.3.1.csproj::TargetFramework=netstandard1.3] [/root/.nuget/packages/microsoft.dotnet.arcade.sdk/8.0.0-beta.23371.1/tools/Build.proj]
  /repos/source-build-reference-packages/artifacts/source-build/self/src/src/referencePackages/src/system.runtime/4.3.1/ref/netstandard1.3/System.Runtime.cs(1065,22): error CS1002: ; expected [/repos/source-build-reference-packages/artifacts/source-build/self/src/src/referencePackages/src/system.runtime/4.3.1/System.Runtime.4.3.1.csproj::TargetFramework=netstandard1.3] [/root/.nuget/packages/microsoft.dotnet.arcade.sdk/8.0.0-beta.23371.1/tools/Build.proj]
  /repos/source-build-reference-packages/artifacts/source-build/self/src/src/referencePackages/src/system.runtime/4.3.1/ref/netstandard1.3/System.Runtime.cs(1066,22): error CS1031: Type expected [/repos/source-build-reference-packages/artifacts/source-build/self/src/src/referencePackages/src/system.runtime/4.3.1/System.Runtime.4.3.1.csproj::TargetFramework=netstandard1.3] [/root/.nuget/packages/microsoft.dotnet.arcade.sdk/8.0.0-beta.23371.1/tools/Build.proj]
  /repos/source-build-reference-packages/artifacts/source-build/self/src/src/referencePackages/src/system.runtime/4.3.1/ref/netstandard1.3/System.Runtime.cs(1066,22): error CS1001: Identifier expected [/repos/source-build-reference-packages/artifacts/source-build/self/src/src/referencePackages/src/system.runtime/4.3.1/System.Runtime.4.3.1.csproj::TargetFramework=netstandard1.3] [/root/.nuget/packages/microsoft.dotnet.arcade.sdk/8.0.0-beta.23371.1/tools/Build.proj]
  /repos/source-build-reference-packages/artifacts/source-build/self/src/src/referencePackages/src/system.runtime/4.3.1/ref/netstandard1.3/System.Runtime.cs(1066,22): error CS0145: A const field requires a value to be provided [/repos/source-build-reference-packages/artifacts/source-build/self/src/src/referencePackages/src/system.runtime/4.3.1/System.Runtime.4.3.1.csproj::TargetFramework=netstandard1.3] [/root/.nuget/packages/microsoft.dotnet.arcade.sdk/8.0.0-beta.23371.1/tools/Build.proj]
  /repos/source-build-reference-packages/artifacts/source-build/self/src/src/referencePackages/src/system.runtime/4.3.1/ref/netstandard1.3/System.Runtime.cs(1066,22): error CS1002: ; expected [/repos/source-build-reference-packages/artifacts/source-build/self/src/src/referencePackages/src/system.runtime/4.3.1/System.Runtime.4.3.1.csproj::TargetFramework=netstandard1.3] [/root/.nuget/packages/microsoft.dotnet.arcade.sdk/8.0.0-beta.23371.1/tools/Build.proj]
  /repos/source-build-reference-packages/artifacts/source-build/self/src/src/referencePackages/src/system.runtime/4.3.1/ref/netstandard1.3/System.Runtime.cs(1067,22): error CS1031: Type expected [/repos/source-build-reference-packages/artifacts/source-build/self/src/src/referencePackages/src/system.runtime/4.3.1/System.Runtime.4.3.1.csproj::TargetFramework=netstandard1.3] [/root/.nuget/packages/microsoft.dotnet.arcade.sdk/8.0.0-beta.23371.1/tools/Build.proj]
  /repos/source-build-reference-packages/artifacts/source-build/self/src/src/referencePackages/src/system.runtime/4.3.1/ref/netstandard1.3/System.Runtime.cs(1067,22): error CS1001: Identifier expected [/repos/source-build-reference-packages/artifacts/source-build/self/src/src/referencePackages/src/system.runtime/4.3.1/System.Runtime.4.3.1.csproj::TargetFramework=netstandard1.3] [/root/.nuget/packages/microsoft.dotnet.arcade.sdk/8.0.0-beta.23371.1/tools/Build.proj]
  /repos/source-build-reference-packages/artifacts/source-build/self/src/src/referencePackages/src/system.runtime/4.3.1/ref/netstandard1.3/System.Runtime.cs(1067,22): error CS0145: A const field requires a value to be provided [/repos/source-build-reference-packages/artifacts/source-build/self/src/src/referencePackages/src/system.runtime/4.3.1/System.Runtime.4.3.1.csproj::TargetFramework=netstandard1.3] [/root/.nuget/packages/microsoft.dotnet.arcade.sdk/8.0.0-beta.23371.1/tools/Build.proj]
  /repos/source-build-reference-packages/artifacts/source-build/self/src/src/referencePackages/src/system.runtime/4.3.1/ref/netstandard1.3/System.Runtime.cs(1067,22): error CS1002: ; expected [/repos/source-build-reference-packages/artifacts/source-build/self/src/src/referencePackages/src/system.runtime/4.3.1/System.Runtime.4.3.1.csproj::TargetFramework=netstandard1.3] [/root/.nuget/packages/microsoft.dotnet.arcade.sdk/8.0.0-beta.23371.1/tools/Build.proj]
  /repos/source-build-reference-packages/artifacts/source-build/self/src/src/referencePackages/src/system.runtime/4.3.1/ref/netstandard1.3/System.Runtime.cs(1068,22): error CS1031: Type expected [/repos/source-build-reference-packages/artifacts/source-build/self/src/src/referencePackages/src/system.runtime/4.3.1/System.Runtime.4.3.1.csproj::TargetFramework=netstandard1.3] [/root/.nuget/packages/microsoft.dotnet.arcade.sdk/8.0.0-beta.23371.1/tools/Build.proj]
  /repos/source-build-reference-packages/artifacts/source-build/self/src/src/referencePackages/src/system.runtime/4.3.1/ref/netstandard1.3/System.Runtime.cs(1068,22): error CS1001: Identifier expected [/repos/source-build-reference-packages/artifacts/source-build/self/src/src/referencePackages/src/system.runtime/4.3.1/System.Runtime.4.3.1.csproj::TargetFramework=netstandard1.3] [/root/.nuget/packages/microsoft.dotnet.arcade.sdk/8.0.0-beta.23371.1/tools/Build.proj]
  /repos/source-build-reference-packages/artifacts/source-build/self/src/src/referencePackages/src/system.runtime/4.3.1/ref/netstandard1.3/System.Runtime.cs(1068,22): error CS0145: A const field requires a value to be provided [/repos/source-build-reference-packages/artifacts/source-build/self/src/src/referencePackages/src/system.runtime/4.3.1/System.Runtime.4.3.1.csproj::TargetFramework=netstandard1.3] [/root/.nuget/packages/microsoft.dotnet.arcade.sdk/8.0.0-beta.23371.1/tools/Build.proj]
  /repos/source-build-reference-packages/artifacts/source-build/self/src/src/referencePackages/src/system.runtime/4.3.1/ref/netstandard1.3/System.Runtime.cs(1068,22): error CS1002: ; expected [/repos/source-build-reference-packages/artifacts/source-build/self/src/src/referencePackages/src/system.runtime/4.3.1/System.Runtime.4.3.1.csproj::TargetFramework=netstandard1.3] [/root/.nuget/packages/microsoft.dotnet.arcade.sdk/8.0.0-beta.23371.1/tools/Build.proj]
  /repos/source-build-reference-packages/artifacts/source-build/self/src/src/referencePackages/src/system.runtime/4.3.1/ref/netstandard1.5/System.Runtime.cs(1071,22): error CS1002: ; expected [/repos/source-build-reference-packages/artifacts/source-build/self/src/src/referencePackages/src/system.runtime/4.3.1/System.Runtime.4.3.1.csproj::TargetFramework=netstandard1.5] [/root/.nuget/packages/microsoft.dotnet.arcade.sdk/8.0.0-beta.23371.1/tools/Build.proj]

Workaround: Replace const readonly with const

  1. Missing attribute types - See https://github.com/dotnet/sdk/issues/33388

Workaround: Manually add missing attribute types.

  1. Circular Reference: primitive type constants have circular references.
    public partial struct UInt32 : IComparable, IComparable<UInt32>, IEquatable<UInt32>, IFormattable
    {
        public const UInt32 MaxValue = MaxValue;
  /repos/source-build-reference-packages/artifacts/source-build/self/src/src/referencePackages/src/system.runtime/4.3.1/ref/netstandard1.0/System.Runtime.cs(2775,29): error CS0110: The evaluation of the constant value for 'uint.MaxValue' involves a circular definition [/repos/source-build-reference-packages/artifacts/source-build/self/src/src/referencePackages/src/system.runtime/4.3.1/System.Runtime.4.3.1.csproj::TargetFramework=netstandard1.0] [/root/.nuget/packages/microsoft.dotnet.arcade.sdk/8.0.0-beta.23371.1/tools/Build.proj]

Workaround: Manually update code to use numeric values.

Issue Analytics

  • State:closed
  • Created 2 months ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ericstjcommented, Aug 4, 2023

Roslyn change merged - that should fix the two unique issues reported here. Plan to resolve this once we can pick up a new roslyn build. Leave the linked issue open to track attribute handling.

1reaction
ericstjcommented, Aug 4, 2023

Both 1 and 3 are roslyn issues.

1 is due to decimal constants being represented differently in metadata. They are a readonly field with an attribute that provides the value. As a result it causes this issue: https://github.com/dotnet/roslyn/issues/69376 I haven’t yet found a good workaround for this - but it should be possible.

3 is due to a bug in how SyntaxGenerator emits literal values. It tries to map to some well known constants, but doesn’t account for that fact it might be defining those constants. https://github.com/dotnet/roslyn/issues/69380 For this I have a workaround.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Could not load file or assembly 'System.Runtime, Version= ...
10 Answers 10 · Go to your project folder. · Delete the bin file inside your project folder. · Remove all added references....
Read more >
GenICam GenTL Standard
GenApi is only a reference implementation, not a mandatory standard. User ... System module handle is requested twice from within a single ...
Read more >
Image Acquisition Interface for GenICam GenTL compliant ...
Please note that it might not be possible to use different GenApi versions ... GenICam-based parameters of the individual GenTL Producer modules (system, ......
Read more >
Common Vision Blox: Common Vision Blox - Online help for ...
GenApi.NODE and Cvb.GenApi.NODEMAP it was necessary to change the signature of those two call-backs to accept System.IntPtr parameters instead of Cvb.GenApi.
Read more >
pylon SDK Samples Manual
This topic describes the SDK sample programs delivered with the pylon Camera Software Suite.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found