This repository was archived by the owner on Aug 27, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 27, 2026. It is now read-only.
Generated files (e.g, Java.Interop.__TypeRegistrations.cs) should mark themselves as auto-generated #1051
Copy link
Copy link
Closed
Labels
enhancementProposed change to current functionalityProposed change to current functionalitygeneratorIssues binding a Java library (generator, class-parse, etc.)Issues binding a Java library (generator, class-parse, etc.)
Milestone
Description
Activity
- addedenhancementProposed change to current functionalityProposed change to current functionalitygeneratorIssues binding a Java library (generator, class-parse, etc.)Issues binding a Java library (generator, class-parse, etc.)and removed
on Oct 15, 2022 Some examples of what a regular console .NET 6 program generates:
- .NETCoreApp,Version=v6.0.AssemblyAttributes.cs:
// <autogenerated /> using System; ...
- {application}.AssemblyInfo.cs:
//------------------------------------------------------------------------------ // <auto-generated> // This code was generated by a tool. // Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </auto-generated> //------------------------------------------------------------------------------ using System; ...
Using the longer version could also help with issues like dotnet/android#7449.
Can you post a
Java.Interop.__TypeRegistrations.csthat demonstrates the CA1825 warning? It looks like all the arrays should have content in them, unless your binding library doesn't bind any types or something? Or maybe all the types it binds arestatic?Example:
public static void RegisterPackages () { #if MONODROID_TIMING var start = DateTime.Now; Android.Util.Log.Info ("MonoDroid-Timing", "RegisterPackages start: " + (start - new DateTime (1970, 1, 1)).TotalMilliseconds); #endif // def MONODROID_TIMING Java.Interop.TypeManager.RegisterPackages ( new string[]{ "com/google/common/flogger", "com/google/common/flogger/backend", "com/google/common/flogger/context", "com/google/common/flogger/parameter", "com/google/common/flogger/parser", "com/google/common/flogger/util", }, new Converter<string, Type?>[]{ lookup_com_google_common_flogger_package, lookup_com_google_common_flogger_backend_package, lookup_com_google_common_flogger_context_package, lookup_com_google_common_flogger_parameter_package, lookup_com_google_common_flogger_parser_package, lookup_com_google_common_flogger_util_package, }); #if MONODROID_TIMING var end = DateTime.Now; Android.Util.Log.Info ("MonoDroid-Timing", "RegisterPackages time: " + (end - new DateTime (1970, 1, 1)).TotalMilliseconds + " [elapsed: " + (end - start).TotalMilliseconds + " ms]"); #endif // def MONODROID_TIMING }
@jpobst This is what I'm seeing:
using System; using System.Collections.Generic; using Android.Runtime; namespace Java.Interop { partial class __TypeRegistrations { public static void RegisterPackages () { #if MONODROID_TIMING var start = DateTime.Now; Android.Util.Log.Info ("MonoDroid-Timing", "RegisterPackages start: " + (start - new DateTime (1970, 1, 1)).TotalMilliseconds); #endif // def MONODROID_TIMING Java.Interop.TypeManager.RegisterPackages ( new string[]{ }, new Converter<string, Type>[]{ }); #if MONODROID_TIMING var end = DateTime.Now; Android.Util.Log.Info ("MonoDroid-Timing", "RegisterPackages time: " + (end - new DateTime (1970, 1, 1)).TotalMilliseconds + " [elapsed: " + (end - start).TotalMilliseconds + " ms]"); #endif // def MONODROID_TIMING } #if NET5_0_OR_GREATER [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage ("Trimming", "IL2057")] #endif static Type Lookup (string[] mappings, string javaType) { var managedType = Java.Interop.TypeManager.LookupTypeMapping (mappings, javaType); if (managedType == null) return null; return Type.GetType (managedType); } } }
- added a commit that references this issue
on Oct 20, 2022 - added a commit that references this issue
on Nov 1, 2022 - locked and limited conversation to collaborators
on Apr 12, 2024 - added a commit that references this issue
on Jul 1, 2026
Metadata
Metadata
Assignees
Labels
enhancementProposed change to current functionalityProposed change to current functionalitygeneratorIssues binding a Java library (generator, class-parse, etc.)Issues binding a Java library (generator, class-parse, etc.)
Android application type
Classic Xamarin.Android (MonoAndroid12.0, etc.), Android for .NET (net6.0-android, etc.)
Affected platform version
MonoAndroid13.0 and net6.0-android
Description
With a project where CA1812 and CA are enforced as errors, the following is observed:
// <auto-generated/>comment at the top so that Roslyn marks them as auto-generated and skips most analyzers for them.Steps to Reproduce
Did you find any workaround?
No response
Relevant log output
No response