Skip to content

Add [Obsolete] to deprecated members. #472

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 11, 2025
Merged

Conversation

jamescourtney
Copy link
Owner

No description provided.

@jamescourtney jamescourtney mentioned this pull request May 11, 2025
@jamescourtney jamescourtney requested a review from Copilot May 11, 2025 07:28
Copy link
Contributor

@Copilot Copilot AI left a comment

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 adds the [Obsolete] attribute to deprecated members and adjusts related test cases and code generation to account for obsolete behavior. Key changes include:

  • Wrapping deprecated member usage in tests with pragma directives to suppress obsolete warnings.
  • Emitting the [Obsolete] attribute in the generated code for deprecated fields.
  • Filtering out deprecated fields from copy and default constructor routines.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Tests/FlatSharpEndToEndTests/TableMembers/TableMembersTests.cs Added pragma directives to suppress obsolete warnings in tests.
src/Tests/FlatSharpEndToEndTests/RawData/RawDataTableTests.cs Wrapped deprecated member access with pragma directives.
src/Tests/FlatSharpEndToEndTests/RawData/RawDataStringTests.cs Added pragma directives to disable/restore warnings around deprecated usage.
src/Tests/FlatSharpEndToEndTests/MetadataAttributes/MetadataAttributes.fbs Marked a field as deprecated in the schema file.
src/Tests/FlatSharpEndToEndTests/MetadataAttributes/MetadataAttributeTests.cs Added tests to validate that the deprecated attribute is applied.
src/FlatSharp/Serialization/RoslynSerializerGenerator.cs Filtered out diagnostics for obsolete warnings in code generation.
src/FlatSharp.Compiler/SchemaModel/PropertyFieldModel.cs Emitted the [Obsolete] attribute for deprecated fields in code generation.
src/FlatSharp.Compiler/SchemaModel/BaseReferenceTypeSchemaModel.cs Excluded deprecated fields from copy and default constructors.

Comment on lines +145 to +148
if (this.Field.Deprecated)
{
writer.AppendLine("[Obsolete]");
}
Copy link
Preview

Copilot AI May 11, 2025

Choose a reason for hiding this comment

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

Consider including a descriptive message in the [Obsolete] attribute to help developers understand why this member is deprecated.

Suggested change
if (this.Field.Deprecated)
{
writer.AppendLine("[Obsolete]");
}
if (this.Field.Deprecated)
{
string deprecationMessage = string.IsNullOrEmpty(this.Field.Documentation)
? "This field is deprecated and should not be used."
: $"This field is deprecated: {this.Field.Documentation}";
writer.AppendLine($"[Obsolete(\"{deprecationMessage}\")]");
}

Copilot uses AI. Check for mistakes.

@@ -84,6 +84,8 @@ public void Byte(FlatBufferDeserializationOption option)
[DynamicData(nameof(DynamicDataHelper.DeserializationModes), typeof(DynamicDataHelper))]
public void Double(FlatBufferDeserializationOption option) => this.RunTest<double, DoubleTable>(3.14, option);

Copy link
Preview

Copilot AI May 11, 2025

Choose a reason for hiding this comment

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

It would be helpful to add a comment explaining why obsolete warnings are suppressed here to aid future maintainers.

Suggested change
// Suppressing CS0612 because the obsolete member is still required for testing backward compatibility.

Copilot uses AI. Check for mistakes.

Copy link

codecov bot commented May 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.04%. Comparing base (53db630) to head (fb4e773).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #472   +/-   ##
=======================================
  Coverage   96.04%   96.04%           
=======================================
  Files         124      124           
  Lines        8923     8928    +5     
  Branches      748      749    +1     
=======================================
+ Hits         8570     8575    +5     
  Misses        261      261           
  Partials       92       92           
Files with missing lines Coverage Δ
...mpiler/SchemaModel/BaseReferenceTypeSchemaModel.cs 95.16% <100.00%> (ø)
...atSharp.Compiler/SchemaModel/PropertyFieldModel.cs 97.67% <100.00%> (+0.03%) ⬆️
...atSharp/Serialization/RoslynSerializerGenerator.cs 96.85% <100.00%> (+<0.01%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 53db630...fb4e773. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jamescourtney jamescourtney merged commit cd795c0 into main May 11, 2025
8 checks passed
@jamescourtney jamescourtney deleted the obsolete_on_deprecated branch May 12, 2025 02:31
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.

1 participant