-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement .NET 6 features for templates. #3018
Merged
Merged
Changes from 21 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
1fbec27
Implement .NET 6 features for templates. Implicit/Global Usings, Scop…
jamesmontemagno 74c8735
Updates based on feedback
jamesmontemagno 375df93
Forecast
jamesmontemagno 1a469de
Sort usings
jamesmontemagno 2392b30
revert back blazor weather stuff
jamesmontemagno cf1ed40
More changes based on feedback
jamesmontemagno 7718ff3
Adjjust appxmanifest for tempaltes
jamesmontemagno 3202407
Merge branch 'main' into dotnet6ify-templates
jamesmontemagno fefc64b
comment out windows again
jamesmontemagno 12eb743
Cleanup merges
jamesmontemagno 84be08b
Merge branch 'dotnet:main' into dotnet6ify-templates
jamesmontemagno dac8e2a
Update MauiApp.1.csproj
jamesmontemagno 84a7e41
Update MauiApp.1.csproj
jamesmontemagno 043e0c9
revert changes back
jamesmontemagno fbdf533
Merge branch 'dotnet6ify-templates' of https://github.com/jamesmontem…
jamesmontemagno 2675ba8
Changes based on conversation
jamesmontemagno 85828ea
Add back usings from native platforms
jamesmontemagno 0987eb2
Merge branch 'dotnet:main' into dotnet6ify-templates
jamesmontemagno 4845597
Merge branch 'release/6.0.1xx-preview10' into dotnet6ify-templates
jamesmontemagno 8d042c5
Revert back lib
jamesmontemagno 4d4c0a6
Merge branch 'dotnet6ify-templates' of https://github.com/jamesmontem…
jamesmontemagno a8a4c10
Merge remote-tracking branch 'origin/main' into pr/3018
mattleibow 6118f7f
No need for the alias
mattleibow 0d0e9dc
Merge remote-tracking branch 'origin/main' into pr/3018
mattleibow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,13 @@ | ||
using Microsoft.Maui; | ||
using Microsoft.Maui.Controls; | ||
using Microsoft.Maui.Controls.PlatformConfiguration.WindowsSpecific; | ||
using Application = Microsoft.Maui.Controls.Application; | ||
using MauiApplication = Microsoft.Maui.Controls.Application; | ||
|
||
namespace MauiApp._1 | ||
namespace MauiApp._1; | ||
|
||
public partial class App : MauiApplication | ||
{ | ||
public partial class App : Application | ||
public App() | ||
{ | ||
public App() | ||
{ | ||
InitializeComponent(); | ||
InitializeComponent(); | ||
|
||
MainPage = new MainPage(); | ||
} | ||
MainPage = new MainPage(); | ||
} | ||
} |
15 changes: 6 additions & 9 deletions
15
src/Templates/src/templates/maui-blazor/Data/WeatherForecast.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,12 @@ | ||
using System; | ||
namespace MauiApp._1.Data; | ||
|
||
namespace MauiApp._1.Data | ||
public class WeatherForecast | ||
{ | ||
public class WeatherForecast | ||
{ | ||
public DateTime Date { get; set; } | ||
public DateTime Date { get; set; } | ||
|
||
public int TemperatureC { get; set; } | ||
public int TemperatureC { get; set; } | ||
|
||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); | ||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); | ||
|
||
public string Summary { get; set; } | ||
} | ||
public string Summary { get; set; } | ||
} |
30 changes: 13 additions & 17 deletions
30
src/Templates/src/templates/maui-blazor/Data/WeatherForecastService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,20 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
namespace MauiApp._1.Data; | ||
|
||
namespace MauiApp._1.Data | ||
public class WeatherForecastService | ||
{ | ||
public class WeatherForecastService | ||
private static readonly string[] Summaries = new[] | ||
{ | ||
private static readonly string[] Summaries = new[] | ||
{ | ||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" | ||
}; | ||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" | ||
}; | ||
|
||
public Task<WeatherForecast[]> GetForecastAsync(DateTime startDate) | ||
public Task<WeatherForecast[]> GetForecastAsync(DateTime startDate) | ||
{ | ||
return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast | ||
{ | ||
return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast | ||
{ | ||
Date = startDate.AddDays(index), | ||
TemperatureC = Random.Shared.Next(-20, 55), | ||
Summary = Summaries[Random.Shared.Next(Summaries.Length)] | ||
}).ToArray()); | ||
} | ||
Date = startDate.AddDays(index), | ||
TemperatureC = Random.Shared.Next(-20, 55), | ||
Summary = Summaries[Random.Shared.Next(Summaries.Length)] | ||
}).ToArray()); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
global using Microsoft.Extensions.DependencyInjection; | ||
global using Microsoft.Maui; | ||
global using Microsoft.Maui.Controls; | ||
global using Microsoft.Maui.Controls.Hosting; | ||
jamesmontemagno marked this conversation as resolved.
Show resolved
Hide resolved
|
||
global using Microsoft.Maui.Controls.Xaml; | ||
global using Microsoft.Maui.Essentials; | ||
global using Microsoft.Maui.Hosting; | ||
global using System; | ||
global using System.Collections.Generic; | ||
global using System.IO; | ||
global using System.Linq; | ||
global using System.Net.Http; | ||
global using System.Threading; | ||
global using System.Threading.Tasks; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,9 @@ | ||
using System; | ||
using Microsoft.Maui.Controls; | ||
namespace MauiApp._1; | ||
|
||
namespace MauiApp._1 | ||
public partial class MainPage : ContentPage | ||
{ | ||
public partial class MainPage : ContentPage | ||
public MainPage() | ||
{ | ||
public MainPage() | ||
{ | ||
InitializeComponent(); | ||
} | ||
InitializeComponent(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,24 @@ | ||
using Microsoft.AspNetCore.Components.WebView.Maui; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Maui; | ||
using Microsoft.Maui.Hosting; | ||
using Microsoft.Maui.Controls.Compatibility; | ||
using Microsoft.Maui.Controls.Hosting; | ||
using MauiApp._1.Data; | ||
|
||
namespace MauiApp._1 | ||
namespace MauiApp._1; | ||
|
||
public static class MauiProgram | ||
{ | ||
public static class MauiProgram | ||
public static MauiApp CreateMauiApp() | ||
{ | ||
public static MauiApp CreateMauiApp() | ||
{ | ||
var builder = MauiApp.CreateBuilder(); | ||
builder | ||
.RegisterBlazorMauiWebView() | ||
.UseMauiApp<App>() | ||
.ConfigureFonts(fonts => | ||
{ | ||
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); | ||
}); | ||
var builder = MauiApp.CreateBuilder(); | ||
builder | ||
.RegisterBlazorMauiWebView() | ||
.UseMauiApp<App>() | ||
.ConfigureFonts(fonts => | ||
{ | ||
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); | ||
}); | ||
|
||
builder.Services.AddBlazorWebView(); | ||
builder.Services.AddSingleton<WeatherForecastService>(); | ||
builder.Services.AddBlazorWebView(); | ||
builder.Services.AddSingleton<WeatherForecastService>(); | ||
|
||
return builder.Build(); | ||
} | ||
return builder.Build(); | ||
} | ||
} | ||
} |
21 changes: 16 additions & 5 deletions
21
src/Templates/src/templates/maui-blazor/Platforms/Android/MainActivity.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,22 @@ | ||
using Android.App; | ||
using Android.Content.PM; | ||
using Microsoft.Maui; | ||
using Android.OS; | ||
|
||
namespace MauiApp._1 | ||
namespace MauiApp._1; | ||
|
||
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize)] | ||
public class MainActivity : MauiAppCompatActivity | ||
{ | ||
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize)] | ||
public class MainActivity : MauiAppCompatActivity | ||
protected override void OnCreate(Bundle savedInstanceState) | ||
{ | ||
base.OnCreate(savedInstanceState); | ||
Platform.Init(this, savedInstanceState); | ||
} | ||
|
||
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults) | ||
jamesmontemagno marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults); | ||
|
||
base.OnRequestPermissionsResult(requestCode, permissions, grantResults); | ||
} | ||
} | ||
} |
24 changes: 10 additions & 14 deletions
24
src/Templates/src/templates/maui-blazor/Platforms/Android/MainApplication.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,15 @@ | ||
using System; | ||
using Android.App; | ||
using Android.App; | ||
using Android.Runtime; | ||
using Microsoft.Maui; | ||
using Microsoft.Maui.Hosting; | ||
|
||
namespace MauiApp._1 | ||
namespace MauiApp._1; | ||
|
||
[Application] | ||
public class MainApplication : MauiApplication | ||
{ | ||
[Application] | ||
public class MainApplication : MauiApplication | ||
public MainApplication(IntPtr handle, JniHandleOwnership ownership) | ||
: base(handle, ownership) | ||
{ | ||
public MainApplication(IntPtr handle, JniHandleOwnership ownership) | ||
: base(handle, ownership) | ||
{ | ||
} | ||
|
||
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); | ||
} | ||
} | ||
|
||
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); | ||
} |
15 changes: 6 additions & 9 deletions
15
src/Templates/src/templates/maui-blazor/Platforms/MacCatalyst/AppDelegate.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,9 @@ | ||
using Foundation; | ||
using Microsoft.Maui; | ||
using Microsoft.Maui.Hosting; | ||
|
||
namespace MauiApp._1 | ||
namespace MauiApp._1; | ||
|
||
[Register("AppDelegate")] | ||
public class AppDelegate : MauiUIApplicationDelegate | ||
{ | ||
[Register("AppDelegate")] | ||
public class AppDelegate : MauiUIApplicationDelegate | ||
{ | ||
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); | ||
} | ||
} | ||
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); | ||
} |
17 changes: 8 additions & 9 deletions
17
src/Templates/src/templates/maui-blazor/Platforms/MacCatalyst/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
using UIKit; | ||
|
||
namespace MauiApp._1 | ||
namespace MauiApp._1; | ||
|
||
public class Program | ||
{ | ||
public class Program | ||
// This is the main entry point of the application. | ||
static void Main(string[] args) | ||
{ | ||
// This is the main entry point of the application. | ||
static void Main(string[] args) | ||
{ | ||
// if you want to use a different Application Delegate class from "AppDelegate" | ||
// you can specify it here. | ||
UIApplication.Main(args, null, typeof(AppDelegate)); | ||
} | ||
// if you want to use a different Application Delegate class from "AppDelegate" | ||
// you can specify it here. | ||
UIApplication.Main(args, null, typeof(AppDelegate)); | ||
} | ||
} |
39 changes: 18 additions & 21 deletions
39
src/Templates/src/templates/maui-blazor/Platforms/Windows/App.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,31 @@ | ||
using Microsoft.Maui; | ||
using Microsoft.Maui.Hosting; | ||
using Microsoft.UI.Xaml; | ||
using Windows.ApplicationModel; | ||
using Microsoft.UI.Xaml; | ||
|
||
// To learn more about WinUI, the WinUI project structure, | ||
// and more about our project templates, see: http://aka.ms/winui-project-info. | ||
|
||
namespace MauiApp._1.WinUI | ||
namespace MauiApp._1.WinUI; | ||
|
||
/// <summary> | ||
/// Provides application-specific behavior to supplement the default Application class. | ||
/// </summary> | ||
public partial class App : MauiWinUIApplication | ||
{ | ||
/// <summary> | ||
/// Provides application-specific behavior to supplement the default Application class. | ||
/// Initializes the singleton application object. This is the first line of authored code | ||
/// executed, and as such is the logical equivalent of main() or WinMain(). | ||
/// </summary> | ||
public partial class App : MauiWinUIApplication | ||
public App() | ||
{ | ||
/// <summary> | ||
/// Initializes the singleton application object. This is the first line of authored code | ||
/// executed, and as such is the logical equivalent of main() or WinMain(). | ||
/// </summary> | ||
public App() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
this.InitializeComponent(); | ||
} | ||
|
||
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); | ||
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); | ||
|
||
protected override void OnLaunched(LaunchActivatedEventArgs args) | ||
{ | ||
base.OnLaunched(args); | ||
protected override void OnLaunched(LaunchActivatedEventArgs args) | ||
{ | ||
base.OnLaunched(args); | ||
|
||
Microsoft.Maui.Essentials.Platform.OnLaunched(args); | ||
} | ||
Platform.OnLaunched(args); | ||
} | ||
} | ||
|
15 changes: 6 additions & 9 deletions
15
src/Templates/src/templates/maui-blazor/Platforms/iOS/AppDelegate.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,9 @@ | ||
using Foundation; | ||
using Microsoft.Maui; | ||
using Microsoft.Maui.Hosting; | ||
|
||
namespace MauiApp._1 | ||
namespace MauiApp._1; | ||
|
||
[Register("AppDelegate")] | ||
public class AppDelegate : MauiUIApplicationDelegate | ||
{ | ||
[Register("AppDelegate")] | ||
public class AppDelegate : MauiUIApplicationDelegate | ||
{ | ||
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); | ||
} | ||
} | ||
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); | ||
} |
19 changes: 9 additions & 10 deletions
19
src/Templates/src/templates/maui-blazor/Platforms/iOS/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
using UIKit; | ||
|
||
namespace MauiApp._1 | ||
namespace MauiApp._1; | ||
|
||
public class Program | ||
{ | ||
public class Program | ||
// This is the main entry point of the application. | ||
static void Main(string[] args) | ||
{ | ||
// This is the main entry point of the application. | ||
static void Main(string[] args) | ||
{ | ||
// if you want to use a different Application Delegate class from "AppDelegate" | ||
// you can specify it here. | ||
UIApplication.Main(args, null, typeof(AppDelegate)); | ||
} | ||
// if you want to use a different Application Delegate class from "AppDelegate" | ||
// you can specify it here. | ||
UIApplication.Main(args, null, typeof(AppDelegate)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,6 @@ | ||
using System; | ||
namespace MauiLib1; | ||
|
||
namespace MauiLib1 | ||
// All the code in this file is included in all platforms. | ||
public class Class1 | ||
{ | ||
// All the code in this file is included in all platforms. | ||
public class Class1 | ||
{ | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use
MauiApplication
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI @jamesmontemagno this one change was reverted because it wasn't clear it's necessary and it might create even more confusion with MAUI's 4 or 5 different "Application" types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds fine to me... why was it ever needed? Is application a conflict with the new usings at all though?