Skip to content
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
namespace Microsoft.Android.Sdk.TrimmableTypeMap.Tests;

/// <summary>
/// Tests for [ExportField] support: the scanner must detect [ExportField] attributes
/// and the JCW generator must emit Java field declarations initialized by calling
/// the annotated method.
/// Tests for the [ExportField] scanner and model contracts.
/// </summary>
public class ExportFieldTests : FixtureTestBase
{
Expand Down Expand Up @@ -41,16 +39,14 @@ public void Scanner_ExportFieldMethod_HasExportConnectorAndFlag ()
}

[Fact]
public void JcwGenerator_EmitsFieldDeclarationsAndMethodWrappers ()
public void JcwGenerator_EmitsInstanceFieldDeclarationAndMethodWrapper ()
{
var peer = FindFixtureByJavaName ("my/app/ExportFieldExample");
var generator = new JcwJavaSourceGenerator ();
using var writer = new StringWriter ();
generator.Generate (peer, writer);
var java = writer.ToString ();

Assert.Contains ("public static", java);
Assert.Contains ("STATIC_INSTANCE = GetInstance ();", java);
Assert.Contains ("VALUE = GetValue ();", java);
Assert.Contains ("GetValue ()", java);
Assert.Contains ("n_GetValue", java);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,6 @@ static MemoryStream GenerateRootAssembly (IReadOnlyList<string> perAssemblyNames
static MethodDefinitionHandle FindMethodDefinition (MetadataReader reader, string methodName) =>
reader.MethodDefinitions.First (h => reader.GetString (reader.GetMethodDefinition (h).Name) == methodName);

[Fact]
public void Generate_ProducesValidPEAssembly ()
{
using var stream = GenerateRootAssembly (new [] { "_App.TypeMap", "_Mono.Android.TypeMap" });
using var pe = new PEReader (stream);
Assert.True (pe.HasMetadata);
}

[Theory]
[InlineData (false)]
[InlineData (true)]
Expand Down
Loading