You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[param-name-importer] Fix NSE when updating JavaApi.AllPackages (#807)
In commit 0cb8e2d, we switched from using `List<JavaPackage>` to
`Dictionary<string, JavaPackage>` for better performance.
To minimize the diffs needed with existing code, we created an
accessor for `Dictionary<string, JavaPackage>.Values`:
partial class JavaApi {
public IDictionary<string, JavaPackage> Packages { get; }
public ICollection<JavaPackage> AllPackages => Packages.Values;
}
However, if you attempt to modify this collection directly -- as is
done by `tools/param-name-importer` -- you get an exception:`
System.NotSupportedException: Mutating a value collection derived from a dictionary is not allowed.
at System.ThrowHelper.ThrowNotSupportedException(ExceptionResource resource)
at Xamarin.Android.ApiTools.JavaStubImporter.JavaStubSourceImporter.ParseJava(String javaSourceText) in …\Java.Interop\tools\param-name-importer\JavaStubSourceImporter.cs:line 81
at Xamarin.Android.ApiTools.JavaStubImporter.JavaStubSourceImporter.Import(ImporterOptions options) in …\Java.Interop\tools\param-name-importer\JavaStubSourceImporter.cs:line 27
at Xamarin.Android.ApiTools.Driver.Main(String[] args) in …\Java.Interop\tools\param-name-importer\Program.cs:line 22
Update `tools/param-name-importer` to use `api.Packages.Add()`
instead of `api.AllPackages.Add()` to avoid the exception.
Verified that this is the only code that attempts to modify
`JavaApi.AllPackages`.
0 commit comments