Skip to content

Commit

Permalink
[Xamarin.Android.Tools.Bytecode] Fix for finding public setters with …
Browse files Browse the repository at this point in the history
…old `kotlinc` versions.
  • Loading branch information
jpobst committed Oct 30, 2023
1 parent 1adb796 commit 5422a81
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Xamarin.Android.Tools.Bytecode/Kotlin/KotlinFixups.cs
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,11 @@ static void FixupField (FieldInfo? field, KotlinProperty metadata)
return null;

// Public/protected setters look like "setFoo"
// Note: earlier versions of kotlinc used "setFoo-abcdefg" for public setters so we use GetMethodNameWithoutSuffix
// Internal setters look like "setFoo$main"
var possible_methods = property.IsInternalVisibility ?
klass.Methods.Where (method => method.Name.StartsWith ($"set{property.Name.Capitalize ()}$", StringComparison.Ordinal)) :
klass.Methods.Where (method => method.Name.Equals ($"set{property.Name.Capitalize ()}", StringComparison.Ordinal));
klass.Methods.Where (method => method.GetMethodNameWithoutSuffix ().Equals ($"set{property.Name.Capitalize ()}", StringComparison.Ordinal));

possible_methods = possible_methods.Where (method =>
property.ReturnType != null &&
Expand Down

0 comments on commit 5422a81

Please sign in to comment.