Skip to content

More precise diagnostics for methods attributes with wrong types#4514

Open
Leinnan wants to merge 1 commit intomainfrom
feature/missingSerializableAttributeForArgument
Open

More precise diagnostics for methods attributes with wrong types#4514
Leinnan wants to merge 1 commit intomainfrom
feature/missingSerializableAttributeForArgument

Conversation

@Leinnan
Copy link
Collaborator

@Leinnan Leinnan commented Feb 11, 2026

It gives a more precise information when game maker is using unsupported type as argument in `ClientCallable. By providing the exact name of the argument being invalid it helps figuring out issue faster.

@github-actions
Copy link
Contributor

Lightbeam link

Copy link
Contributor

@DiasAtBeamable DiasAtBeamable left a comment

Choose a reason for hiding this comment

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

LGTM, good addition to the Diagnostics. Thanks!

Copy link
Contributor

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 improves diagnostic messages for ClientCallable methods with unsupported argument types by providing more precise error messages that include the specific parameter name causing the issue.

Changes:

  • Added a new diagnostic descriptor MissingSerializableAttributeForArgument that provides parameter-specific error messages
  • Modified ValidateSerializableAttributeOnSymbol to accept an optional parameterName parameter and use the new diagnostic when a parameter name is provided
  • Updated the test to validate the new parameter-aware diagnostic

Reviewed changes

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

File Description
templates/MicroserviceSourceGen/MicroserviceSourceGen/Diagnostics.cs Added new MissingSerializableAttributeForArgument diagnostic descriptor and registered it in the analyzer
templates/MicroserviceSourceGen/MicroserviceSourceGen/Analyzers/ServicesAnalyzer.cs Updated method signature to accept parameter name and added logic to use the new diagnostic when validating method parameters
templates/SourceGen/MicroserviceSourceGen.Tests/BeamableSourceGeneratorTests.Srv.cs Added test case for new parameter-aware diagnostic with wrongArgument parameter

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

Comment on lines +146 to +147
public static readonly DiagnosticDescriptor MissingSerializableAttributeForArgument
= new(MISSING_SERIALIZABLE_ATTRIBUTE_ON_TYPE_ID,
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

The new diagnostic descriptor MissingSerializableAttributeForArgument is reusing the same diagnostic ID MISSING_SERIALIZABLE_ATTRIBUTE_ON_TYPE_ID as MissingSerializableAttributeOnType. This is problematic because diagnostic IDs should be unique to allow proper identification and filtering of specific diagnostic types. When two diagnostics share the same ID, it becomes impossible to distinguish between them programmatically, which can cause issues with diagnostic suppression, IDE filtering, and diagnostic tracking.

Consider creating a new unique diagnostic ID constant (e.g., MISSING_SERIALIZABLE_ATTRIBUTE_FOR_ARGUMENT_ID = "BEAM_SRV_0024") and using it for this diagnostic descriptor instead of reusing the existing ID.

Copilot uses AI. Check for mistakes.
Comment on lines +644 to +651
if (!string.IsNullOrWhiteSpace(parameterName))
{
diagnostic = Diagnostic.Create(Diagnostics.Srv.MissingSerializableAttributeForArgument, location, typeSymbol.Name, parameterName);
}
else
{
diagnostic = Diagnostic.Create(Diagnostics.Srv.MissingSerializableAttributeOnType, location, typeSymbol.Name);
}
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

Both branches of this 'if' statement write to the same variable - consider using '?' to express intent better.

Copilot uses AI. Check for mistakes.
@cdhanna
Copy link
Collaborator

cdhanna commented Feb 13, 2026

@Leinnan , I was experimenting with copilot. Your PR just had the luck of being recent.

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.

3 participants

Comments