Skip to content

Commit

Permalink
Prism.Avalonia.Tests - Disabled ImplicitUsing for code clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
DamianSuess committed Aug 31, 2024
1 parent 366f3fc commit d4b2a05
Show file tree
Hide file tree
Showing 38 changed files with 135 additions and 62 deletions.
1 change: 0 additions & 1 deletion PrismLibrary.sln
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,6 @@ Global
EndGlobalSection
GlobalSection(SharedMSBuildProjectFiles) = preSolution
tests\Avalonia\Prism.Container.Avalonia.Shared\Prism.Container.Avalonia.Shared.projitems*{03b9c775-9582-409f-b67f-6b8a0ce0c7af}*SharedItemsImports = 5
tests\Forms\Prism.DI.Forms.Tests\Prism.DI.Forms.Tests.projitems*{089c5e84-52c3-409e-924c-bd8f4833594b}*SharedItemsImports = 5
tests\Wpf\Prism.Container.Wpf.Shared\Prism.Container.Wpf.Shared.projitems*{367be810-5b34-4894-be47-1c8dcc67de81}*SharedItemsImports = 5
tests\Avalonia\Prism.Container.Avalonia.Shared\Prism.Container.Avalonia.Shared.projitems*{6fda7d49-df44-4e8f-a182-0eb73dd3c452}*SharedItemsImports = 13
tests\Wpf\Prism.Container.Wpf.Shared\Prism.Container.Wpf.Shared.projitems*{ba05687e-2317-4a65-805b-c596f52f7203}*SharedItemsImports = 5
Expand Down
2 changes: 1 addition & 1 deletion src/Avalonia/Prism.DryIoc.Avalonia/PrismBootstrapper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using DryIoc;
using Prism.Container.DryIoc;
using Prism.Ioc;
Expand Down
4 changes: 4 additions & 0 deletions tests/Avalonia/Prism.Avalonia.Tests/CompilerHelper.Desktop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@

namespace Prism.Avalonia.Tests
{
// Warning:
// CompileCode() method is not supported by .NET 6
// DotNet Runtime Issue 18768 - https://github.com/dotnet/runtime/issues/18768#issuecomment-265381303
// Workaround: Upgrade to RosylnCompiler (https://github.com/npolyak/RoslynAssembly)
public class CompilerHelper
{
private static string moduleTemplate =
Expand Down
3 changes: 2 additions & 1 deletion tests/Avalonia/Prism.Avalonia.Tests/ExceptionAssert.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Xunit;
using System;
using Xunit;

namespace Prism.Avalonia.Tests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Windows.Input;
using Avalonia.Controls;
using Prism.Interactivity;
Expand Down Expand Up @@ -165,5 +166,4 @@ public void Execute(object parameter)
ExecuteCalledWithParameter = parameter;
}
}

}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Windows.Input;
using Avalonia;
using Avalonia.Controls;
Expand Down Expand Up @@ -36,8 +37,8 @@ public class InvokeCommandAction : AvaloniaObject
/// </summary>
public bool AutoEnable
{
get { return (bool)this.GetValue(AutoEnableProperty); }
set { this.SetValue(AutoEnableProperty, value); }
get { return (bool)GetValue(AutoEnableProperty); }
set { SetValue(AutoEnableProperty, value); }
}

public ICommand? Command { get; set; }
Expand Down Expand Up @@ -365,7 +366,7 @@ internal class TestEventArgs : EventArgs
{
public TestEventArgs(string name)
{
this.Thing1 = new Thing1 { Thing2 = new Thing2 { Name = name } };
Thing1 = new Thing1 { Thing2 = new Thing2 { Name = name } };
}

public Thing1 Thing1 { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System;
using System.Threading;
using Prism.Modularity;

namespace Prism.Avalonia.Tests.Mocks
Expand Down Expand Up @@ -26,7 +28,7 @@ public void LoadModuleType(IModuleInfo moduleInfo)
{
Thread.Sleep(SleepTimeOut);

this.RaiseLoadModuleCompleted(new LoadModuleCompletedEventArgs(moduleInfo, CallbackArgumentError));
RaiseLoadModuleCompleted(new LoadModuleCompletedEventArgs(moduleInfo, CallbackArgumentError));
callbackEvent.Set();
});
retrieverThread.Start();
Expand All @@ -36,14 +38,14 @@ public void LoadModuleType(IModuleInfo moduleInfo)

private void RaiseLoadModuleProgressChanged(ModuleDownloadProgressChangedEventArgs e)
{
this.ModuleDownloadProgressChanged?.Invoke(this, e);
ModuleDownloadProgressChanged?.Invoke(this, e);
}

public event EventHandler<LoadModuleCompletedEventArgs> LoadModuleCompleted;

private void RaiseLoadModuleCompleted(LoadModuleCompletedEventArgs e)
{
this.LoadModuleCompleted?.Invoke(this, e);
LoadModuleCompleted?.Invoke(this, e);
}
}
}
5 changes: 3 additions & 2 deletions tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockCommand.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Windows.Input;

namespace Prism.Avalonia.Tests.Mocks
Expand Down Expand Up @@ -27,8 +28,8 @@ public bool CanExecute(object parameter)

public void RaiseCanExecuteChanged()
{
if (this.CanExecuteChanged != null)
this.CanExecuteChanged(this, EventArgs.Empty);
if (CanExecuteChanged != null)
CanExecuteChanged(this, EventArgs.Empty);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System;
using System.Collections.Generic;
using Prism.Ioc;

namespace Prism.Avalonia.Tests.Mocks
Expand Down Expand Up @@ -106,14 +108,14 @@ public IContainerRegistry RegisterSingleton(Type type, Func<IContainerProvider,
public object Resolve(Type type)
{
object resolvedInstance;
if (!this.ResolvedInstances.ContainsKey(type))
if (!ResolvedInstances.ContainsKey(type))
{
resolvedInstance = Activator.CreateInstance(type);
this.ResolvedInstances.Add(type, resolvedInstance);
ResolvedInstances.Add(type, resolvedInstance);
}
else
{
resolvedInstance = this.ResolvedInstances[type];
resolvedInstance = ResolvedInstances[type];
}

return resolvedInstance;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using Prism.Events;

namespace Prism.Avalonia.Tests.Mocks
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Avalonia;
using Avalonia;
using Prism.Navigation.Regions;
using Prism.Navigation.Regions.Behaviors;

namespace Prism.Avalonia.Tests.Mocks
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System;
using System.Collections.Generic;
using Prism.Modularity;

namespace Prism.Avalonia.Tests.Mocks
Expand All @@ -15,27 +17,27 @@ public bool CanLoadModuleType(IModuleInfo moduleInfo)

public void LoadModuleType(IModuleInfo moduleInfo)
{
this.LoadedModules.Add(moduleInfo);
this.RaiseLoadModuleCompleted(new LoadModuleCompletedEventArgs(moduleInfo, this.LoadCompletedError));
LoadedModules.Add(moduleInfo);
RaiseLoadModuleCompleted(new LoadModuleCompletedEventArgs(moduleInfo, LoadCompletedError));
}

public event EventHandler<ModuleDownloadProgressChangedEventArgs> ModuleDownloadProgressChanged;

public void RaiseLoadModuleProgressChanged(ModuleDownloadProgressChangedEventArgs e)
{
this.ModuleDownloadProgressChanged?.Invoke(this, e);
ModuleDownloadProgressChanged?.Invoke(this, e);
}

public event EventHandler<LoadModuleCompletedEventArgs> LoadModuleCompleted;

public void RaiseLoadModuleCompleted(ModuleInfo moduleInfo, Exception error)
{
this.RaiseLoadModuleCompleted(new LoadModuleCompletedEventArgs(moduleInfo, error));
RaiseLoadModuleCompleted(new LoadModuleCompletedEventArgs(moduleInfo, error));
}

public void RaiseLoadModuleCompleted(LoadModuleCompletedEventArgs e)
{
this.LoadModuleCompleted?.Invoke(this, e);
LoadModuleCompleted?.Invoke(this, e);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System.ComponentModel;
using System;
using System.ComponentModel;
using Prism.Navigation;
using Prism.Navigation.Regions;

namespace Prism.Avalonia.Tests.Mocks
{
Expand Down
7 changes: 5 additions & 2 deletions tests/Avalonia/Prism.Avalonia.Tests/Mocks/MockRegion.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System.ComponentModel;
using System;
using System.ComponentModel;
using Prism.Navigation;
using Prism.Navigation.Regions;

namespace Prism.Avalonia.Tests.Mocks
{
Expand Down Expand Up @@ -38,7 +41,7 @@ public INavigationParameters NavigationParameters

public IRegionManager Add(object view)
{
this.views.Add(view);
views.Add(view);
return null;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Avalonia;
using System.Collections.Generic;
using Avalonia;
using Prism.Navigation.Regions;

namespace Prism.Avalonia.Tests.Mocks
{
Expand All @@ -15,7 +17,7 @@ public IRegion Initialize(object regionTarget, string regionName)
RegionManager.GetObservableRegion(regionTarget as AvaloniaObject).Value = region;

// Fire update regions again. This also happens if a region is created and added to the regionmanager
if (this.Accessor != null)
if (Accessor != null)
Accessor.UpdateRegions();

return region;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
using System;
using Prism.Navigation.Regions;

namespace Prism.Avalonia.Tests.Mocks
{
public class MockRegionBehavior : IRegionBehavior
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Collections;
using System.Collections.Generic;
using Prism.Navigation.Regions;

namespace Prism.Avalonia.Tests.Mocks
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
using System.Collections;
using System;
using System.Collections;
using System.Collections.Generic;
using Prism.Ioc;
using Prism.Navigation;
using Prism.Navigation.Regions;

namespace Prism.Avalonia.Tests.Mocks
{
Expand Down Expand Up @@ -113,7 +118,7 @@ public IRegion this[string regionName]

void IRegionCollection.Add(IRegion region)
{
this.Add(region);
Add(region);
}

public bool Remove(string regionName)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using Avalonia;
using Prism.Navigation.Regions;

namespace Prism.Avalonia.Tests.Mocks
{
Expand All @@ -11,30 +13,26 @@ internal class MockRegionManagerAccessor : IRegionManagerAccessor

string IRegionManagerAccessor.GetRegionName(AvaloniaObject element)
{
return this.GetRegionName(element);
return GetRegionName(element);
}

IRegionManager IRegionManagerAccessor.GetRegionManager(AvaloniaObject element)
{
if (this.GetRegionManager != null)
{
return this.GetRegionManager(element);
}
if (GetRegionManager != null)
return GetRegionManager(element);

return null;
}

public void UpdateRegions()
{
if (this.UpdatingRegions != null)
{
this.UpdatingRegions(this, EventArgs.Empty);
}
if (UpdatingRegions != null)
UpdatingRegions(this, EventArgs.Empty);
}

public int GetSubscribersCount()
{
return this.UpdatingRegions != null ? this.UpdatingRegions.GetInvocationList().Length : 0;
return UpdatingRegions != null ? UpdatingRegions.GetInvocationList().Length : 0;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Prism.Avalonia.Tests.Mocks
using Prism.Navigation.Regions;

namespace Prism.Avalonia.Tests.Mocks
{
[ViewSortHint("01")]
internal class MockSortableView1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using Prism.Navigation.Regions;

namespace Prism.Avalonia.Tests.Mocks
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using Prism.Ioc;
using Prism.Modularity;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Prism.Modularity;
using System;
using Prism.Modularity;
using Xunit;

namespace Prism.Avalonia.Tests.Modularity
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<ImplicitUsings>false</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
Expand All @@ -28,7 +28,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\Prism.Avalonia\Prism.Avalonia.csproj" />
<ProjectReference Include="..\..\..\src\Avalonia\Prism.Avalonia\Prism.Avalonia.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand All @@ -12,6 +12,7 @@
using Prism.Dialogs;
using Xunit;
using Prism.Navigation.Regions.Behaviors;
using Prism.Navigation.Regions;

namespace Prism.Avalonia.Tests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Avalonia;
using Avalonia;
using Avalonia.Controls;
using Moq;
using Prism.Events;
Expand All @@ -7,6 +7,8 @@
using Prism.Dialogs;
using Xunit;
using Prism.Navigation.Regions.Behaviors;
using Prism.Navigation.Regions;
using System;

namespace Prism
{
Expand Down
Loading

0 comments on commit d4b2a05

Please sign in to comment.