Skip to content

Conversation

@atsushieno
Copy link
Contributor

This fixes dotnet/android#1138

It is quite corner case, where ... arguments are used in interfaces that
can be converted to events.

Parameter types cannot be simply used for fields and parameters because
they cannot take "params" as their modifiers.

The real code fix should be in Parameter.cs, but that would require
a lot of changes unlike this tiny fix.

@atsushieno atsushieno requested a review from jonpryor January 26, 2018 05:23
return "void";
if (s.StartsWith ("params "))
return "params " + GetOutputName (s.Substring (6));
return "params " + GetOutputName (s.Substring (7));
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is 7 coming from? Presumably it's "params ".Length.

Assuming that 7 is coming from a string length, could you lease replace 7 with e.g. "params ".Length, so that the source value is obvious?

continue;
sw.WriteLine ();
sw.WriteLine ("{0}\t{1} {2};", indent, opt.GetOutputName (p.Type), opt.GetSafeIdentifier (p.Name));
var safeTypeName = p.Type.StartsWith ("params ", StringComparison.Ordinal) ? p.Type.Substring (7) : p.Type;
Copy link
Contributor

Choose a reason for hiding this comment

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

This usage makes the 7 a bit more obvious, as "params " is on the same line/nearby (unlike the previous spot), but I would still prefer use of "params ".Length over a hardcoded 7.

@atsushieno
Copy link
Contributor Author

If you think your suggested changes are REALLY important, then make another PR to achieve them.

string args_name = GetArgsName (m);
if (m.RetVal.IsVoid || m.IsEventHandlerWithHandledProperty) {
if (!m.IsSimpleEventHandler || m.IsEventHandlerWithHandledProperty) {
sw.WriteLine ("{0}// event args for {1}.{2}", indent, this.JavaName, m.JavaName);
Copy link
Contributor

Choose a reason for hiding this comment

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

This line is causing the unit tests to fail, as the expected file contents don't contain it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

…lds.

This fixes dotnet/android#1138

It is quite corner case, where ... arguments are used in interfaces that
can be converted to events.

Parameter types cannot be simply used for fields and parameters because
they cannot take "params" as their modifiers.

The real code fix should be in Parameter.cs, but that would require
a lot of changes unlike this tiny fix.
@jonpryor jonpryor merged commit ed70cb4 into dotnet:master Feb 7, 2018
@github-actions github-actions bot locked and limited conversation to collaborators Apr 14, 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.

Binding Library using class-parse (Error CS1519: Invalid token 'params')

2 participants