Skip to content

Commit

Permalink
Merge pull request #3056 from Saibamen/fix_csproj
Browse files Browse the repository at this point in the history
Fix csproj duplicates and warnings
  • Loading branch information
marticliment authored Dec 13, 2024
2 parents 90a1ac7 + 5d0b77a commit 6af0733
Show file tree
Hide file tree
Showing 96 changed files with 135 additions and 384 deletions.
12 changes: 5 additions & 7 deletions src/UniGetUI.Core.Classes.Tests/TaskRecyclerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,30 @@ public class TaskRecyclerTests
private int MySlowMethod1()
{
Thread.Sleep(1000);
return (new Random()).Next();
return new Random().Next();
}

class TestClass
private class TestClass
{
public TestClass() {}

public string SlowMethod2()
{
Thread.Sleep(1000);
return (new Random()).Next().ToString();
return new Random().Next().ToString();
}

public string SlowMethod3()
{
Thread.Sleep(1000);
return (new Random()).Next().ToString();
return new Random().Next().ToString();
}
}

private int MySlowMethod4(int argument)
{
Thread.Sleep(1000);
return (new Random()).Next() + (argument - argument);
return new Random().Next() + (argument - argument);
}

[Fact]
Expand Down Expand Up @@ -131,7 +131,6 @@ public void TestTaskRecycler_Class_String()
string result2 = task2.GetAwaiter().GetResult();
Assert.Equal(result1, result2);


var class1_copy = class1;

// The SAME method from the SAME instance, even when called
Expand All @@ -153,7 +152,6 @@ public void TestTaskRecycler_Class_String()
// Ensure the last call was not permanently cached
Assert.NotEqual(result1, result3);


// The SAME method from two DIFFERENT instances should NOT be
// cached, so the results should differ
var task7 = TaskRecycler<string>.RunOrAttachAsync(class1.SlowMethod3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
<RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers>
<RuntimeIdentifier>win-$(Platform)</RuntimeIdentifier>
<Platforms>x64</Platforms>
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
<WindowsSdkPackageVersion>10.0.26100.53</WindowsSdkPackageVersion>
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
<WindowsSdkPackageVersion>10.0.26100.53</WindowsSdkPackageVersion>
<SdkVersion>8.0.401</SdkVersion>
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
<PublishSelfContained>true</PublishSelfContained>
<Authors>Martí Climent and the contributors</Authors>
<PublisherName>Martí Climent</PublisherName>
<Nullable>enable</Nullable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<Configurations>Debug;Release</Configurations>
</PropertyGroup>
Expand Down
18 changes: 3 additions & 15 deletions src/UniGetUI.Core.Classes/TaskRecycler.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System.Collections.Concurrent;
using System.Diagnostics;
using UniGetUI.Core.Logging;
using WinRT.Interop;

namespace UniGetUI.Core.Classes;

Expand All @@ -21,12 +18,10 @@ namespace UniGetUI.Core.Classes;
*/
public static class TaskRecycler<ReturnT>
{
private static ConcurrentDictionary<int, Task<ReturnT>> _tasks = new();

private static readonly ConcurrentDictionary<int, Task<ReturnT>> _tasks = new();

// ---------------------------------------------------------------------------------------------------------------


/// Asynchronous entry point for 0 parameters
public static Task<ReturnT> RunOrAttachAsync(Func<ReturnT> method, int cacheTimeSecs = 0)
{
Expand Down Expand Up @@ -57,10 +52,8 @@ public static Task<ReturnT> RunOrAttachAsync<Param1T, Param2T, Param3T>(Func<Par
return _runTaskAndWait(new Task<ReturnT>(() => method(arg1, arg2, arg3)), hash, cacheTimeSecs);
}


// ---------------------------------------------------------------------------------------------------------------


/// Synchronous entry point for 0 parameters
public static ReturnT RunOrAttach(Func<ReturnT> method, int cacheTimeSecs = 0)
=> RunOrAttachAsync(method, cacheTimeSecs).GetAwaiter().GetResult();
Expand All @@ -79,10 +72,8 @@ public static ReturnT RunOrAttach<Param1T, Param2T, Param3T>(Func<Param1T, Param
Param2T arg2, Param3T arg3, int cacheTimeSecs = 0)
=> RunOrAttachAsync(method, arg1, arg2, arg3, cacheTimeSecs).GetAwaiter().GetResult();


// ---------------------------------------------------------------------------------------------------------------


/// <summary>
/// Instantly removes a function call from the cache, even if the associated task has not
/// finished yet. Any previous call will finish as expected. New calls won't attach to any
Expand All @@ -93,10 +84,8 @@ public static ReturnT RunOrAttach<Param1T, Param2T, Param3T>(Func<Param1T, Param
public static void RemoveFromCache(Func<ReturnT> method)
=> _removeFromCache(method.GetHashCode(), 0);


// ---------------------------------------------------------------------------------------------------------------


/// <summary>
/// Handles running the task if no such task was found on cache, and returning the cached task if it was found.
/// </summary>
Expand Down Expand Up @@ -134,15 +123,14 @@ private static async Task<ReturnT> _runTaskAndWait(Task<ReturnT> task, int hash,
/// </summary>
private static async void _removeFromCache(int hash, int cacheTimeSecsSecs)
{
if(cacheTimeSecsSecs > 0)
if (cacheTimeSecsSecs > 0)
await Task.Delay(cacheTimeSecsSecs * 1000);

_tasks.Remove(hash, out _);
}
}


public static class TaskRecyclerTelemetry
{
public static int DeduplicatedCalls = 0;
public static int DeduplicatedCalls;
}
8 changes: 2 additions & 6 deletions src/UniGetUI.Core.Classes/UniGetUI.Core.Classes.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers>
<RuntimeIdentifier>win-$(Platform)</RuntimeIdentifier>
<Platforms>x64</Platforms>
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
<WindowsSdkPackageVersion>10.0.26100.53</WindowsSdkPackageVersion>
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
<WindowsSdkPackageVersion>10.0.26100.53</WindowsSdkPackageVersion>
<SdkVersion>8.0.401</SdkVersion>
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
<PublishSelfContained>true</PublishSelfContained>
Expand All @@ -18,10 +18,6 @@
<Configurations>Debug;Release</Configurations>
</PropertyGroup>

<PropertyGroup>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\SharedAssemblyInfo.cs" Link="SharedAssemblyInfo.cs" />
</ItemGroup>
Expand Down
5 changes: 2 additions & 3 deletions src/UniGetUI.Core.Data.Tests/UniGetUI.Core.Data.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
<RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers>
<RuntimeIdentifier>win-$(Platform)</RuntimeIdentifier>
<Platforms>x64</Platforms>
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
<WindowsSdkPackageVersion>10.0.26100.53</WindowsSdkPackageVersion>
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
<WindowsSdkPackageVersion>10.0.26100.53</WindowsSdkPackageVersion>
<SdkVersion>8.0.401</SdkVersion>
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
<PublishSelfContained>true</PublishSelfContained>
<Authors>Martí Climent and the contributors</Authors>
<PublisherName>Martí Climent</PublisherName>
<Nullable>enable</Nullable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<Configurations>Debug;Release</Configurations>
</PropertyGroup>
Expand Down
3 changes: 1 addition & 2 deletions src/UniGetUI.Core.Data/CoreData.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Diagnostics;
using System.Diagnostics;
using System.Net;
using System.Text.Json;
using System.Text.Json.Serialization.Metadata;
Expand Down Expand Up @@ -160,7 +160,6 @@ public static string UniGetUI_DefaultBackupDirectory
/// </summary>
public const int NewShortcutsNotificationTag = 1236;


/// <summary>
/// A path pointing to the location where the app is installed
/// </summary>
Expand Down
8 changes: 2 additions & 6 deletions src/UniGetUI.Core.Data/UniGetUI.Core.Data.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers>
<RuntimeIdentifier>win-$(Platform)</RuntimeIdentifier>
<Platforms>x64</Platforms>
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
<WindowsSdkPackageVersion>10.0.26100.53</WindowsSdkPackageVersion>
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
<WindowsSdkPackageVersion>10.0.26100.53</WindowsSdkPackageVersion>
<SdkVersion>8.0.401</SdkVersion>
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
<PublishSelfContained>true</PublishSelfContained>
Expand All @@ -18,10 +18,6 @@
<Configurations>Debug;Release</Configurations>
</PropertyGroup>

<PropertyGroup>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\UniGetUI.Core.Logger\UniGetUI.Core.Logging.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
<RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers>
<RuntimeIdentifier>win-$(Platform)</RuntimeIdentifier>
<Platforms>x64</Platforms>
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
<WindowsSdkPackageVersion>10.0.26100.53</WindowsSdkPackageVersion>
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
<WindowsSdkPackageVersion>10.0.26100.53</WindowsSdkPackageVersion>
<SdkVersion>8.0.401</SdkVersion>
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
<PublishSelfContained>true</PublishSelfContained>
<Authors>Martí Climent and the contributors</Authors>
<PublisherName>Martí Climent</PublisherName>
<Nullable>enable</Nullable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<Configurations>Debug;Release</Configurations>
</PropertyGroup>
Expand Down
7 changes: 0 additions & 7 deletions src/UniGetUI.Core.IconStore/IconCacheEngine.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
using System.Collections.ObjectModel;
using System.Security.Cryptography;
using Windows.ApplicationModel;
using Windows.Graphics.Imaging;
using Windows.UI;
using PhotoSauce.MagicScaler;
using UniGetUI.Core.Classes;
using UniGetUI.Core.Data;
using UniGetUI.Core.Logging;
using UniGetUI.Core.Tools;

namespace UniGetUI.Core.IconEngine
{
Expand Down Expand Up @@ -230,7 +226,6 @@ cachedIconFile is not null &&
return null;
}


/// <summary>
/// The given image will be downsized to the expected size of an icon, if required
/// </summary>
Expand Down Expand Up @@ -278,10 +273,8 @@ private static void DownsizeImage(string cachedIconFile, string extension)
Logger.Error($"An error occurred while downsizing the image file {cachedIconFile}");
Logger.Error(ex);
}

}


/// <summary>
/// Checks whether a cached image is valid or not depending on the size (in bytes) of the image
/// </summary>
Expand Down
8 changes: 2 additions & 6 deletions src/UniGetUI.Core.IconStore/UniGetUI.Core.IconEngine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers>
<RuntimeIdentifier>win-$(Platform)</RuntimeIdentifier>
<Platforms>x64</Platforms>
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
<WindowsSdkPackageVersion>10.0.26100.53</WindowsSdkPackageVersion>
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
<WindowsSdkPackageVersion>10.0.26100.53</WindowsSdkPackageVersion>
<SdkVersion>8.0.401</SdkVersion>
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
<PublishSelfContained>true</PublishSelfContained>
Expand All @@ -18,10 +18,6 @@
<Configurations>Debug;Release</Configurations>
</PropertyGroup>

<PropertyGroup>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\UniGetUI.Core.Data\UniGetUI.Core.Data.csproj" />
<ProjectReference Include="..\UniGetUI.Core.Logger\UniGetUI.Core.Logging.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
<RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers>
<RuntimeIdentifier>win-$(Platform)</RuntimeIdentifier>
<Platforms>x64</Platforms>
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
<WindowsSdkPackageVersion>10.0.26100.53</WindowsSdkPackageVersion>
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
<WindowsSdkPackageVersion>10.0.26100.53</WindowsSdkPackageVersion>
<SdkVersion>8.0.401</SdkVersion>
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
<PublishSelfContained>true</PublishSelfContained>
<Authors>Martí Climent and the contributors</Authors>
<PublisherName>Martí Climent</PublisherName>
<Nullable>enable</Nullable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<Configurations>Debug;Release</Configurations>
</PropertyGroup>
Expand Down
1 change: 0 additions & 1 deletion src/UniGetUI.Core.LanguageEngine/LanguageEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ public Dictionary<string, string> LoadLanguageFile(string LangKey)

Dictionary<string, string> LangDict = BundledContents.ToDictionary(x => x.Key, x => x.Value?.ToString() ?? "");


string CachedLangFileToLoad = Path.Join(CoreData.UniGetUICacheDirectory_Lang, "lang_" + LangKey + ".json");

if (Settings.Get("DisableLangAutoUpdater"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers>
<RuntimeIdentifier>win-$(Platform)</RuntimeIdentifier>
<Platforms>x64</Platforms>
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
<WindowsSdkPackageVersion>10.0.26100.53</WindowsSdkPackageVersion>
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
<WindowsSdkPackageVersion>10.0.26100.53</WindowsSdkPackageVersion>
<SdkVersion>8.0.401</SdkVersion>
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
<PublishSelfContained>true</PublishSelfContained>
Expand All @@ -18,10 +18,6 @@
<Configurations>Debug;Release</Configurations>
</PropertyGroup>

<PropertyGroup>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MessageFormat" Version="7.1.2" />
</ItemGroup>
Expand Down
8 changes: 2 additions & 6 deletions src/UniGetUI.Core.Logger/UniGetUI.Core.Logging.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers>
<RuntimeIdentifier>win-$(Platform)</RuntimeIdentifier>
<Platforms>x64</Platforms>
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
<WindowsSdkPackageVersion>10.0.26100.53</WindowsSdkPackageVersion>
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
<WindowsSdkPackageVersion>10.0.26100.53</WindowsSdkPackageVersion>
<SdkVersion>8.0.401</SdkVersion>
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
<PublishSelfContained>true</PublishSelfContained>
Expand All @@ -18,10 +18,6 @@
<Configurations>Debug;Release</Configurations>
</PropertyGroup>

<PropertyGroup>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\SharedAssemblyInfo.cs" Link="SharedAssemblyInfo.cs" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
<RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers>
<RuntimeIdentifier>win-$(Platform)</RuntimeIdentifier>
<Platforms>x64</Platforms>
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
<WindowsSdkPackageVersion>10.0.26100.53</WindowsSdkPackageVersion>
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
<WindowsSdkPackageVersion>10.0.26100.53</WindowsSdkPackageVersion>
<SdkVersion>8.0.401</SdkVersion>
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
<PublishSelfContained>true</PublishSelfContained>
<Authors>Martí Climent and the contributors</Authors>
<PublisherName>Martí Climent</PublisherName>
<Nullable>enable</Nullable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<Configurations>Debug;Release</Configurations>
</PropertyGroup>
Expand Down
1 change: 0 additions & 1 deletion src/UniGetUI.Core.Settings.Tests/SettingsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ public void TestListSettings(string SettingName, string[] ls1Array, int[] ls2Arr
public void TestDictionarySettings(string SettingName, string[] keyArray, int[] intArray, string[] strArray)
{
Dictionary<string, SerializableTest?> test = [];
Dictionary<string, string> emptyDictionary = [];
Dictionary<string, SerializableTest?> nonEmptyDictionary = [];
nonEmptyDictionary["this should not be null; something's wrong"] = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
<RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers>
<RuntimeIdentifier>win-$(Platform)</RuntimeIdentifier>
<Platforms>x64</Platforms>
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
<WindowsSdkPackageVersion>10.0.26100.53</WindowsSdkPackageVersion>
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
<WindowsSdkPackageVersion>10.0.26100.53</WindowsSdkPackageVersion>
<SdkVersion>8.0.401</SdkVersion>
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
<PublishSelfContained>true</PublishSelfContained>
<Authors>Martí Climent and the contributors</Authors>
<PublisherName>Martí Climent</PublisherName>
<Nullable>enable</Nullable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<Configurations>Debug;Release</Configurations>
</PropertyGroup>
Expand Down
Loading

0 comments on commit 6af0733

Please sign in to comment.