Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[templates] fix broken/wrong item template contents (#7366)
After working on #7349, I found some really odd behavior if you name an Android layout, `my_cool_layout.xml`. VS appears to generate: <?xml version="1.0" encoding="utf-8"?> <Linearmy_cool_layout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:my_cool_layout_width="match_parent" android:my_cool_layout_height="match_parent"> </Linearmy_cool_layout> This is completely broken! It appears that anywhere the word `Layout` was replaced with `my_cool_layout`. I also get the same behavior with `dotnet new android-layout -n my_cool_layout`. To solve this issue, I made the default name `Layout1`, so that `<LinearLayout/>` and `android:layout_width`, are not replaced. Now I get a `my_cool_layout.xml` with the contents: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> </LinearLayout> Secondly, the `android-activity` template if you run: dotnet new android-activity -n MyActivity It will generate: [Activity(Label = "@string/app_name", MainLauncher = true)] public class MyActivity : Activity Let's replace the label with the name passed in, and remove `MainLauncher=true`, so we instead get: [Activity(Label = "MyActivity")] public class MyActivity : Activity I think this will prevent confusion with multiple app launchers, etc.
- Loading branch information