Skip to content

Various additions#511

Merged
PTKu merged 12 commits intodevfrom
510-various-additions
Feb 25, 2026
Merged

Various additions#511
PTKu merged 12 commits intodevfrom
510-various-additions

Conversation

@PTKu
Copy link
Contributor

@PTKu PTKu commented Feb 23, 2026

This pull request introduces a significant new feature to the AXSharp compiler: automatic generation of typed enum accessor properties for PLC enum and named value types with integral backing types. This enhancement improves type safety and usability in generated C# code, and is accompanied by documentation updates and some minor dependency and code improvements.

The most important changes are:

Typed Enum Accessor Properties:

  • The compiler now automatically generates strongly-typed enum accessor properties (e.g., StatusEnum) for properties based on PLC ENUM types and named value types with integral backing types, allowing direct access to enum values without manual casting. [1] [2] [3] [4] [5] [6]
  • All such properties are decorated with [EnumeratorDiscriminatorAttribute] to support serialization and UI features, and this is also reflected in POCO types. [1] [2]

Documentation Updates:

  • Added a comprehensive section to ADDED_MEMBERS.md documenting the new typed enum accessor properties, usage examples, and important notes on reading values.
  • Updated the compiler README to mention typed enum accessor properties.

Compiler Helper Improvements:

  • Added a helper method HasIntegralBackingType to detect if a named value type has an integral base, used to determine when to generate typed enum accessors.

Pragma and Error Handling Improvements:

  • Improved pragma parsing and error reporting, including better handling of malformed pragmas and more accurate error messages. [1] [2] [3] [4]

Dependency Updates:

  • Updated dependencies for Google.Protobuf, Siemens.Simatic.S7.Webserver.API, and Microsoft.Extensions.DependencyInjection.Abstractions to newer versions. [1] [2] [3]

closes #510
closes #386
closes #455

@PTKu PTKu linked an issue Feb 23, 2026 that may be closed by this pull request
PTKu added 5 commits February 23, 2026 14:30
Emit AXSharp.Connector.EnumeratorDiscriminatorAttribute on generated POCO properties representing enum and named value types. Update CsPlainSourceBuilder to generate this attribute, and regenerate .g.cs files to include it. Bump AXSharp.Abstractions and AXSharp.Connector package versions to support the new attribute. This improves metadata for reflection and tooling.
…ing types for enums; update CsPlainSourceBuilder for global attribute usage.
- Enhance GetPropertyValue to detect and handle malformed pragmas, returning an empty string on error.
- Adjust error messages to use 1-based line numbers for clarity.
- Reorder grammar rules for correct pragma parsing precedence.
- Minor formatting and copyright updates.
Introduced PragmaParserTests covering property, attribute, setter, and generic pragma parsing, as well as error handling and edge cases. Added PragmaMock for IPragma and used NSubstitute for IDeclaration mocking. This significantly improves test coverage and robustness for pragma parsing.
@PTKu PTKu marked this pull request as ready for review February 23, 2026 15:58
@PTKu PTKu requested review from TomKovac and kuh0005 February 23, 2026 15:58
@PTKu PTKu marked this pull request as draft February 24, 2026 07:21
PTKu added 6 commits February 24, 2026 13:24
ConstructIdentitiesAsync now uses _identitiesTags directly, bypassing ReadIdentitiesAsync. SortIdentitiesAsync performs an async batch read of identity keys and uses LastValue directly for sorting, removing synchronous calls for improved performance. Minor formatting change to DuplicateIdentityException.
Improved safety by adding an explicit null check for _connector
before calling ReadBatchAsync in SortIdentitiesAsync. This change
clarifies intent and prevents potential null reference issues.
@PTKu PTKu marked this pull request as ready for review February 25, 2026 11:01
@PTKu PTKu merged commit d7c784b into dev Feb 25, 2026
2 checks passed
@PTKu PTKu deleted the 510-various-additions branch February 25, 2026 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant