Skip to content

Generated ids as base-constructor arguments #10637

@ShortDevelopment

Description

@ShortDevelopment

Description

Following the android documentation about Fragments I tried to use the AppCompatActivity constructor-overload that takes a layout-id instead of calling SetContentView like I used to.

public sealed class MainActivity() : AppCompatActivity(Resource.Layout.activity_main)

Problem is: The base constructor never get's called (from .NET) as the RCW is already created when activating the activity.

I would argue that calling a base-constructor of an activatable class with arguments should at least give some build-time warning. Also it would be nice if integer constants would be supported when generating the constructor of the RCW as I cannot use the ExportAttribute with generated constants (See below).

Did you find any workaround?

No.

I tried to use the ExportAttribute like so:

[method: Export(SuperArgumentsString = $"{Resource.Layout.activity_main}")]
public sealed class MainActivity() : AppCompatActivity(Resource.Layout.activity_main)

but c# only allows strings in interpolated string constants (not integers).

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageIssues that need to be assigned.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions