diff --git a/tools/generator/ApiVersionsSupport.cs b/tools/generator/ApiVersionsSupport.cs index 20e0f8315..7ae5a3e3e 100644 --- a/tools/generator/ApiVersionsSupport.cs +++ b/tools/generator/ApiVersionsSupport.cs @@ -20,16 +20,25 @@ public interface IApiAvailability int ApiAvailableSince { get; set; } } - public static void AssignApiLevels (IList gens, string apiVersionsXml, string currentApiLevelString) + static IEnumerable FlattenGens (IEnumerable gens) { - int dummy; - int currentApiLevel = int.TryParse (currentApiLevelString, out dummy) ? dummy : int.MaxValue; + foreach (var g in gens) { + yield return g; + foreach (var nt in FlattenGens (g.NestedTypes)) + yield return nt; + } + } + public static void AssignApiLevels (IList gens, string apiVersionsXml) + { + var flattenGens = FlattenGens (gens); var versions = new ApiVersionsProvider (); versions.Parse (apiVersionsXml); foreach (var type in versions.Versions.Values) { - var matchedGens = gens.Where (g => g.JavaName == type.Name); + var matchedGens = flattenGens.Where (g => g.JavaName == type.Name); if (!matchedGens.Any ()) + // There are known missing types, and it's going to be too noisy to report missing ones here. + // That task should be done elsewhere. continue; foreach (var gen in matchedGens) gen.ApiAvailableSince = type.Since; @@ -38,9 +47,6 @@ public static void AssignApiLevels (IList gens, string apiVersionsXml, // it might be moved to the corresponding class. if (genf != null) genf.ApiAvailableSince = field.Since > 0 ? field.Since : type.Since; - // commenting out this, because there are too many enum-mapped fields (removed). - //else - // Console.Error.WriteLine ("!!!!! In type {0}, field {1} not found.", type.Name, field.Name); } Func methodMatch = (m, method) => m.JavaName == method.MethodName && m.JniSignature == method.Name.Substring (method.MethodName.Length); @@ -52,9 +58,6 @@ public static void AssignApiLevels (IList gens, string apiVersionsXml, matchedGens.SelectMany (g => GetAllMethods (g)).FirstOrDefault (m => methodMatch (m, method)); if (genm != null) genm.ApiAvailableSince = method.Since > 0 ? method.Since : type.Since; - // there are several "missing" stuff from android.test packages (unbound yet). - else if (!type.Name.StartsWith ("android.test") && method.Since <= currentApiLevel) - Report.Warning (0, Report.WarningAnnotationsProvider, " api-versions.xml mensions type {0}, methodbase {1}, but not found.", type.Name, method.Name); } } } diff --git a/tools/generator/CodeGenerator.cs b/tools/generator/CodeGenerator.cs index 8fb650f5f..523c0f9dc 100644 --- a/tools/generator/CodeGenerator.cs +++ b/tools/generator/CodeGenerator.cs @@ -318,7 +318,7 @@ static void Run (CodeGeneratorOptions options, DirectoryAssemblyResolver resolve Validate (gens, opt); if (api_versions_xml != null) - ApiVersionsSupport.AssignApiLevels (gens, api_versions_xml, api_level); + ApiVersionsSupport.AssignApiLevels (gens, api_versions_xml); foreach (GenBase gen in gens) gen.FillProperties ();