Skip to content

Commit

Permalink
feat: StyleCop (#2)
Browse files Browse the repository at this point in the history
* feat: added CI

* feat: stylecop
  • Loading branch information
antomys authored Nov 17, 2024
1 parent 2df0ac1 commit e3e78fe
Show file tree
Hide file tree
Showing 14 changed files with 1,047 additions and 19 deletions.
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 @@ -7,6 +7,7 @@ public class ExportParser
public static async Task<ChatExport?> ParseChatExportFile(string file)
{
var content = await File.ReadAllTextAsync(file);

return ParseChatExport(content);
}

Expand All @@ -16,7 +17,9 @@ public class ExportParser
{
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; }
}

0 comments on commit e3e78fe

Please sign in to comment.