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: StyleCop #2

Merged
merged 3 commits into from
Nov 17, 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
740 changes: 740 additions & 0 deletions .editorconfig

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ updates:
- package-ecosystem: nuget
directory: '/'
schedule:
interval: weekly
interval: monthly
time: '08:00'
timezone: Europe/Kyiv
labels:
Expand All @@ -21,7 +21,7 @@ updates:
- package-ecosystem: github-actions
directory: '/'
schedule:
interval: weekly
interval: monthly
time: '08:00'
timezone: Europe/Kyiv
labels:
Expand Down
254 changes: 254 additions & 0 deletions StyleCop.ruleset

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,11 @@
<ProjectReference Include="..\TelegramExportProcessor\TelegramExportProcessor.csproj" />
</ItemGroup>

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

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
</PropertyGroup>

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

Expand Down
5 changes: 5 additions & 0 deletions TelegramExportProcessor/ChatExport.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
// See https://aka.ms/new-console-template for more information
namespace TelegramExportProcessor;

public class ChatExport
{
public string Name { get; set; }

public string Type { get; set; }

public int Id { get; set; }

public List<ChatMessage> Messages { get; set; }
}
11 changes: 10 additions & 1 deletion TelegramExportProcessor/ChatMessage.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
// See https://aka.ms/new-console-template for more information

using System.Text.Json.Serialization;

namespace TelegramExportProcessor;

public class ChatMessage
{
public int Id { get; set; }

public string Type { get; set; }

public DateTime Date { get; set; }

[JsonPropertyName("date_unixtime")]
public string DateUnixTime { get; set; }

public DateTime? Edited { get; set; }

[JsonPropertyName("edited_unixtime")]
public string? EditedUnixTime { get; set; }

public string? Title { get; set; }
//public string? Text { get; set; }

// public string? Text { get; set; }
public string? From { get; set; }

[JsonPropertyName("from_id")]
public string? FromId { get; set; }

[JsonPropertyName("text_entities")]
public List<TextEntity> TextEntities { get; set; }

public List<Reaction> Reactions { get; set; }
}
14 changes: 5 additions & 9 deletions TelegramExportProcessor/ComplexTextJsonConverter.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.Json;
using System.Threading.Tasks;

namespace TelegramExportProcessor;

Expand All @@ -17,7 +11,8 @@ public override ComplexText Read(
JsonSerializerOptions options)
{
throw new NotImplementedException();
//return DateTimeOffset.ParseExact(reader.GetString()!,

// return DateTimeOffset.ParseExact(reader.GetString()!,
// "MM/dd/yyyy", CultureInfo.InvariantCulture);
}

Expand All @@ -27,7 +22,8 @@ public override void Write(
JsonSerializerOptions options)
{
throw new NotImplementedException();
//writer.WriteStringValue(dateTimeValue.ToString(

// writer.WriteStringValue(dateTimeValue.ToString(
// "MM/dd/yyyy", CultureInfo.InvariantCulture));
}
}
9 changes: 2 additions & 7 deletions TelegramExportProcessor/ComplexTextPart.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TelegramExportProcessor;
namespace TelegramExportProcessor;

public class ComplexTextPart
{
public string Text { get; set; }

public string Type { get; set; }
}
3 changes: 3 additions & 0 deletions TelegramExportProcessor/ExportParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

namespace TelegramExportProcessor;

public class ExportParser

Check warning on line 5 in TelegramExportProcessor/ExportParser.cs

View workflow job for this annotation

GitHub Actions / build

Type 'ExportParser' is a static holder type but is neither static nor NotInheritable (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1052)

Check warning on line 5 in TelegramExportProcessor/ExportParser.cs

View workflow job for this annotation

GitHub Actions / build

Type 'ExportParser' is a static holder type but is neither static nor NotInheritable (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1052)
{
public static async Task<ChatExport?> ParseChatExportFile(string file)
{
var content = await File.ReadAllTextAsync(file);

return ParseChatExport(content);
}

Expand All @@ -16,7 +17,9 @@
{
content += "]}";
}

var chatHistory = JsonSerializer.Deserialize(content, SourceGenerationContext.Default.ChatExport);

return chatHistory;
}
}
4 changes: 4 additions & 0 deletions TelegramExportProcessor/Reaction.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
// See https://aka.ms/new-console-template for more information
namespace TelegramExportProcessor;

public class Reaction
{
public int Count { get; set; }

public string Type { get; set; }

public string Emoji { get; set; }
}
1 change: 1 addition & 0 deletions TelegramExportProcessor/SourceGenerationContext.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// See https://aka.ms/new-console-template for more information
using System.Text.Json.Serialization;
using TelegramExportProcessor;

[JsonSourceGenerationOptions(WriteIndented = true, PropertyNamingPolicy = JsonKnownNamingPolicy.KebabCaseLower)]
[JsonSerializable(typeof(ChatExport))]
Expand Down
7 changes: 7 additions & 0 deletions TelegramExportProcessor/TelegramExportProcessor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,11 @@
<VersionSuffix>0.0.1</VersionSuffix>
</PropertyGroup>

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

</Project>
3 changes: 3 additions & 0 deletions TelegramExportProcessor/TextEntity.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// See https://aka.ms/new-console-template for more information
namespace TelegramExportProcessor;

public class TextEntity
{
public string Text { get; set; }

public string Type { get; set; }
}
Loading