Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<!-- Add Roslyn analyzers NuGet to all projects -->
<ItemGroup Condition=" '$(DisableRoslynAnalyzers)' != 'True' ">
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="9.0.0">
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="10.0.301">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
40 changes: 20 additions & 20 deletions build-tools/jnienv-gen/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static string FixupType (this string t)
}
}

partial class Generator
partial sealed class Generator
{
static string jnienv_g_c;
static string jnienv_g_h;
Expand Down Expand Up @@ -656,7 +656,7 @@ static void GenerateNativeLibSource (TextWriter source, TextWriter header, strin
}
}

class JniFunction {
sealed class JniFunction {

public string DeclaringType;

Expand Down Expand Up @@ -797,7 +797,7 @@ public static TypeInfo Create (string type, string managedType = null)
string p;
if (pointerMapping.TryGetValue (type, out p))
return new BuiltinTypeInfo (type, p);
if (type.EndsWith ("*", StringComparison.Ordinal))
if (type.EndsWith ('*'))
return new BuiltinTypeInfo (type, "IntPtr");
return new BuiltinTypeInfo (type, type);
}
Expand Down Expand Up @@ -843,7 +843,7 @@ public virtual string[] VerifyParameter (HandleStyle style, string variable)
public virtual string[] GetManagedToMarshalCleanupStatements (HandleStyle style, string variable) => Array.Empty<string> ();
}

class BuiltinTypeInfo : TypeInfo {
sealed class BuiltinTypeInfo : TypeInfo {

/// <summary>
/// NOTE: .NET framework can't marshal this
Expand Down Expand Up @@ -886,7 +886,7 @@ public override string[] VerifyParameter (HandleStyle style, string variable)
{
if (managed != "IntPtr")
return new string [0];
var variableName = variable.StartsWith ("@", StringComparison.Ordinal)
var variableName = variable.StartsWith ('@')
? variable.Substring (1)
: variable;
return new[] {
Expand All @@ -896,7 +896,7 @@ public override string[] VerifyParameter (HandleStyle style, string variable)
}
}

class BooleanTypeInfo : TypeInfo {
sealed class BooleanTypeInfo : TypeInfo {

public BooleanTypeInfo (string jni)
: base (jni)
Expand Down Expand Up @@ -926,7 +926,7 @@ public override string GetManagedToMarshalExpression (HandleStyle style, string
}
}

class StringTypeInfo : TypeInfo {
sealed class StringTypeInfo : TypeInfo {

public StringTypeInfo (string jni)
: base (jni)
Expand Down Expand Up @@ -977,7 +977,7 @@ public override string[] GetMarshalToManagedStatements (HandleStyle style, strin

public override string[] VerifyParameter (HandleStyle style, string variable)
{
var variableName = variable.StartsWith ("@", StringComparison.Ordinal)
var variableName = variable.StartsWith ('@')
? variable.Substring (1)
: variable;
return new[] {
Expand Down Expand Up @@ -1011,7 +1011,7 @@ public override string[] GetManagedToMarshalCleanupStatements (HandleStyle style
}
}

class JniReleaseArrayElementsModeTypeInfo : TypeInfo {
sealed class JniReleaseArrayElementsModeTypeInfo : TypeInfo {

public JniReleaseArrayElementsModeTypeInfo ()
: base ("jint")
Expand Down Expand Up @@ -1041,7 +1041,7 @@ public override string GetManagedToMarshalExpression (HandleStyle style, string
}
}

class ArrayTypeInfo : LocalReferenceTypeInfo {
sealed class ArrayTypeInfo : LocalReferenceTypeInfo {

public ArrayTypeInfo (string jni)
: base (jni)
Expand Down Expand Up @@ -1090,7 +1090,7 @@ public override string GetManagedToMarshalExpression (HandleStyle style, string

public override string[] VerifyParameter (HandleStyle style, string variable)
{
var variableName = variable.StartsWith ("@", StringComparison.Ordinal)
var variableName = variable.StartsWith ('@')
? variable.Substring (1)
: variable;
switch (style) {
Expand Down Expand Up @@ -1137,23 +1137,23 @@ protected virtual bool IsStatic {
}
}

class InstanceFieldTypeInfo : IdTypeInfo {
sealed class InstanceFieldTypeInfo : IdTypeInfo {

public InstanceFieldTypeInfo (string jni)
: base (jni, "JniFieldInfo")
{
}
}

class InstanceMethodTypeInfo : IdTypeInfo {
sealed class InstanceMethodTypeInfo : IdTypeInfo {

public InstanceMethodTypeInfo (string jni)
: base (jni, "JniMethodInfo")
{
}
}

class StaticFieldTypeInfo : IdTypeInfo {
sealed class StaticFieldTypeInfo : IdTypeInfo {

public StaticFieldTypeInfo (string jni)
: base (jni, "JniFieldInfo")
Expand All @@ -1165,7 +1165,7 @@ protected override bool IsStatic {
}
}

class StaticMethodTypeInfo : IdTypeInfo {
sealed class StaticMethodTypeInfo : IdTypeInfo {

public StaticMethodTypeInfo (string jni)
: base (jni, "JniMethodInfo")
Expand Down Expand Up @@ -1244,7 +1244,7 @@ public override string[] GetMarshalToManagedStatements (HandleStyle style, strin

public override string[] VerifyParameter (HandleStyle style, string variable)
{
var variableName = variable.StartsWith ("@", StringComparison.Ordinal)
var variableName = variable.StartsWith ('@')
? variable.Substring (1)
: variable;
switch (style) {
Expand Down Expand Up @@ -1282,23 +1282,23 @@ public override string[] GetHandleCreationLogStatements (HandleStyle style, stri
}
}

class WeakGlobalReferenceTypeInfo : ObjectReferenceTypeInfo {
sealed class WeakGlobalReferenceTypeInfo : ObjectReferenceTypeInfo {

public WeakGlobalReferenceTypeInfo (string jni)
: base (jni, "JniObjectReferenceType.WeakGlobal")
{
}
}

class GlobalReferenceTypeInfo : ObjectReferenceTypeInfo {
sealed class GlobalReferenceTypeInfo : ObjectReferenceTypeInfo {

public GlobalReferenceTypeInfo (string jni)
: base (jni, "JniObjectReferenceType.Global")
{
}
}

class JavaVMPointerTypeInfo : TypeInfo {
sealed class JavaVMPointerTypeInfo : TypeInfo {

public JavaVMPointerTypeInfo (string jni)
: base (jni)
Expand Down Expand Up @@ -1353,7 +1353,7 @@ public override string[] GetManagedToMarshalCleanupStatements (HandleStyle style
}
}

class ParamInfo
sealed class ParamInfo
{
public TypeInfo Type;
public string Name;
Expand Down
4 changes: 2 additions & 2 deletions src/Java.Base-ref.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3539,7 +3539,7 @@ public sealed partial class Double : Java.Lang.Number, Java.Interop.IJavaPeerabl
public const int MinExponent = -1022;
public const double MinNormal = 2.2250738585072014E-308;
public const double MinValue = 5E-324;
public const double NaN = 0.0 / 0.0;
public const double Nan = 0.0 / 0.0;
public const double NegativeInfinity = -1.0 / 0.0;
public const double PositiveInfinity = 1.0 / 0.0;
public const int Size = 64;
Expand Down Expand Up @@ -3737,7 +3737,7 @@ public sealed partial class Float : Java.Lang.Number, Java.Interop.IJavaPeerable
public const int MinExponent = -126;
public const float MinNormal = 1.1754944E-38f;
public const float MinValue = 1E-45f;
public const float NaN = 0.0f / 0.0f;
public const float Nan = 0.0f / 0.0f;
public const float NegativeInfinity = -1.0f / 0.0f;
public const float PositiveInfinity = 1.0f / 0.0f;
public const int Size = 32;
Expand Down
2 changes: 1 addition & 1 deletion src/Java.Base/Java.Lang/ICharSequence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Java.Lang {

partial class ICharSequenceInvoker : IEnumerable {
partial sealed class ICharSequenceInvoker : IEnumerable {
}

public static partial class ICharSequenceExtensions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Java.Interop {
#if !JCW_ONLY_TYPE_NAMES
public
#endif // !JCW_ONLY_TYPE_NAMES
partial class ExportAttribute : Attribute {
partial sealed class ExportAttribute : Attribute {

public ExportAttribute ()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Java.Interop {
#if !JCW_ONLY_TYPE_NAMES
public
#endif // !JCW_ONLY_TYPE_NAMES
partial class ExportFieldAttribute : Attribute {
partial sealed class ExportFieldAttribute : Attribute {

public ExportFieldAttribute (string name)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Java.Interop {
#if !JCW_ONLY_TYPE_NAMES
public
#endif // !JCW_ONLY_TYPE_NAMES
partial class ExportParameterAttribute : Attribute {
partial sealed class ExportParameterAttribute : Attribute {

public ExportParameterAttribute (ExportParameterKind kind)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ static ConstantEntry FromVersion1String (CsvParser parser, bool transientMode)
EnumMember = parser.GetField (2),
JavaSignature = parser.GetField (3),
Value = parser.GetField (4),
IsFlags = parser.GetField (5).ToLowerInvariant () == "flags",
IsFlags = parser.GetField (5).Equals ("flags", StringComparison.InvariantCultureIgnoreCase),
FieldAction = transientMode ? FieldAction.Remove : FieldAction.Keep
};

Expand Down Expand Up @@ -134,7 +134,7 @@ static ConstantEntry FromVersion2String (CsvParser parser)
EnumFullType = parser.GetField (4),
EnumMember = parser.GetField (5),
FieldAction = FromFieldActionString (parser.GetField (6)),
IsFlags = parser.GetField (7).ToLowerInvariant () == "flags",
IsFlags = parser.GetField (7).Equals ("flags", StringComparison.InvariantCultureIgnoreCase),
DeprecatedSince = parser.GetFieldAsNullableAndroidSdkVersion (8)
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void Apply (ApiXmlDocument apiDocument, string apiLevelString, int produc
try {
var nodes = apiDocument.ApiDocument.XPathSelectElements (path).ToArray ();

if (nodes.Any ())
if (nodes.Length != 0)
foreach (var node in nodes)
node.Remove ();
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ public NamespaceTransform (string oldValue, string newValue)
OldValue = oldValue;
NewValue = newValue;

if (OldValue.EndsWith (".", StringComparison.Ordinal)) {
if (OldValue.EndsWith ('.')) {
IsStartsWith = true;
OldValue = OldValue.Substring (0, OldValue.Length - 1);
}

if (OldValue.StartsWith (".", StringComparison.Ordinal)) {
if (OldValue.StartsWith ('.')) {
IsEndsWith = true;
OldValue = OldValue.Substring (1);
}
Expand Down Expand Up @@ -57,15 +57,15 @@ public string Apply (string value)
// Handle a "starts with" transform
if (IsStartsWith) {
if (value.StartsWith (OldValue, StringComparison.OrdinalIgnoreCase))
return (NewValue + value.Substring (OldValue.Length)).TrimStart ('.');
return (string.Concat (NewValue, value.AsSpan (OldValue.Length))).TrimStart ('.');

return value;
}

// Handle an "ends with" transform
if (IsEndsWith) {
if (value.EndsWith (OldValue, StringComparison.OrdinalIgnoreCase))
return (value.Substring (0, value.Length - OldValue.Length) + NewValue).TrimEnd ('.');
return (string.Concat (value.AsSpan (0, value.Length - OldValue.Length), NewValue)).TrimEnd ('.');

return value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ static CallableWrapperMethod ImportMethod (CallableWrapperType type, XElement xm
return m;
}

private static readonly char [] separator = new [] { ',' };

static void FillInMethodDetails (CallableWrapperMethod method, XElement xml)
{
// Common between constructors and methods
Expand All @@ -175,7 +177,7 @@ static void FillInMethodDetails (CallableWrapperMethod method, XElement xml)
method.ActivateCall = xml.GetAttributeOrDefault ("activate_call", (string?) null);

if (xml.GetAttributeOrDefault ("thrown_type_names", (string?) null) is string thrownTypeNames)
method.ThrownTypeNames = thrownTypeNames.Split (new [] { ',' }, StringSplitOptions.RemoveEmptyEntries);
method.ThrownTypeNames = thrownTypeNames.Split (separator, StringSplitOptions.RemoveEmptyEntries);

ImportAnnotations (method.Annotations, xml.Element ("annotations"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ static ExportAttribute ToExportAttribute (CustomAttribute attr, IMemberDefinitio
if (attr.Properties.Count == 0)
return new ExportAttribute (name);
var typeArgs = (CustomAttributeArgument []) attr.Properties.FirstOrDefault (p => p.Name == "Throws").Argument.Value;
var thrown = typeArgs != null && typeArgs.Any ()
var thrown = typeArgs != null && typeArgs.Length != 0
? (from caa in typeArgs select JavaNativeTypeManager.Parse (GetJniTypeName ((TypeReference) caa.Value, cache))?.Type)
.Where (v => v != null)
.ToArray ()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ void Flatten (List<JavaType> list, JavaType t)
}
}

class JavaNestedType : JavaMember
sealed class JavaNestedType : JavaMember
{
public JavaNestedType (JavaType? type)
: base (type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ static NonTerminal CreateEndElement (string endElement, Grammar grammar, bool op
}

// Based in part on WikiTextTerminal
class CharacterDataTerminal : Terminal {
sealed class CharacterDataTerminal : Terminal {

char[]? _stopChars;

Expand Down Expand Up @@ -357,7 +357,7 @@ public override void Init (GrammarData grammarData)
}
}

class PreBlockDeclarationBodyTerminal : Terminal {
sealed class PreBlockDeclarationBodyTerminal : Terminal {

public PreBlockDeclarationBodyTerminal ()
: base ("<pre> body")
Expand Down Expand Up @@ -385,7 +385,7 @@ public override void Init (GrammarData grammarData)
}
}

class UnknownHtmlElementStartTerminal : Terminal {
sealed class UnknownHtmlElementStartTerminal : Terminal {

bool addingRemarks;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ internal void CreateRules (SourceJavadocToXmldocGrammar grammar)
}
}

class IgnorableCharTerminal : Terminal
sealed class IgnorableCharTerminal : Terminal
{
public IgnorableCharTerminal (string name)
: base (name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ public void FindBaseMethod (JavaClassModel? type)
// - TODO?: array indicator fixup ("T..." should match "T[]")
public static bool IsImplementing (JavaMethodModel derived, JavaMethodModel basis, IDictionary<JavaTypeReference, JavaTypeReference> genericInstantiation)
{
if (genericInstantiation == null)
throw new ArgumentNullException ("genericInstantiation");
ArgumentNullException.ThrowIfNull (genericInstantiation);

if (basis.Name != derived.Name)
return false;
Expand Down Expand Up @@ -170,7 +169,7 @@ static bool IsParameterAssignableTo (JavaParameterModel dp, JavaParameterModel b

static bool IsConformantType (JavaTypeParameter typeParameter, JavaTypeReference? examinedType)
{
if (!typeParameter.GenericConstraints.Any ())
if (typeParameter.GenericConstraints.Count == 0)
return true;
// FIXME: implement correct generic constraint conformance check.
//Log.LogDebug ("NOTICE: generic constraint conformance check is not implemented, so the type might be actually compatible. Type parameter: {0}{1}, examined type: {2}",
Expand Down
Loading