Skip to content

Commit a0d420e

Browse files
committed
[Java.Interop] Enable PublicApiAnalyzers to prevent API contract breakage.
1 parent 8b85462 commit a0d420e

File tree

5 files changed

+937
-12
lines changed

5 files changed

+937
-12
lines changed

src/Java.Interop/Java.Interop.csproj

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<TargetFramework>$(DotNetTargetFramework)</TargetFramework>
99
</PropertyGroup>
1010
<PropertyGroup>
11-
<NoWarn>$(NoWarn);1591</NoWarn>
11+
<NoWarn>$(NoWarn);1591;RS0041</NoWarn>
1212
<SignAssembly>true</SignAssembly>
1313
<AssemblyOriginatorKeyFile>..\..\product.snk</AssemblyOriginatorKeyFile>
1414
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
@@ -88,18 +88,11 @@
8888
<DependentUpon>JniPeerMembers.JniInstanceMethods_Invoke.tt</DependentUpon>
8989
</Compile>
9090
</ItemGroup>
91-
<ProjectExtensions>
92-
<MonoDevelop>
93-
<Properties>
94-
<Policies>
95-
<VersionControlPolicy>
96-
<CommitMessageStyle Indent="&#x9;" LineAlign="0" IncludeDirectoryPaths="True" />
97-
</VersionControlPolicy>
98-
</Policies>
99-
</Properties>
100-
</MonoDevelop>
101-
</ProjectExtensions>
10291
<ItemGroup>
92+
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.4">
93+
<PrivateAssets>all</PrivateAssets>
94+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
95+
</PackageReference>
10396
<PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="All" />
10497
</ItemGroup>
10598
<Import Project="Java.Interop.targets" />

src/Java.Interop/Java.Interop/JavaObjectArray.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public class JavaObjectArray<T> : JavaArray<T>
1111
{
1212
internal static readonly ValueMarshaler Instance = new ValueMarshaler ();
1313

14+
[SuppressMessage ("ApiDesign", "RS0022:Constructor make noninheritable base class inheritable", Justification = "Existing public API")]
1415
public JavaObjectArray (ref JniObjectReference handle, JniObjectReferenceOptions options)
1516
: base (ref handle, options)
1617
{
@@ -29,20 +30,23 @@ static JniObjectReference NewArray (int length)
2930
}
3031
}
3132

33+
[SuppressMessage ("ApiDesign", "RS0022:Constructor make noninheritable base class inheritable", Justification = "Existing public API")]
3234
public unsafe JavaObjectArray (int length)
3335
: this (ref *InvalidJniObjectReference, JniObjectReferenceOptions.None)
3436
{
3537
var peer = NewArray (CheckLength (length));
3638
Construct (ref peer, JniObjectReferenceOptions.CopyAndDispose);
3739
}
3840

41+
[SuppressMessage ("ApiDesign", "RS0022:Constructor make noninheritable base class inheritable", Justification = "Existing public API")]
3942
public JavaObjectArray (IList<T> value)
4043
: this (CheckLength (value))
4144
{
4245
for (int i = 0; i < value.Count; ++i)
4346
SetElementAt (i, value [i]);
4447
}
4548

49+
[SuppressMessage ("ApiDesign", "RS0022:Constructor make noninheritable base class inheritable", Justification = "Existing public API")]
4650
public JavaObjectArray (IEnumerable<T> value)
4751
: this (ToList (value))
4852
{

src/Java.Interop/Java.Interop/JniValueMarshaler.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public struct JniValueMarshalerState : IEquatable<JniValueMarshalerState> {
4949
public IJavaPeerable? PeerableValue {get; private set;}
5050
public object? Extra {get; private set;}
5151

52+
[SuppressMessage ("ApiDesign", "RS0026:Do not add multiple public overloads with optional parameters", Justification = "Existing public API")]
5253
public JniValueMarshalerState (JniArgumentValue jniArgumentValue, object? extra = null)
5354
{
5455
JniArgumentValue = jniArgumentValue;
@@ -57,6 +58,7 @@ public JniValueMarshalerState (JniArgumentValue jniArgumentValue, object? extra
5758
Extra = extra;
5859
}
5960

61+
[SuppressMessage ("ApiDesign", "RS0026:Do not add multiple public overloads with optional parameters", Justification = "Existing public API")]
6062
public JniValueMarshalerState (JniObjectReference referenceValue, object? extra = null)
6163
{
6264
JniArgumentValue = new JniArgumentValue (referenceValue);
@@ -65,6 +67,7 @@ public JniValueMarshalerState (JniObjectReference referenceValue, object? extra
6567
Extra = extra;
6668
}
6769

70+
[SuppressMessage ("ApiDesign", "RS0026:Do not add multiple public overloads with optional parameters", Justification = "Existing public API")]
6871
public JniValueMarshalerState (IJavaPeerable? peerableValue, object? extra = null)
6972
{
7073
PeerableValue = peerableValue;

0 commit comments

Comments
 (0)