Skip to content

Commit

Permalink
* fix all errors of `CS0104: 'User' is an ambiguous reference between…
Browse files Browse the repository at this point in the history
… 'tbm.Crawler.Db.User' and 'TbClient.User'` @ crawler

* update NuGet packages
@ c#
  • Loading branch information
n0099 committed Feb 13, 2024
1 parent 32ad36f commit e9eaff0
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 18 deletions.
6 changes: 3 additions & 3 deletions c#/crawler/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"net7.0": {
"AngleSharp": {
"type": "Direct",
"requested": "[1.0.7, )",
"resolved": "1.0.7",
"contentHash": "jZg7lDcrXRiIC8VBluuGKOCMR9mc4CIRX5vpQJ8fcgafs6T6plOzKHhAn3lJEwXorrltd9p1WtRxxhFpRBACbg==",
"requested": "[1.1.0, )",
"resolved": "1.1.0",
"contentHash": "3baCuPkx2Wrpjr2b67wJAf9fCbYSbEVcdCh88S66HLdfHa2b1Mk1FsGpcH76uHLf3MPxopWngT1imHPEmDimAg==",
"dependencies": {
"System.Text.Encoding.CodePages": "7.0.0"
}
Expand Down
1 change: 1 addition & 0 deletions c#/crawler/src/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
global using TbClient.Post.Common;
global using TbClient.Wrapper;
global using Thread = TbClient.Post.Thread;
global using User = tbm.Crawler.Db.User;

global using Fid = System.UInt32;
global using PostId = System.UInt64;
Expand Down
2 changes: 1 addition & 1 deletion c#/crawler/src/Tieba/Crawl/Facade/ReplyCrawlFacade.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected override void PostCommitSaveHook(
p => p.Pid, p => p.OriginalContents, stoppingToken);

// fill the values for some field of reply from user list which is out of post list
private static void FillAuthorInfoBackToReply(IEnumerable<User> users, IEnumerable<ReplyPost> parsedReplies) =>
private static void FillAuthorInfoBackToReply(IEnumerable<TbClient.User> users, IEnumerable<ReplyPost> parsedReplies) =>
(from reply in parsedReplies
join user in users on reply.AuthorUid equals user.Uid
select (reply, user))
Expand Down
2 changes: 1 addition & 1 deletion c#/crawler/src/Tieba/Crawl/Facade/ThreadCrawlFacade.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected override void BeforeCommitSaveHook(CrawlerDbContext db)

protected void ParseLatestRepliers(IEnumerable<Thread> threads) =>
threads.Select(th => th.LastReplyer ?? null) // LastReplyer will be null when LivePostType != ""
.OfType<User>() // filter out nulls
.OfType<TbClient.User>() // filter out nulls

// some rare deleted thread but still visible in 6.0.2 response
// will have a latest replier uid=0 name="" nameShow=".*"
Expand Down
8 changes: 4 additions & 4 deletions c#/crawler/src/Tieba/Crawl/Parser/BaseParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@ public abstract class BaseParser<TPost, TPostProtoBuf>
{
public void ParsePosts(
CrawlRequestFlag requestFlag, IList<TPostProtoBuf> inPosts,
out Dictionary<PostId, TPost> outPosts, out List<User> outUsers)
out Dictionary<PostId, TPost> outPosts, out List<TbClient.User> outUsers)
{
outUsers = new(30);
if (ShouldSkipParse(requestFlag))
{
outPosts = new();
return;
}
var outNullableUsers = new List<User?>();
var outNullableUsers = new List<TbClient.User?>();
outPosts = ParsePostsInternal(inPosts, outNullableUsers).ToDictionary(PostIdSelector, post => post);
if (outPosts.Values.Any(p => p.AuthorUid == 0))
throw new TiebaException(shouldRetry: true,
"Value of IPost.AuthorUid is the protoBuf default value 0.");
outUsers.AddRange(outNullableUsers.OfType<User>()
outUsers.AddRange(outNullableUsers.OfType<TbClient.User>()
.Where(u => u.CalculateSize() != 0)); // remove empty users
}

protected abstract PostId PostIdSelector(TPost post);
protected abstract TPost Convert(TPostProtoBuf inPost);
protected abstract IEnumerable<TPost> ParsePostsInternal(IList<TPostProtoBuf> inPosts, List<User?> outUsers);
protected abstract IEnumerable<TPost> ParsePostsInternal(IList<TPostProtoBuf> inPosts, List<TbClient.User?> outUsers);
protected virtual bool ShouldSkipParse(CrawlRequestFlag requestFlag) => false;
}
2 changes: 1 addition & 1 deletion c#/crawler/src/Tieba/Crawl/Parser/ReplyParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public partial class ReplyParser(ILogger<ReplyParser> logger)
protected override PostId PostIdSelector(ReplyPost post) => post.Pid;

protected override IEnumerable<ReplyPost> ParsePostsInternal
(IList<Reply> inPosts, List<User?> outUsers) => inPosts.Select(Convert);
(IList<Reply> inPosts, List<TbClient.User?> outUsers) => inPosts.Select(Convert);

protected override ReplyPost Convert(Reply inPost)
{
Expand Down
2 changes: 1 addition & 1 deletion c#/crawler/src/Tieba/Crawl/Parser/SubReplyParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ public class SubReplyParser : BaseParser<SubReplyPost, SubReply>
{
protected override PostId PostIdSelector(SubReplyPost post) => post.Spid;

protected override IEnumerable<SubReplyPost> ParsePostsInternal(IList<SubReply> inPosts, List<User?> outUsers)
protected override IEnumerable<SubReplyPost> ParsePostsInternal(IList<SubReply> inPosts, List<TbClient.User?> outUsers)
{
outUsers.AddRange(inPosts.Select(sr => sr.Author));
return inPosts.Select(Convert);
Expand Down
2 changes: 1 addition & 1 deletion c#/crawler/src/Tieba/Crawl/Parser/ThreadParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ protected override bool ShouldSkipParse(CrawlRequestFlag requestFlag) =>
requestFlag == CrawlRequestFlag.ThreadClientVersion602;

protected override IEnumerable<ThreadPost> ParsePostsInternal
(IList<Thread> inPosts, List<User?> outUsers) => inPosts.Select(Convert);
(IList<Thread> inPosts, List<TbClient.User?> outUsers) => inPosts.Select(Convert);

protected override ThreadPost Convert(Thread inPost)
{
Expand Down
2 changes: 1 addition & 1 deletion c#/crawler/src/Tieba/Crawl/UserParserAndSaver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public partial class UserParserAndSaver(ILogger<UserParserAndSaver> logger)
private readonly List<Uid> _savedUsersId = new();
private readonly ConcurrentDictionary<Uid, User> _users = new();

public void ParseUsers(IEnumerable<User> users) =>
public void ParseUsers(IEnumerable<TbClient.User> users) =>
users.Select(el =>
{
static (string Portrait, uint? UpdateTime) ExtractPortrait(string portrait) =>
Expand Down
2 changes: 1 addition & 1 deletion c#/crawler/tbm.Crawler.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<ProjectReference Include="..\shared\tbm.Shared.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="AngleSharp" Version="1.0.7" />
<PackageReference Include="AngleSharp" Version="1.1.0" />
<PackageReference Include="Dapper" Version="2.1.28" />
<PackageReference Include="FlexLabs.EntityFrameworkCore.Upsert" Version="7.0.0" />
<PackageReference Include="Humanizer.Core.zh-Hans" Version="2.14.1" />
Expand Down
6 changes: 3 additions & 3 deletions c#/imagePipeline/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"net7.0": {
"LanguageExt.Core": {
"type": "Direct",
"requested": "[4.4.7, )",
"resolved": "4.4.7",
"contentHash": "dZVtfDw22sbiSXsMMgytlv+ggE2q3mf6fvLp4YNoksNkNLk2inXCe/TM6UcdXNj9tOhn3mUTtXealIxkG1gGzA==",
"requested": "[4.4.8, )",
"resolved": "4.4.8",
"contentHash": "zd3+mICicbTvf17OuOaruTpluiA5qEl9e28rXSokkI/rK9vdtZzpigYN6+D6Yx9jTkkVDZlvoYUg28RtQqtGiw==",
"dependencies": {
"Microsoft.Bcl.AsyncInterfaces": "7.0.0",
"Microsoft.CSharp": "4.7.0",
Expand Down
2 changes: 1 addition & 1 deletion c#/imagePipeline/tbm.ImagePipeline.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<ProjectReference Include="..\shared\tbm.Shared.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="LanguageExt.Core" Version="4.4.7" />
<PackageReference Include="LanguageExt.Core" Version="4.4.8" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="8.0.1" />
<PackageReference Include="OpenCvSharp4" Version="4.9.0.20240103" />
<PackageReference Include="OpenCvSharp4.runtime.win" Version="4.9.0.20240103" />
Expand Down

0 comments on commit e9eaff0

Please sign in to comment.