Skip to content
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

Fixes Code Analysis issues for C# templates #229

Merged
merged 4 commits into from
Aug 14, 2023
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
2 changes: 1 addition & 1 deletion templates/csharp/app-mvvm/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace AvaloniaAppTemplate;

class Program
sealed class Program
{
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
Expand Down
2 changes: 2 additions & 0 deletions templates/csharp/app-mvvm/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ public partial class MainWindowViewModel : ViewModelBase
public class MainWindowViewModel : ViewModelBase
#endif
{
#pragma warning disable CA1822 // Mark members as static
public string Greeting => "Welcome to Avalonia!";
#pragma warning restore CA1822 // Mark members as static
}
4 changes: 2 additions & 2 deletions templates/csharp/xplat/AvaloniaTest.Browser/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

[assembly: SupportedOSPlatform("browser")]

internal partial class Program
internal sealed partial class Program
{
private static async Task Main(string[] args) => await BuildAvaloniaApp()
private static Task Main(string[] args) => BuildAvaloniaApp()
.WithInterFont()
.UseReactiveUI()
.StartBrowserAppAsync("out");
Expand Down
2 changes: 1 addition & 1 deletion templates/csharp/xplat/AvaloniaTest.Desktop/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace AvaloniaTest.Desktop;

class Program
sealed class Program
{
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
Expand Down
2 changes: 2 additions & 0 deletions templates/csharp/xplat/AvaloniaTest.iOS/AppDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ namespace AvaloniaTest.iOS;
// User Interface of the application, as well as listening (and optionally responding) to
// application events from iOS.
[Register("AppDelegate")]
#pragma warning disable CA1711 // Identifiers should not have incorrect suffix
public partial class AppDelegate : AvaloniaAppDelegate<App>
#pragma warning restore CA1711 // Identifiers should not have incorrect suffix
{
protected override AppBuilder CustomizeAppBuilder(AppBuilder builder)
{
Expand Down
10 changes: 5 additions & 5 deletions templates/csharp/xplat/AvaloniaTest/ViewLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ namespace AvaloniaTest;
public class ViewLocator : IDataTemplate
{
#if (AvaloniaStableChosen)
public IControl Build(object data)
public IControl Build(object param)
#else
public Control Build(object data)
public Control? Build(object param)
#endif
{
if (data is null)
if (param is null)
return null;

var name = data.GetType().FullName!.Replace("ViewModel", "View");
var name = param.GetType().FullName!.Replace("ViewModel", "View", StringComparison.Ordinal);
var type = Type.GetType(name);

if (type != null)
{
return (Control)Activator.CreateInstance(type)!;
}

return new TextBlock { Text = name };
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@

public class MainViewModel : ViewModelBase
{
#pragma warning disable CA1822 // Mark members as static
public string Greeting => "Welcome to Avalonia!";
#pragma warning restore CA1822 // Mark members as static
}