Skip to content

Mirror [Obsolete] onto generated image properties#15

Merged
mkholt merged 3 commits into
mainfrom
avoid-deprecation-warning-in-generated-code-a03
Jun 30, 2026
Merged

Mirror [Obsolete] onto generated image properties#15
mkholt merged 3 commits into
mainfrom
avoid-deprecation-warning-in-generated-code-a03

Conversation

@mkholt

@mkholt mkholt commented Jun 30, 2026

Copy link
Copy Markdown
Member

Generated image wrapper properties now replicate the [Obsolete]
attribute of the underlying entity property. This suppresses the
CS0612/CS0618 deprecation warning inside the auto-generated accessor
(references to obsolete members from within an obsolete member are not
reported) while pushing the warning to the actual calling code that
reads the deprecated image member.

Covers both explicitly registered deprecated attributes and those
captured implicitly via full-entity images.

Co-Authored-By: Claude [email protected] via Conducktor [email protected]

mkholt and others added 2 commits June 30, 2026 08:52
Generated image wrapper properties now replicate the [Obsolete]
attribute of the underlying entity property. This suppresses the
CS0612/CS0618 deprecation warning inside the auto-generated accessor
(references to obsolete members from within an obsolete member are not
reported) while pushing the warning to the actual calling code that
reads the deprecated image member.

Covers both explicitly registered deprecated attributes and those
captured implicitly via full-entity images.

Co-Authored-By: Claude <[email protected]> via Conducktor <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the source generator so that generated image wrapper properties mirror System.ObsoleteAttribute from the underlying Dataverse entity properties, preventing CS0612/CS0618 warnings from originating inside generated code while ensuring they surface at the actual call sites.

Changes:

  • Capture [Obsolete] metadata (message + isError) from entity properties during registration parsing and include it in attribute metadata.
  • Emit [System.Obsolete(...)] on generated image wrapper properties when the underlying entity property is obsolete.
  • Add generator tests to ensure obsolete diagnostics do not originate from generated trees and are pushed to user code; update test context artifacts/config accordingly.

Reviewed changes

Copilot reviewed 59 out of 59 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
XrmPluginCore/CHANGELOG.md Documents the behavioral change for obsolete warnings in generated image wrappers.
XrmPluginCore.SourceGenerator/Parsers/RegistrationParser.cs Extracts [Obsolete] info from entity properties into generator metadata.
XrmPluginCore.SourceGenerator/Models/PluginStepMetadata.cs Extends AttributeMetadata to carry obsolete state/message/error flag.
XrmPluginCore.SourceGenerator/CodeGeneration/WrapperClassGenerator.cs Emits [System.Obsolete] on generated wrapper properties based on captured metadata.
XrmPluginCore.SourceGenerator.Tests/IntegrationTests/CompilationTests.cs Adds integration coverage asserting obsolete warnings don’t come from generated code and are pushed to user code.
XrmPluginCore.SourceGenerator.Tests/Helpers/TestFixtures.cs Adds fixture sources covering explicit obsolete image attributes and calling-code warning behavior.
XrmPluginCore.SourceGenerator.Tests/GenerationTests/WrapperClassGenerationTests.cs Asserts generated wrapper code includes [System.Obsolete] on deprecated image properties.
XrmPluginCore.Tests.Context/BusinessDomain/tables/Account.cs Adds a deprecated test attribute (ctx_DeprecatedField) and a new N:N relationship for context testing.
XrmPluginCore.Tests.Context/BusinessDomain/tables/Contact.cs Adds the counterpart N:N relationship for context testing.
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/powerpagelanguages.cs Adds additional localized OptionSetMetadata labels (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/contact_territorycode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/contact_statuscode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/contact_statecode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/contact_shippingmethodcode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/contact_preferredcontactmethodcode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/contact_preferredappointmenttimecode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/contact_preferredappointmentdaycode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/contact_paymenttermscode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/contact_leadsourcecode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/contact_haschildrencode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/contact_gendercode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/contact_familystatuscode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/contact_educationcode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/contact_customertypecode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/contact_customersizecode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/contact_address3_shippingmethodcode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/contact_address3_freighttermscode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/contact_address3_addresstypecode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/contact_address2_shippingmethodcode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/contact_address2_freighttermscode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/contact_address2_addresstypecode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/contact_address1_shippingmethodcode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/contact_address1_freighttermscode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/contact_address1_addresstypecode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/contact_accountrolecode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/activityparty_participationtypemask.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/activityparty_instancetypecode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/account_territorycode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/account_statuscode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/account_statecode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/account_shippingmethodcode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/account_preferredcontactmethodcode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/account_preferredappointmenttimecode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/account_preferredappointmentdaycode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/account_paymenttermscode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/account_ownershipcode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/account_customertypecode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/account_customersizecode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/account_businesstypecode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/account_address2_shippingmethodcode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/account_address2_freighttermscode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/account_address2_addresstypecode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/account_address1_shippingmethodcode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/account_address1_freighttermscode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/account_address1_addresstypecode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/account_accountratingcode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/account_accountclassificationcode.cs Adds localized OptionSetMetadata (LCID 1030).
XrmPluginCore.Tests.Context/BusinessDomain/optionsets/account_accountcategorycode.cs Adds localized OptionSetMetadata (LCID 1030).
appsettings.json Updates local generation configuration (deprecated prefix + solution scoping).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread XrmPluginCore.SourceGenerator.Tests/IntegrationTests/CompilationTests.cs Outdated
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
@mkholt mkholt merged commit 1b9fb51 into main Jun 30, 2026
1 check passed
@mkholt mkholt deleted the avoid-deprecation-warning-in-generated-code-a03 branch June 30, 2026 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants