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

feat: Add support for upgrade policy, upgrade to net8 #20

Merged
merged 6 commits into from
Oct 21, 2024
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
96 changes: 85 additions & 11 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
root = true

[*]
[*]
end_of_line = crlf
tab_width = 4
trim_trailing_whitespace = true
Expand Down Expand Up @@ -43,7 +41,7 @@ csharp_new_line_before_open_brace = all
csharp_new_line_between_query_expression_clauses = true

# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_prefer_braces
csharp_prefer_braces = true:suggestion
csharp_prefer_braces = true:silent

# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_prefer_simple_default_expression
csharp_prefer_simple_default_expression = true:suggestion
Expand Down Expand Up @@ -124,22 +122,22 @@ csharp_space_between_square_brackets = false
csharp_style_conditional_delegate_call = true:suggestion

# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_style_expression_bodied_accessors
csharp_style_expression_bodied_accessors = true:suggestion
csharp_style_expression_bodied_accessors = true:silent

# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_style_expression_bodied_constructors
csharp_style_expression_bodied_constructors = false:suggestion
csharp_style_expression_bodied_constructors = false:silent

# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_style_expression_bodied_indexers
csharp_style_expression_bodied_indexers = true:suggestion
csharp_style_expression_bodied_indexers = true:silent

# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_style_expression_bodied_methods
csharp_style_expression_bodied_methods = true:suggestion
csharp_style_expression_bodied_methods = false:silent

# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_style_expression_bodied_operators
csharp_style_expression_bodied_operators = true:suggestion
csharp_style_expression_bodied_operators = false:silent

# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_style_expression_bodied_properties
csharp_style_expression_bodied_properties = true:suggestion
csharp_style_expression_bodied_properties = true:silent

# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_style_inlined_variable_declaration
csharp_style_inlined_variable_declaration = true:suggestion
Expand Down Expand Up @@ -207,6 +205,22 @@ indent_style = tab

[{*.ts, *.json}]
indent_style = tab
csharp_using_directive_placement = outside_namespace:silent
csharp_prefer_simple_using_statement = true:suggestion
csharp_style_namespace_declarations = block_scoped:silent
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_style_prefer_primary_constructors = true:suggestion
csharp_prefer_system_threading_lock = true:suggestion
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent
csharp_style_prefer_null_check_over_type_check = true:suggestion
csharp_style_prefer_local_over_anonymous_function = true:suggestion
csharp_style_prefer_index_operator = true:suggestion
csharp_style_prefer_range_operator = true:suggestion
csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion
csharp_style_prefer_tuple_swap = true:suggestion
csharp_style_prefer_utf8_string_literals = true:suggestion

[*.csproj]
indent_style = tab
Expand All @@ -220,4 +234,64 @@ indent_style = space
indent_style = space

[*.md]
indent_style = space
indent_style = space
[*.{cs,vb}]
#### Naming styles ####

# Naming rules

dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i

dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case

dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case

# Symbol specifications

dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.interface.required_modifiers =

dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.types.required_modifiers =

dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.non_field_members.required_modifiers =

# Naming styles

dotnet_naming_style.begins_with_i.required_prefix = I
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.capitalization = pascal_case

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case
dotnet_style_operator_placement_when_wrapping = beginning_of_line
indent_size = 4
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
dotnet_style_prefer_auto_properties = true:silent
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
dotnet_style_prefer_conditional_expression_over_return = true:silent
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_compound_assignment = true:suggestion
dotnet_style_prefer_simplified_interpolation = true:suggestion
dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion
dotnet_style_namespace_match_folder = true:suggestion
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ What kind of change does this PR introduce?
Please check if your PR fulfills the following requirements:

- [ ] Tested code with current [supported SDKs](../README.md#supported)
- [ ] Docs have been added/updated which fit [documentation template](https://github.com/unoplatform/Uno/blob/master/doc/.feature-template.md). (for bug fixes / features)
- [ ] Docs have been added/updated which fit [documentation template](https://github.com/unoplatform/uno/blob/master/doc/.feature-template.md). (for bug fixes / features)
- [ ] [Unit Tests and/or UI Tests](doc/articles/working-with-the-samples-apps.md) for the changes have been added (for bug fixes / features) (if applicable)
- [ ] [Wasm UI Tests](doc/articles/working-with-the-samples-apps.md#running-the-webassembly-ui-tests-snapshots) are not showing unexpected any differences. Validate PR `Screenshots Compare Test Run` results.
- [ ] Contains **NO** breaking changes
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: '7.0.100'
dotnet-version: '8.0.100'

- name: Setup GitVersion
uses: gittools/actions/gitversion/setup@v0.9.9
Expand All @@ -62,7 +62,7 @@ jobs:
dotnet test

- name: Upload Artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: NuGet
path: .\artifacts
Expand Down Expand Up @@ -124,7 +124,7 @@ jobs:
run: tfx extension create --json --no-color --output-path .\artifacts\Build.Tasks.${{ steps.gitversion.outputs.MajorMinorPatch }}.vsix --override "{""version"":""${{ steps.gitversion.outputs.MajorMinorPatch }}""}"

- name: Upload Artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: extensions
path: extensions/azuredevops/artifacts
Expand Down Expand Up @@ -161,7 +161,7 @@ jobs:
build\SignClient sign -i artifacts\*.nupkg -c build\SignClient.json -r "${{ secrets.UNO_PLATFORM_CODESIGN_USERNAME }}" -s "${{ secrets.UNO_PLATFORM_CODESIGN_SECRET }}" -n "Uno Nuget Tools" -d "Uno Nuget Tools" -u "https://github.com/unoplatform/nuget.updater"

- name: Upload Signed Artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: NuGet-Signed
path: .\artifacts
Expand Down
12 changes: 12 additions & 0 deletions doc/nuget-updater.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@ versions.json example:
{
"PackageId": "Uno.Wasm.Bootstrap",
"UpdatedVersion": "(,1.2.0-dev.18]" -> Resolves 1.2.0-dev.18 (-v=dev + -v=stable), 1.0.10 (-v=stable)
},
{
"PackageId": "Uno.WinUI",
"UpgradePolicy": "Minor" -> Only upgrades when a minor version of the same major is available
},
{
"PackageId": "Uno.Core",
"UpgradePolicy": "Major" -> Always upgrades
},
{
"PackageId": "Uno.Core.Extensions",
"UpgradePolicy": "Patch" -> Only upgrades when a patch version of the same major,minor is available
}
]
```
Expand Down
9 changes: 8 additions & 1 deletion src/NvGet.Tests/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,16 @@ public static class Constants
public static readonly Dictionary<string, string[]> TestPackages = new Dictionary<string, string[]>
{
{"unoplatform.NuGet.Updater", new[] { "1.0-beta.1" } },
{"Uno.UI", new[] { "2.1.39", "2.2.0", "2.3.0-dev.44", "2.3.0-dev.48", "2.3.0-dev.58", "5.0.0-feature.5x.88" } },
{"Uno.UI", new[] { "2.1.39", "2.2.0", "2.3.0-dev.44", "2.3.0-dev.48", "2.3.0-dev.58", "3.0.0-dev.2", "5.0.0-feature.5x.88" } },
};

public static readonly TestPackageFeed TestFeed = new TestPackageFeed(TestFeedUri, TestPackages);

public static readonly Dictionary<string, string[]> TestPackages2 = new Dictionary<string, string[]>
{
{"Uno.UI", new[] { "2.1.39", "2.2.0", "2.2.1", "2.3.0" } },
};

public static readonly TestPackageFeed TestFeed2 = new TestPackageFeed(TestFeedUri, TestPackages2);
}
}
23 changes: 17 additions & 6 deletions src/NvGet.Tests/NvGet.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
<PackageReference Include="Mono.Options" Version="6.6.0.161" />
<None Include="..\..\.editorconfig" Link=".editorconfig" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="MSTest.TestAdapter" Version="3.6.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.6.1" />
<PackageReference Include="Mono.Options" Version="6.12.0.148" />
</ItemGroup>

<ItemGroup>
Expand All @@ -18,10 +22,17 @@

<ItemGroup>
<None Update="Resources\*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
<PackageReference Update="StyleCop.Analyzers" Version="1.2.0-beta.556">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<Import Project="..\NvGet.Tools.Shared\NvGet.Tools.Shared.projitems" Label="Shared" />

</Project>
4 changes: 3 additions & 1 deletion src/NvGet.Tests/Resources/version_overrides.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[
{ "PackageId": "Newtonsoft.Json", "UpdatedVersion": "12.0.1" },
{ "PackageId": "Microsoft.Extensions.Logging", "UpdatedVersion": "3.1.2" }
{ "PackageId": "Microsoft.Extensions.Logging", "UpdatedVersion": "3.1.2" },
{ "PackageId": "Uno.UI", "UpgradePolicy": "Minor", "UpdatedVersion": "3.1.2" },
{ "PackageId": "Uno.WinUI", "UpgradePolicy": "Patch", "UpdatedVersion": "3.1.2" }
]
1 change: 0 additions & 1 deletion src/NvGet.Tests/Tools/ConsoleArgsParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ public void Given_UpdaterParametersArgument_ContextCollectionPropertyIsSet(Expre
}

[TestMethod]
[DeploymentItem(PinnedVersionJsonPath)]
public void Given_UpdaterParametersArgument_ContextTargetVersionIsSet()
{
var arguments = new[] { $"--versionOverrides={PinnedVersionJsonPath}" };
Expand Down
2 changes: 1 addition & 1 deletion src/NvGet.Tests/Tools/Updater/PackageReferenceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public async Task GivenManualUpdates_AndVersionNotInFeed_ManualVersionIsFound()
Feeds = { Constants.TestFeed },
VersionOverrides =
{
{ reference.Identity.Id, (true, new VersionRange(reference.Identity.Version, true, reference.Identity.Version, true)) },
{ reference.Identity.Id, (true, UpgradePolicy.Major, new VersionRange(reference.Identity.Version, true, reference.Identity.Version, true)) },
},
};

Expand Down
54 changes: 50 additions & 4 deletions src/NvGet.Tests/Tools/Updater/UpdaterParametersTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public async Task GivenSinglePartTag_NoOverride()

var version = await parameters.GetLatestVersion(CancellationToken.None, reference);

Assert.AreEqual(NuGetVersion.Parse("2.3.0-dev.58"), version.Version);
Assert.AreEqual(NuGetVersion.Parse("3.0.0-dev.2"), version.Version);
}

[TestMethod]
Expand All @@ -70,21 +70,67 @@ public async Task GivenRangeOverrides_CorrectVersionsAreResolved()
Feeds = { Constants.TestFeed },
VersionOverrides =
{
{ reference.Identity.Id, (false, VersionRange.Parse("(,2.3.0-dev.48]")) },
{ reference.Identity.Id, (false, UpgradePolicy.Major, VersionRange.Parse("(,2.3.0-dev.48]")) },
},
};

var version = await parameters.GetLatestVersion(CancellationToken.None, reference);

Assert.AreEqual(NuGetVersion.Parse("2.3.0-dev.48"), version.Version);

parameters.VersionOverrides["Uno.UI"] = (false, VersionRange.Parse("(,2.3.0-dev.48)"));
parameters.VersionOverrides["Uno.UI"] = (false, UpgradePolicy.Major, VersionRange.Parse("(,2.3.0-dev.48)"));

version = await parameters.GetLatestVersion(CancellationToken.None, reference);

Assert.AreEqual(NuGetVersion.Parse("2.3.0-dev.44"), version.Version);
}

[TestMethod]
public async Task GivenRangeOverrides_KeepMinor()
{
var reference = new PackageReference("Uno.UI", "2.1.39");

var parameters = new UpdaterParameters
{
TargetVersions = { "dev", "stable" },
Feeds = { Constants.TestFeed },
VersionOverrides =
{
{ reference.Identity.Id, (false, UpgradePolicy.Minor, VersionRange.Parse("0.0.0.0")) },
},
};

var version = await parameters.GetLatestVersion(CancellationToken.None, reference);

Assert.AreEqual(NuGetVersion.Parse("2.3.0-dev.58"), version.Version);

parameters.VersionOverrides["Uno.UI"] = (false, UpgradePolicy.Minor, VersionRange.Parse("(,2.3.0-dev.48)"));

version = await parameters.GetLatestVersion(CancellationToken.None, reference);

Assert.AreEqual(NuGetVersion.Parse("2.3.0-dev.44"), version.Version);
}

[TestMethod]
public async Task GivenRangeOverrides_KeepPatch()
{
var reference = new PackageReference("Uno.UI", "2.2.0");

var parameters = new UpdaterParameters
{
TargetVersions = { "dev", "stable" },
Feeds = { Constants.TestFeed2 },
VersionOverrides =
{
{ reference.Identity.Id, (false, UpgradePolicy.Patch, VersionRange.Parse("0.0.0.0")) },
},
};

var version = await parameters.GetLatestVersion(CancellationToken.None, reference);

Assert.AreEqual(NuGetVersion.Parse("2.2.1"), version.Version);
}

[TestMethod]
public async Task GivenRangeOverrides_CorrectVersionsAreResolved_AndTargetVersionIsHonored()
{
Expand All @@ -96,7 +142,7 @@ public async Task GivenRangeOverrides_CorrectVersionsAreResolved_AndTargetVersio
Feeds = { Constants.TestFeed },
VersionOverrides =
{
{ reference.Identity.Id, (false, VersionRange.Parse("(,2.3.0-dev.48]")) },
{ reference.Identity.Id, (false, UpgradePolicy.Major, VersionRange.Parse("(,2.3.0-dev.48]")) },
},
};

Expand Down
3 changes: 1 addition & 2 deletions src/NvGet.Tools.Downloader/NvGet.Tools.Downloader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackAsTool>true</PackAsTool>
<ToolCommandName>nugetdownloader</ToolCommandName>
<LangVersion>latest</LangVersion>
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
</PropertyGroup>

Expand Down
Loading
Loading