Skip to content

Commit

Permalink
Revert "Added fix to support spaces between the method name and its `…
Browse files Browse the repository at this point in the history
…()` to prevent a false positive MCTME001 error (CommunityToolkit#1477)"

This reverts commit cf6360d.
  • Loading branch information
ne0rrmatrix committed Sep 18, 2024
1 parent 5bcb930 commit 0f22e23
Show file tree
Hide file tree
Showing 34 changed files with 269 additions and 715 deletions.
1 change: 0 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ csharp_style_conditional_delegate_call = true:suggestion

# Collection Expressions
dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion
dotnet_diagnostic.IDE0303.severity = suggestion

# Naming rules

Expand Down
17 changes: 9 additions & 8 deletions samples/CommunityToolkit.Maui.Sample/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@
using Microsoft.Extensions.Http.Resilience;
using Microsoft.Extensions.Logging;
using Microsoft.Maui.LifecycleEvents;
using Microsoft.Maui.Platform;
using Polly;


#if WINDOWS10_0_17763_0_OR_GREATER
using Microsoft.UI;
using Microsoft.UI.Composition.SystemBackdrops;
using Microsoft.UI.Windowing;
using Microsoft.UI.Xaml.Media;
using Microsoft.Maui.Platform;
#endif

[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
Expand All @@ -51,12 +52,12 @@ public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder()
#if DEBUG
.UseMauiCommunityToolkit(static options =>
.UseMauiCommunityToolkit(options =>
{
options.SetShouldEnableSnackbarOnWindows(true);
})
#else
.UseMauiCommunityToolkit(static options =>
.UseMauiCommunityToolkit(options =>
{
options.SetShouldEnableSnackbarOnWindows(true);
options.SetShouldSuppressExceptionsInConverters(true);
Expand All @@ -69,7 +70,7 @@ public static MauiApp CreateMauiApp()
.UseMauiCommunityToolkitMediaElement()
.UseMauiCommunityToolkitMaps("KEY") // You should add your own key here from bingmapsportal.com
.UseMauiApp<App>()
.ConfigureFonts(static fonts =>
.ConfigureFonts(fonts =>
{
fonts.AddFont("Font Awesome 6 Brands-Regular-400.otf", FontFamilies.FontAwesomeBrands);
});
Expand All @@ -78,13 +79,13 @@ public static MauiApp CreateMauiApp()
builder.ConfigureLifecycleEvents(events =>
{
#if WINDOWS10_0_17763_0_OR_GREATER
events.AddWindows(static windowLifeCycleBuilder =>
events.AddWindows(wndLifeCycleBuilder =>
{
windowLifeCycleBuilder.OnWindowCreated(window =>
wndLifeCycleBuilder.OnWindowCreated(window =>
{
window.SystemBackdrop = new MicaBackdrop { Kind = MicaKind.Base };
var titleBar = window.GetAppWindow()?.TitleBar ?? throw new InvalidOperationException("App Window Cannot be Null");
var titleBar = window.GetAppWindow()!.TitleBar;
titleBar.PreferredHeightOption = TitleBarHeightOption.Tall;
Expand All @@ -104,7 +105,7 @@ public static MauiApp CreateMauiApp()
});

builder.Services.AddHttpClient<ByteArrayToImageSourceConverterViewModel>()
.AddStandardResilienceHandler(static options => options.Retry = new MobileHttpRetryStrategyOptions());
.AddStandardResilienceHandler(options => options.Retry = new MobileHttpRetryStrategyOptions());

builder.Services.AddSingleton<PopupSizeConstants>();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>$(NetVersion)</TargetFramework>
Expand All @@ -18,7 +18,7 @@
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" PrivateAssets="All" />
<PackageReference Include="coverlet.collector" Version="6.0.2" PrivateAssets="All" />
<PackageReference Include="Microsoft.CodeAnalysis" Version="4.10.0" />
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiPackageVersion)" />
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiPackageVersion)"/>
</ItemGroup>

<ItemGroup>
Expand All @@ -30,11 +30,7 @@

<ItemGroup>
<ProjectReference Include="..\CommunityToolkit.Maui.Analyzers.CodeFixes\CommunityToolkit.Maui.Analyzers.CodeFixes.csproj" />
<ProjectReference Include="..\CommunityToolkit.Maui.Camera.Analyzers.CodeFixes\CommunityToolkit.Maui.Camera.Analyzers.CodeFixes.csproj" />
<ProjectReference Include="..\CommunityToolkit.Maui.Camera\CommunityToolkit.Maui.Camera.csproj" />
<ProjectReference Include="..\CommunityToolkit.Maui.MediaElement.Analyzers.CodeFixes\CommunityToolkit.Maui.MediaElement.Analyzers.CodeFixes.csproj" />
<ProjectReference Include="..\CommunityToolkit.Maui.MediaElement\CommunityToolkit.Maui.MediaElement.csproj" />
<ProjectReference Include="..\CommunityToolkit.Maui\CommunityToolkit.Maui.csproj" />
</ItemGroup>

</Project>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Testing;
using Xunit;
using static CommunityToolkit.Maui.Analyzers.UnitTests.CSharpAnalyzerVerifier<CommunityToolkit.Maui.Analyzers.UseCommunityToolkitInitializationAnalyzer>;
using Xunit;

namespace CommunityToolkit.Maui.Analyzers.UnitTests;

Expand All @@ -12,107 +9,4 @@ public void UseCommunityToolkitInitializationAnalyzerId()
{
Assert.Equal("MCT001", UseCommunityToolkitInitializationAnalyzer.DiagnosticId);
}

[Fact]
public async Task VerifyNoErrorsWhenUseMauiCommunityToolkit()
{
const string source = @"
namespace CommunityToolkit.Maui.Analyzers.UnitTests
{
using Microsoft.Maui.Controls.Hosting;
using Microsoft.Maui.Hosting;
using CommunityToolkit.Maui;
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder.UseMauiApp<Microsoft.Maui.Controls.Application>()
.UseMauiCommunityToolkit()
.ConfigureFonts(fonts =>
{
fonts.AddFont(""OpenSans-Regular.ttf"", ""OpenSansRegular"");
fonts.AddFont(""OpenSans-Semibold.ttf"", ""OpenSansSemibold"");
});
return builder.Build();
}
}
}";

await VerifyMauiToolkitAnalyzer(source);
}

[Fact]
public async Task VerifyNoErrorsWhenUseMauiCommunityToolkitHasAdditonalWhitespace()
{
const string source = @"
namespace CommunityToolkit.Maui.Analyzers.UnitTests
{
using Microsoft.Maui.Controls.Hosting;
using Microsoft.Maui.Hosting;
using CommunityToolkit.Maui;
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder ();
builder.UseMauiApp<Microsoft.Maui.Controls.Application> ()
.UseMauiCommunityToolkit ()
.ConfigureFonts (fonts =>
{
fonts.AddFont(""OpenSans-Regular.ttf"", ""OpenSansRegular"");
fonts.AddFont(""OpenSans-Semibold.ttf"", ""OpenSansSemibold"");
});
return builder.Build ();
}
}
}";

await VerifyMauiToolkitAnalyzer(source);
}

[Fact]
public async Task VerifyErrorsWhenMissingUseMauiCommunityToolkit()
{
const string source = @"
namespace CommunityToolkit.Maui.Analyzers.UnitTests
{
using Microsoft.Maui.Controls.Hosting;
using Microsoft.Maui.Hosting;
using CommunityToolkit.Maui;
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder.UseMauiApp<Microsoft.Maui.Controls.Application>()
.ConfigureFonts(fonts =>
{
fonts.AddFont(""OpenSans-Regular.ttf"", ""OpenSansRegular"");
fonts.AddFont(""OpenSans-Semibold.ttf"", ""OpenSansSemibold"");
});
return builder.Build();
}
}
}";

await VerifyMauiToolkitAnalyzer(source, Diagnostic().WithSpan(13, 4, 13, 61).WithSeverity(DiagnosticSeverity.Error));
}

static Task VerifyMauiToolkitAnalyzer(string source, params DiagnosticResult[] expected)
{
return VerifyAnalyzerAsync(
source,
[
typeof(Options), // CommunityToolkit.Maui
typeof(Core.Options), // CommunityToolkit.Maui.Core;
],
expected);
}
}
Loading

0 comments on commit 0f22e23

Please sign in to comment.