Android C# Code Analysis

Activity Icon Should Be Mip Map

Inspects usages of the [Activity] attribute and validates the Icon property uses a mip map instead of a drawable.

Application Requires Peer Connection Constructor

Check Android.Content.Res.Resources Usages

When using the Android.Content.Res.Resources class, all Get* expressions expect the correct resource type identifier. For example, when using Resource.GetString(), a resource identifier of Resources.String.myString is expected. Passing any other resource identifier such as Resource.Color.myColor may result in unintended data being used or runtime exceptions. This code analyser validates that the correct resource type is being provided to the API call.

Class Derives From IJavaObject

Often when creating new classes in a Xamarin.Android codebase developers will need a new class to be usable between Java and C#. Xamarin.Android provides the IJavaObject interface to expose a class to Java. Instead of directly inheriting from the IJavaObject interface, a developer should instead inherit from Java.Lang.Object which implements the required interface members.

Incorrect Activity Creation

This analyser detects when a developer is instantiating an Android activity or activity subclass directly using a new expression. Activities should only ever be created through the operating system; creating them through a new expression leaves them in an invalid state.

Verify Toast Is Shown

Sometimes when a Toast is created via MakeText, the Show method is accidently omitted. This analysis routine looks for invocations of Toast.MakeText() that don't then invoke the Show() method on the toast object in the same expression. If the MakeText() result is assigned into a variable or passed as a method argument then this check is skipped.

Warn Of Static Context References

This analyser inspects static variable declarations within classes and checks if the type derives from Android.Content.Context. Static context references have the potential to cause large memory leaks.