Skip to content
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

[generator] Change generated code to not emit CA1305 warning. #771

Merged
merged 1 commit into from
Jan 6, 2021

Conversation

jpobst
Copy link
Contributor

@jpobst jpobst commented Jan 5, 2021

Fixes: #763

Today we generate this code:

throw new InvalidCastException (string.Format ("Unable to convert instance of type '{0}' to type '{1}'.", JNIEnv.GetClassNameFromInstance (handle), "java.code.IMyInterface"));

In newer CSC versions (.NET5+), this produces a CA1305 warning. We can avoid this warning with string interpolation:

throw new InvalidCastException ($"Unable to convert instance of type '{JNIEnv.GetClassNameFromInstance (handle)}' to type 'java.code.IMyInterface'.");

@jpobst jpobst marked this pull request as ready for review January 5, 2021 21:32
@radekdoulik radekdoulik merged commit f1b9365 into master Jan 6, 2021
@radekdoulik radekdoulik deleted the ca1305 branch January 6, 2021 10:04
@jpobst jpobst added this to the 11.2 (16.10 / 8.10) milestone Feb 2, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generated invoker code causes CA1305 warning
2 participants