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

Add .editorconfig & run dotnet format #16

Merged
merged 1 commit into from
Apr 22, 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
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*.cs]
indent_size = 4
indent_style = tab
tab_width = 4

csharp_new_line_before_open_brace = accessors, anonymous_methods, anonymous_types, events, indexers, local_functions, methods, object_collection_array_initializers, properties, types
csharp_new_line_before_else = false
csharp_new_line_before_catch = false
csharp_new_line_before_members_in_object_initializers = true
csharp_preserve_single_line_statements = true
12 changes: 6 additions & 6 deletions 7TVEmoteProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ internal class SevenTVEmoticonFile
public int width { get; set; }
public int height { get; set; }
}

public List<SevenTVEmoticonFile> files { get; set; }
}

public SevenTVEmoticonHost host { get; set; }
}

public string name { get; set; }
public int flags { get; set; }
public SevenTVEmoticonData data { get; set; }
Expand All @@ -39,17 +39,17 @@ private class SevenTVGlobalEmotes
{
public List<SevenTVEmoticon> emotes { get; set; }
}

private class SevenTVUserEmotes
{
internal class SevenTVEmoteSet
{
public List<SevenTVEmoticon> emotes { get; set; }
}

public SevenTVEmoteSet emote_set { get; set; }
}

public bool TryGetEmote(string Name, out SizeF Size) => EmoteCache.TryGetValue(Name, out Size);

public async Task Initialize(string ChannelID, CancellationToken Token)
Expand Down
5 changes: 3 additions & 2 deletions BTTVEmoteProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public async Task Initialize(string ChannelId, CancellationToken Token)

var rawJson = await Client.GetAsync("https://api.betterttv.net/3/cached/emotes/global", Token);
rawJson.EnsureSuccessStatusCode();

var globalEmotes = await JsonSerializer.DeserializeAsync<IEnumerable<BTTVEmote>>(await rawJson.Content.ReadAsStreamAsync());

void addToList(string Name, Stream EmoteStream)
Expand Down Expand Up @@ -102,7 +102,8 @@ void fetchAllForList(IEnumerable<BTTVEmote> Emotes)
.Replace("module.exports = ", "")
.Replace(";", "")
.Replace("'", "\"");
var emojiBlacklist = JsonSerializer.Deserialize<List<string>>(rawContents, new JsonSerializerOptions() {
var emojiBlacklist = JsonSerializer.Deserialize<List<string>>(rawContents, new JsonSerializerOptions()
{
ReadCommentHandling = JsonCommentHandling.Skip
});

Expand Down
12 changes: 6 additions & 6 deletions MessageHeightTwitch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

namespace MessageHeightTwitch
{
public class MessageHeightTwitch
{
public class MessageHeightTwitch
{
public struct CharacterProperty
{
public float Width;
Expand Down Expand Up @@ -55,7 +55,7 @@ public static void FillCharMap(string CharMapPath)
}

CharacterProperties = charProperties.ToArray();

Debug.Assert(broken);
Debug.Assert(CharacterProperties['A'].Width == 8);
Debug.Assert(CharacterProperties['@'].Width == 12.171875f);
Expand Down Expand Up @@ -317,7 +317,7 @@ public float CalculateMessageHeightEx(

var split = Regex.Split(Input, @"(?<=[ -])");
int curChar = 0;
for (int x = 0;x < split.Length;/* Increment is at the end of the loop */) {
for (int x = 0; x < split.Length;/* Increment is at the end of the loop */) {
// Currently processing emote name
string curEmoteName = null;
// Currently processing emote provider
Expand Down Expand Up @@ -388,7 +388,7 @@ bool tryGetEmote()
// No dice, try to:
curEmoteName = split[x].Substring(curChar);
emojiMatch = EmojiRegex.Match(curEmoteName);

// ...limit current lookup to first possible emoji
if (emojiMatch.Success)
curEmoteName = curEmoteName.Substring(0, emojiMatch.Index);
Expand Down Expand Up @@ -551,7 +551,7 @@ bool tryGetEmote()
if (split[x].Substring(curChar) != " ")
prevEmote = null;

for (int oldCurChar = curChar;curChar < split[x].Length;curChar++) {
for (int oldCurChar = curChar; curChar < split[x].Length; curChar++) {
if (emojiMatch.Success && emojiMatch.Index == curChar - oldCurChar) {
if (!FFZIsEmojiSupported(split[x].Substring(curChar, emojiMatch.Length)) &&
!BTTVIsEmojiSupported(split[x].Substring(curChar, emojiMatch.Length))) {
Expand Down
5 changes: 3 additions & 2 deletions MessageHeightTwitchStatic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

class MessageHeightTwitchStatic
{
public struct TwitchEmote {
public struct TwitchEmote
{
public string Name;

Check warning on line 9 in MessageHeightTwitchStatic.cs

View workflow job for this annotation

GitHub Actions / Build project on .NET 8.0.x

Field 'MessageHeightTwitchStatic.TwitchEmote.Name' is never assigned to, and will always have its default value null

Check warning on line 9 in MessageHeightTwitchStatic.cs

View workflow job for this annotation

GitHub Actions / Build project on .NET 8.0.x

Field 'MessageHeightTwitchStatic.TwitchEmote.Name' is never assigned to, and will always have its default value null
public string Url;

Check warning on line 10 in MessageHeightTwitchStatic.cs

View workflow job for this annotation

GitHub Actions / Build project on .NET 8.0.x

Field 'MessageHeightTwitchStatic.TwitchEmote.Url' is never assigned to, and will always have its default value null

Check warning on line 10 in MessageHeightTwitchStatic.cs

View workflow job for this annotation

GitHub Actions / Build project on .NET 8.0.x

Field 'MessageHeightTwitchStatic.TwitchEmote.Url' is never assigned to, and will always have its default value null
}

private static Dictionary<string, MessageHeightTwitch.MessageHeightTwitch> Instances = new Dictionary<string, MessageHeightTwitch.MessageHeightTwitch>();
Expand Down Expand Up @@ -64,8 +65,8 @@

try {
var dict = new Dictionary<string, string>();
if (TwitchEmotes != null) {

Check warning on line 68 in MessageHeightTwitchStatic.cs

View workflow job for this annotation

GitHub Actions / Build project on .NET 8.0.x

The result of the expression is always 'true' since a value of type 'nint' is never equal to 'null' of type 'nint?'

Check warning on line 68 in MessageHeightTwitchStatic.cs

View workflow job for this annotation

GitHub Actions / Build project on .NET 8.0.x

The result of the expression is always 'true' since a value of type 'nint' is never equal to 'null' of type 'nint?'
for (int x = 0;x < TwitchEmotesLen * Marshal.SizeOf<TwitchEmote>();x += Marshal.SizeOf<TwitchEmote>()) {
for (int x = 0; x < TwitchEmotesLen * Marshal.SizeOf<TwitchEmote>(); x += Marshal.SizeOf<TwitchEmote>()) {
var te = Marshal.PtrToStructure<TwitchEmote>(new IntPtr(TwitchEmotes.ToInt64() + x));
dict.Add(te.Name, te.Url);
}
Expand Down
Loading