Skip to content

Commit

Permalink
Fix styling.
Browse files Browse the repository at this point in the history
  • Loading branch information
CXuesong committed Aug 30, 2024
1 parent 75d999f commit 5ae36c3
Show file tree
Hide file tree
Showing 69 changed files with 134 additions and 135 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
</ItemGroup>

Expand Down
8 changes: 4 additions & 4 deletions Samples/ConsoleTestApplication1/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static async Task HelloWikiWorld()
// Create a MediaWiki Site instance with the URL of API endpoint.
var site = new WikiSite(wikiClient, "https://test2.wikipedia.org/w/api.php")
{
Logger = loggerFactory.CreateLogger<WikiSite>()
Logger = loggerFactory.CreateLogger<WikiSite>(),
};
// Waits for the WikiSite to initialize
await site.Initialization;
Expand Down Expand Up @@ -114,7 +114,7 @@ static async Task HelloWikiGenerators()
var allpages = new AllPagesGenerator(site)
{
StartTitle = "Wiki",
RedirectsFilter = PropertyFilterOption.WithoutProperty
RedirectsFilter = PropertyFilterOption.WithoutProperty,
};
// Take the first 1000 results
var pages = await allpages.EnumPagesAsync().Take(1000).ToListAsync();
Expand All @@ -126,7 +126,7 @@ static async Task HelloWikiGenerators()
Console.WriteLine("Cats");
var catmembers = new CategoryMembersGenerator(site, "Category:Cats")
{
MemberTypes = CategoryMemberTypes.Subcategory
MemberTypes = CategoryMemberTypes.Subcategory,
};
pages = await catmembers.EnumPagesAsync().Take(10).ToListAsync();
foreach (var p in pages)
Expand Down Expand Up @@ -175,7 +175,7 @@ static async Task InteractivePatrol()
{
TypeFilters = RecentChangesFilterTypes.Create,
PaginationSize = 5,
PatrolledFilter = PropertyFilterOption.WithoutProperty
PatrolledFilter = PropertyFilterOption.WithoutProperty,
};
// List the first unpatrolled result.
var rc = await rcg.EnumItemsAsync().FirstOrDefaultAsync();
Expand Down
4 changes: 2 additions & 2 deletions Samples/LinqToCargo/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
using var client = new WikiClient
{
ClientUserAgent = "WikiClientLibrary.Samples.CargoLinq/1.0",
Logger = loggerFactory.CreateLogger<WikiClient>()
Logger = loggerFactory.CreateLogger<WikiClient>(),
};
var site = new WikiSite(client, "https://lol.fandom.com/api.php");
site.Logger = loggerFactory.CreateLogger<WikiSite>();
Expand All @@ -41,7 +41,7 @@
x.Direction,
Roles = string.Join(';', x.Roles),
Tags = string.Join(';', x.Tags),
Tournaments = string.Join(';', x.Tournaments)
Tournaments = string.Join(';', x.Tournaments),
});
var counter = 0;
await foreach (var item in query)
Expand Down
2 changes: 1 addition & 1 deletion UnitTestProject1/Attributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public enum CISkippedReason
Unknown = 0,
Unstable,
Deprecated,
AgentBlocked
AgentBlocked,

}

Expand Down
4 changes: 2 additions & 2 deletions UnitTestProject1/Fixtures/WikiSiteProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ public async Task<WikiSite> CreateWikiSiteAsync(IWikiClient wikiClient, string u
{
var uri = new Uri(url, UriKind.Absolute);
var rootUrl = new Uri(uri, ".").ToString();
var options = new WikiaSiteOptions(rootUrl) { AccountAssertion = AccountAssertionBehavior.AssertAll, };
var options = new WikiaSiteOptions(rootUrl) { AccountAssertion = AccountAssertionBehavior.AssertAll };
site = new WikiaSite(wikiClient, options) { Logger = loggerFactory.CreateLogger<WikiaSite>() };
}
else
{
var options = new SiteOptions(url) { AccountAssertion = AccountAssertionBehavior.AssertAll, };
var options = new SiteOptions(url) { AccountAssertion = AccountAssertionBehavior.AssertAll };
site = new WikiSite(wikiClient, options) { Logger = loggerFactory.CreateLogger<WikiSite>() };
}
await site.Initialization;
Expand Down
10 changes: 6 additions & 4 deletions UnitTestProject1/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

using System.Diagnostics.CodeAnalysis;

[assembly:
SuppressMessage("Style", "VSTHRD200:Use Async suffix for async methods", Justification = "test methods",
Scope = "namespaceanddescendants", Target = "~N:WikiClientLibrary.Tests.UnitTestProject1.Tests")
]
[assembly: SuppressMessage("Style", "VSTHRD003:Avoid awaiting or returning a Task representing work that was not started within your context as that can lead to deadlocks.",
Justification = "There is no STA thread so what are you talking about? ",
Scope = "namespaceanddescendants", Target = "~N:WikiClientLibrary.Tests.UnitTestProject1.Tests")]
[assembly: SuppressMessage("Style", "VSTHRD200:Use Async suffix for async methods",
Justification = "test methods",
Scope = "namespaceanddescendants", Target = "~N:WikiClientLibrary.Tests.UnitTestProject1.Tests")]
8 changes: 4 additions & 4 deletions UnitTestProject1/Tests/GeneratorTests2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ internal async Task WikiaLogEventsListLoopTest()
// Introduce some last-resorts.
generator.CompatibilityOptions = new WikiListCompatibilityOptions
{
ContinuationLoopBehaviors = WikiListContinuationLoopBehaviors.FetchMore
ContinuationLoopBehaviors = WikiListContinuationLoopBehaviors.FetchMore,
};
var logs2 = await generator.EnumItemsAsync().Take(100).ToListAsync();
Output.WriteLine("logs = {0}", string.Join(",", logs.Select(l => l.LogId)));
Expand Down Expand Up @@ -107,7 +107,7 @@ public async Task RecentChangesGeneratorTest3(string siteName)
var site = await WikiSiteFromNameAsync(siteName);
var generator = new RecentChangesGenerator(site)
{
LastRevisionsOnly = true, TypeFilters = RecentChangesFilterTypes.Edit, PaginationSize = 500
LastRevisionsOnly = true, TypeFilters = RecentChangesFilterTypes.Edit, PaginationSize = 500,
};
var pages = await generator.EnumPagesAsync().Take(2000).ToListAsync();
TracePages(pages);
Expand Down Expand Up @@ -146,7 +146,7 @@ public async Task WpTest2PatrolTest1()
var site = await WpTest2SiteAsync;
var generator = new RecentChangesGenerator(site)
{
LastRevisionsOnly = true, PatrolledFilter = PropertyFilterOption.WithoutProperty
LastRevisionsOnly = true, PatrolledFilter = PropertyFilterOption.WithoutProperty,
};
var rc = await generator.EnumItemsAsync().Take(2).ToListAsync();
Output.WriteLine("Changes to patrol:");
Expand All @@ -170,7 +170,7 @@ public async Task LogEventsListTest1(string siteName)
LogAction = LogActions.MoveOverRedirect,
TimeAscending = false,
// Local time should be converted to UTC in Utility.ToWikiQueryValue
StartTime = DateTime.Now - TimeSpan.FromDays(7)
StartTime = DateTime.Now - TimeSpan.FromDays(7),
};
var logs = await generator.EnumItemsAsync().Take(200).ToListAsync();
ShallowTrace(logs, 1);
Expand Down
4 changes: 2 additions & 2 deletions UnitTestProject1/Tests/InfrastructureTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public void JsonDataTimeTests()
[Fact]
public void WbMonolingualTextCollectionTest()
{
var collection = new WbMonolingualTextCollection(new[] { new WbMonolingualText("en", "Wikipedia"), })
var collection = new WbMonolingualTextCollection(new[] { new WbMonolingualText("en", "Wikipedia") })
{
{ "zh-hans", "维基百科" }, { "zh-Hant", "維基百科" }, new WbMonolingualText("ja", "ウィキペディア")
{ "zh-hans", "维基百科" }, { "zh-Hant", "維基百科" }, new WbMonolingualText("ja", "ウィキペディア"),
};
collection["ru"] = "Википедия";
Assert.Equal(5, collection.Count);
Expand Down
6 changes: 3 additions & 3 deletions UnitTestProject1/Tests/PageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public async Task WpLzhPageExtractTest()
var page = new WikiPage(site, "莎拉伯恩哈特");
await page.RefreshAsync(new WikiPageQueryProvider
{
Properties = { new ExtractsPropertyProvider { AsPlainText = true, IntroductionOnly = true, MaxSentences = 1 } }
Properties = { new ExtractsPropertyProvider { AsPlainText = true, IntroductionOnly = true, MaxSentences = 1 } },
});
ShallowTrace(page);
Assert.Equal("莎拉·伯恩哈特,一八四四年生,法國巴黎人也。", page.GetPropertyGroup<ExtractsPropertyGroup>()!.Extract);
Expand All @@ -157,7 +157,7 @@ public async Task WpLzhPageImagesTest()
var page = new WikiPage(site, "挪威");
await page.RefreshAsync(new WikiPageQueryProvider
{
Properties = { new PageImagesPropertyProvider { QueryOriginalImage = true, ThumbnailSize = 100 } }
Properties = { new PageImagesPropertyProvider { QueryOriginalImage = true, ThumbnailSize = 100 } },
});
var group = page.GetPropertyGroup<PageImagesPropertyGroup>();
ShallowTrace(group);
Expand All @@ -176,7 +176,7 @@ public async Task WpLzhPageLanguageLinksTest()
var page = new WikiPage(site, "莎拉伯恩哈特");
await page.RefreshAsync(new WikiPageQueryProvider
{
Properties = { new LanguageLinksPropertyProvider(LanguageLinkProperties.Autonym) }
Properties = { new LanguageLinksPropertyProvider(LanguageLinkProperties.Autonym) },
});
var langLinks = page.GetPropertyGroup<LanguageLinksPropertyGroup>()?.LanguageLinks;
ShallowTrace(langLinks);
Expand Down
4 changes: 2 additions & 2 deletions UnitTestProject1/Tests/RenderingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public async Task WpLzhPageParsingTest1()

Assert.Equal("一九五二年", result.Title);
Assert.Matches(@"<span class=""[\w-]+"">一九五二年</span>", result.DisplayTitle);
Assert.True(result.LanguageLinks.First(l => l.Language == "en").Title == "1952");
Assert.True(result.LanguageLinks.First(l => l.Language == "zh").Title == "1952年");
Assert.Equal("1952", result.LanguageLinks.First(l => l.Language == "en").Title);
Assert.Equal("1952年", result.LanguageLinks.First(l => l.Language == "zh").Title);
Assert.Contains(">公元<b>一九五二年</b>於諸曆</", result.Content);

WriteOutput("Sections");
Expand Down
2 changes: 1 addition & 1 deletion UnitTestProject1/Tests/SiteTokenTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public async Task BadTokenTest(string endpointUrl, string sandboxPageTitle)
try
{
// This should cause token cache invalidation.
await page.EditAsync(new WikiPageEditOptions { Content = page.Content!, Summary = "Make an empty update.", Minor = true, });
await page.EditAsync(new WikiPageEditOptions { Content = page.Content!, Summary = "Make an empty update.", Minor = true });
}
catch (OperationFailedException ex) when (ex.ErrorCode == "globalblocking-blockedtext-range")
{
Expand Down
2 changes: 1 addition & 1 deletion UnitTestProject1/Tests/WikiaApiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public async Task FetchRelatedPagesTest()
public async Task SearchListTest()
{
var site = await WikiaTestSiteAsync;
var list = new LocalWikiSearchList(site, "test keyword") { PaginationSize = 10, };
var list = new LocalWikiSearchList(site, "test keyword") { PaginationSize = 10 };
var results = await list.EnumItemsAsync().Take(30).ToListAsync();
ShallowTrace(results);
Assert.NotEmpty(results);
Expand Down
2 changes: 1 addition & 1 deletion UnitTestProject1/Tests/WikibaseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ await entity.RefreshAsync(EntityQueryOptions.FetchLabels
ShallowTrace(entity);

// Remove a claim (claim2 contains the claim id now).
changelist = new[] { new EntityEditEntry(nameof(Entity.Claims), claim2, EntityEditEntryState.Removed), };
changelist = new[] { new EntityEditEntry(nameof(Entity.Claims), claim2, EntityEditEntryState.Removed) };
await entity.EditAsync(changelist, "Edit test entity. Remove a claim.", options);
if ((options & EntityEditOptions.Bulk) != EntityEditOptions.Bulk)
await entity.RefreshAsync(EntityQueryOptions.FetchClaims);
Expand Down
8 changes: 4 additions & 4 deletions UnitTestProject1/UnitTestProject1.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Nerdbank.Streams" Version="2.11.74" />
<PackageReference Include="xunit" Version="2.8.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.0">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
<PackageReference Include="Nerdbank.Streams" Version="2.11.79" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected override Expression VisitMethodCall(MethodCallExpression node)
node.Type),
nameof(CargoFunctions.DateDiff) => new CargoFunctionExpression("DATEDIFF", typeof(int), Visit(node.Arguments[0]),
Visit(node.Arguments[1])),
_ => throw new NotImplementedException($"CargoFunction call is not implemented: {node.Method}.")
_ => throw new NotImplementedException($"CargoFunction call is not implemented: {node.Method}."),
};
}
return base.VisitMethodCall(node);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ internal class CargoQueryClauseBuilder : ExpressionVisitor
{ ExpressionType.Divide, " / " },
{ ExpressionType.Modulo, " % " },
{ ExpressionType.And, " & " },
{ ExpressionType.Or, " | " }
{ ExpressionType.Or, " | " },
};

public string BuildClause(Expression expr)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected override Expression VisitMethodCall(MethodCallExpression node)
UnwindLambdaExpression(Visit(node.Arguments[1])), true),
nameof(Queryable.ThenByDescending) => ProcessThenOrderByCall((CargoQueryExpression)Visit(node.Arguments[0]),
UnwindLambdaExpression(Visit(node.Arguments[1])), true),
_ => throw new NotSupportedException($"Queryable method call is not supported: {node.Method}.")
_ => throw new NotSupportedException($"Queryable method call is not supported: {node.Method}."),
};
}
return node;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public override int GetHashCode(Expression? obj)
BinaryExpression be => HashCode.Combine(be.NodeType, GetHashCode(be.Left), GetHashCode(be.Right)),
MemberExpression me => HashCode.Combine(me.NodeType, GetHashCode(me.Expression), me.Member, me.Type),
null => 0,
_ => obj.GetHashCode()
_ => obj.GetHashCode(),
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static LambdaExpression UnwindLambdaExpression(Expression lambdaOrQuote)
LambdaExpression lambda => lambda,
UnaryExpression unary when unary.Operand is LambdaExpression lambda1 && unary.NodeType == ExpressionType.Quote => lambda1,
_ => throw new ArgumentException($"Provided expression cannot be unwound to LambdaExpression: {lambdaOrQuote}.",
nameof(lambdaOrQuote))
nameof(lambdaOrQuote)),
};
}

Expand Down
6 changes: 3 additions & 3 deletions WikiClientLibrary.Flow/Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static string ToString(ModerationAction value)
ModerationAction.Unhide => "unhide",
ModerationAction.Undelete => "undelete",
ModerationAction.Unsuppress => "unsuppress",
_ => throw new ArgumentOutOfRangeException(nameof(value), value, null)
_ => throw new ArgumentOutOfRangeException(nameof(value), value, null),
};
}

Expand All @@ -74,7 +74,7 @@ public static string ToString(LockAction value)
{
LockAction.Lock => "lock",
LockAction.Unlock => "unlock",
_ => throw new ArgumentOutOfRangeException(nameof(value), value, null)
_ => throw new ArgumentOutOfRangeException(nameof(value), value, null),
};
}

Expand All @@ -85,7 +85,7 @@ public static ModerationState ParseModerationState(string value)
"delete" => ModerationState.Deleted,
"hide" => ModerationState.Hidden,
"suppress" => ModerationState.Suppressed,
_ => ModerationState.Unknown
_ => ModerationState.Unknown,
};
}

Expand Down
4 changes: 2 additions & 2 deletions WikiClientLibrary.Flow/FlowRequestHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static async Task<Post> ReplyAsync(WikiSite site, string pageTitle, strin
token = WikiSiteToken.Edit,
repreplyTo = workflowId,
repformat = "wikitext",
repcontent = content
repcontent = content,
}), cancellationToken);
}
var jtopic = jresult["flow"]["reply"]["committed"]?["topic"];
Expand Down Expand Up @@ -56,7 +56,7 @@ public static async Task<Topic> NewTopicAsync(WikiSite site, string pageTitle,
token = WikiSiteToken.Edit,
nttopic = topicTitle,
ntformat = "wikitext",
ntcontent = topicContent
ntcontent = topicContent,
}), cancellationToken);
}
var jtopiclist = jresult["flow"]["new-topic"]?["committed"]?["topiclist"];
Expand Down
2 changes: 1 addition & 1 deletion WikiClientLibrary.Wikia/Discussions/Post.cs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ public enum PostQueryOptions
/// <para>If you are fetching for only 1 comment at a time, the exact authoring information
/// will be fetching regardless of this flag.</para>
/// </remarks>
ExactAuthoringInformation
ExactAuthoringInformation,

}

Expand Down
4 changes: 2 additions & 2 deletions WikiClientLibrary.Wikia/RequestHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ IEnumerable<Post> PostsAndDescendants(IEnumerable<Post> posts)
controller = "ArticleComments",
method = "Content",
articleId = board.Page.Id,
page = page
page = page,
}), WikiaJsonResponseParser.Default, cancellationToken);
// Build comment structure.
var jcomments = jroot["commentListRaw"]?.AsObject();
Expand All @@ -88,7 +88,7 @@ IEnumerable<Post> PostsAndDescendants(IEnumerable<Post> posts)

private static readonly WikiPageQueryProvider postLastRevisionQueryProvider = new WikiPageQueryProvider
{
Properties = { new RevisionsPropertyProvider { FetchContent = true } }, ResolveRedirects = false
Properties = { new RevisionsPropertyProvider { FetchContent = true } }, ResolveRedirects = false,
};

private static readonly RevisionsPropertyProvider postRevisionWithContentProvider =
Expand Down
2 changes: 1 addition & 1 deletion WikiClientLibrary.Wikia/Sites/WikiaSite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public async Task<T> InvokeWikiaAjaxAsync<T>(WikiRequestMessage request,
{
var fields = new List<KeyValuePair<string, object>>(queryRequest.Fields.Count + 1)
{
new KeyValuePair<string, object>("action", "ajax")
new KeyValuePair<string, object>("action", "ajax"),
};
fields.AddRange(queryRequest.Fields);
localRequest = new WikiaQueryRequestMessage(request.Id, fields, queryRequest.UseHttpPost);
Expand Down
2 changes: 1 addition & 1 deletion WikiClientLibrary.Wikia/Utility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal static class Utility

public static readonly JsonSerializerOptions WikiaApiJsonSerializerOptions = new()
{
PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower, Converters = { new WikiReadOnlyDictionaryConverterFactory(), }
PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower, Converters = { new WikiReadOnlyDictionaryConverterFactory() },
};

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions WikiClientLibrary.Wikia/WikiaApi/LocalWikiSearchList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ private string SerializeRank(SearchRankingType value)
SearchRankingType.MostViewed => "most-viewed",
SearchRankingType.Freshest => "freshest",
SearchRankingType.Stalest => "stalest",
_ => throw new ArgumentOutOfRangeException(nameof(value), value, null)
_ => throw new ArgumentOutOfRangeException(nameof(value), value, null),
};
}

Expand Down Expand Up @@ -161,6 +161,6 @@ public enum SearchRankingType
Stable,
MostViewed,
Freshest,
Stalest
Stalest,

}
Loading

0 comments on commit 5ae36c3

Please sign in to comment.