Skip to content

Commit f1352ae

Browse files
azu-compentJoNax97
authored andcommitted
fix: Suppress warnings to allow github workflow to pass
1 parent be62ce0 commit f1352ae

57 files changed

Lines changed: 295 additions & 166 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text eol=crlf

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ jobs:
3434
- name: Restore packages
3535
run: dotnet restore Arch.Extended.sln
3636
- name: Build
37-
run: dotnet build Arch.Extended.sln -c ${{ matrix.config }} --no-restore
37+
run: dotnet build Arch.Extended.sln -c ${{ matrix.config }} --no-restore -warnaserror
3838
- name: Test
3939
run: dotnet test Arch.Extended.sln -c ${{ matrix.config }} -l "console;verbosity=detailed"

Arch.AOT.SourceGenerator/SourceGenerator.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ namespace Arch.AOT.SourceGenerator
3131
public sealed class ComponentAttribute : Attribute { }
3232
}
3333
""";
34+
35+
/// <inheritdoc cref="IIncrementalGenerator.Initialize"/>
3436
public void Initialize(IncrementalGeneratorInitializationContext context)
3537
{
3638
// Register the attribute.

Arch.EventBus/EventBus.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ public struct ReceivingMethod
6464
public int Order;
6565
}
6666

67+
/// <summary>
68+
/// EventBusExtensions
69+
/// </summary>
6770
public static class EventBusExtensions
6871
{
6972

@@ -86,7 +89,7 @@ public static string RefKindToString(RefKind refKind)
8689
case RefKind.Out:
8790
return "out";
8891
}
89-
return null;
92+
return null!;
9093
}
9194

9295
/// <summary>
@@ -108,7 +111,7 @@ public static StringBuilder AppendEventMethods(this StringBuilder sb, IList<Meth
108111
/// Appends all methods redirecting events.
109112
/// </summary>
110113
/// <param name="sb">The <see cref="StringBuilder"/>.</param>
111-
/// <param name="callMethods">The <see cref="IList{T}"/> containing the <see cref="Method"/>s redirecting the event and calling the methods. </param>
114+
/// <param name="callMethod">The <see cref="IList{T}"/> containing the <see cref="Method"/>s redirecting the event and calling the methods. </param>
112115
/// <returns></returns>
113116
public static StringBuilder AppendEventMethod(this StringBuilder sb, Method callMethod)
114117
{

Arch.EventBus/Hooks.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,30 @@
33

44
namespace Arch.Bus;
55

6+
/// <summary>
7+
/// Hooks.
8+
/// </summary>
69
public struct Hooks
710
{
11+
/// <summary>
12+
/// Instances.
13+
/// </summary>
814
public List<ClassHooks> Instances;
915
}
1016

17+
/// <summary>
18+
/// Class hooks.
19+
/// </summary>
1120
public struct ClassHooks
1221
{
22+
/// <summary>
23+
/// Partial class.
24+
/// </summary>
1325
public ITypeSymbol PartialClass;
26+
27+
/// <summary>
28+
/// Event hooks.
29+
/// </summary>
1430
public IList<EventHook> EventHooks;
1531
}
1632

@@ -32,7 +48,10 @@ public struct EventHook
3248
public IMethodSymbol MethodSymbol;
3349
}
3450

35-
public static class Hookersxtensions
51+
/// <summary>
52+
/// Hook extensions.
53+
/// </summary>
54+
public static class HookExtensions
3655
{
3756

3857
/// <summary>
Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
namespace Arch.Bus;
44

5-
public static class IMethodSymbolExtensions
5+
/// <summary>
6+
/// Method symbol extensions.
7+
/// </summary>
8+
public static class MethodSymbolExtensions
69
{
710

811
/// <summary>
@@ -16,12 +19,12 @@ public static AttributeData GetAttributeData(this IMethodSymbol ms, string name)
1619
foreach (var attribute in ms.GetAttributes())
1720
{
1821
var classSymbol = attribute.AttributeClass;
19-
if(!classSymbol.Name.Contains(name)) continue;
22+
if(!classSymbol!.Name.Contains(name)) continue;
2023

2124
return attribute;
2225
}
2326

24-
return default;
27+
return default!;
2528
}
2629

2730
/// <summary>
@@ -30,17 +33,17 @@ public static AttributeData GetAttributeData(this IMethodSymbol ms, string name)
3033
/// </summary>
3134
/// <param name="data">The <see cref="AttributeData"/>.</param>
3235
/// <param name="array">The <see cref="List{T}"/> where the found <see cref="ITypeSymbol"/>s are added to.</param>
33-
public static void GetAttributeTypes(this AttributeData data, List<ITypeSymbol> array)
36+
public static void GetAttributeTypes(this AttributeData? data, List<ITypeSymbol> array)
3437
{
35-
if (data is not null && data.AttributeClass.IsGenericType)
38+
if (data is not null && data.AttributeClass!.IsGenericType)
3639
{
3740
array.AddRange(data.AttributeClass.TypeArguments);
3841
}
39-
else if (data is not null && !data.AttributeClass.IsGenericType)
42+
else if (data is not null && !data.AttributeClass!.IsGenericType)
4043
{
4144
var constructorArguments = data.ConstructorArguments[0].Values;
4245
var constructorArgumentsTypes = constructorArguments.Select(constant => constant.Value as ITypeSymbol).ToList();
43-
array.AddRange(constructorArgumentsTypes);
46+
array.AddRange(constructorArgumentsTypes!);
4447
}
4548
}
4649
}

Arch.EventBus/SourceGenerator.cs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,19 @@
88

99
namespace Arch.Bus;
1010

11+
/// <summary>
12+
/// Query generator.
13+
/// </summary>
1114
[Generator]
1215
public class QueryGenerator : IIncrementalGenerator
1316
{
1417
private static EventBus _eventBus;
1518
private static Hooks _hooks;
1619

17-
private static Dictionary<ITypeSymbol, (RefKind, IList<ReceivingMethod>)> _eventTypeToReceivingMethods;
18-
private static Dictionary<ITypeSymbol, IList<EventHook>> _containingTypeToReceivingMethods;
20+
private static Dictionary<ITypeSymbol, (RefKind, IList<ReceivingMethod>)> _eventTypeToReceivingMethods = null!;
21+
private static Dictionary<ITypeSymbol, IList<EventHook>> _containingTypeToReceivingMethods = null!;
1922

23+
/// <inheritdoc cref="IIncrementalGenerator.Initialize"/>
2024
public void Initialize(IncrementalGeneratorInitializationContext context)
2125
{
2226
//if (!Debugger.IsAttached) Debugger.Launch();
@@ -59,7 +63,7 @@ public EventAttribute(int order = 0)
5963

6064

6165
/// <summary>
62-
/// Returns a <see cref="MethodDeclarationSyntax"/> if its annocated with a attribute of <see cref="name"/>.
66+
/// Returns a <see cref="MethodDeclarationSyntax"/> if its annotated with an attribute of <paramref name="name"/>.
6367
/// </summary>
6468
/// <param name="context">Its <see cref="GeneratorSyntaxContext"/>.</param>
6569
/// <param name="name">The attributes name.</param>
@@ -97,7 +101,7 @@ private static void MapMethodToEventType(IMethodSymbol methodSymbol)
97101
{
98102
var eventType = methodSymbol.Parameters[0];
99103
var param = methodSymbol.GetAttributes()[0].ConstructorArguments[0];
100-
var receivingMethod = new ReceivingMethod{ Static = methodSymbol.IsStatic, MethodSymbol = methodSymbol, Order = (int)param.Value };
104+
var receivingMethod = new ReceivingMethod{ Static = methodSymbol.IsStatic, MethodSymbol = methodSymbol, Order = (int)param.Value! };
101105

102106
// Either append or create a new receiving method with a new list.
103107
if (_eventTypeToReceivingMethods.TryGetValue(eventType.Type, out var tuple))
@@ -189,19 +193,19 @@ private static void Generate(Compilation compilation, ImmutableArray<MethodDecla
189193
// Init
190194
_eventBus.Namespace = "Arch.Bus";
191195
_eventBus.Methods = new List<Method>(512);
192-
_eventTypeToReceivingMethods = new Dictionary<ITypeSymbol, (RefKind, IList<ReceivingMethod>)>(512);
196+
_eventTypeToReceivingMethods = new Dictionary<ITypeSymbol, (RefKind, IList<ReceivingMethod>)>(512, SymbolEqualityComparer.Default);
193197

194198
_hooks.Instances = new List<ClassHooks>(512);
195-
_containingTypeToReceivingMethods = new Dictionary<ITypeSymbol, IList<EventHook>>(512);
199+
_containingTypeToReceivingMethods = new Dictionary<ITypeSymbol, IList<EventHook>>(512, SymbolEqualityComparer.Default);
196200

197201
// Generate Query methods and map them to their classes
198202
foreach (var methodSyntax in methods)
199203
{
200204
var semanticModel = compilation.GetSemanticModel(methodSyntax.SyntaxTree);
201205
var methodSymbol = ModelExtensions.GetDeclaredSymbol(semanticModel, methodSyntax) as IMethodSymbol;
202206

203-
MapMethodToEventType(methodSymbol);
204-
MapMethodToContainingType(methodSymbol);
207+
MapMethodToEventType(methodSymbol!);
208+
MapMethodToContainingType(methodSymbol!);
205209
}
206210

207211
PrepareEventBus();

Arch.Extended.Sample/Game.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@ namespace Arch.Extended;
2727
public class Game : Microsoft.Xna.Framework.Game
2828
{
2929
// The world and a job scheduler for multithreading
30-
private World _world;
31-
private JobScheduler _jobScheduler;
30+
private World _world = null!;
31+
private JobScheduler _jobScheduler = null!;
3232

3333
// Our systems processing entities
34-
private System.Group<GameTime> _systems;
35-
private DrawSystem _drawSystem;
34+
private System.Group<GameTime> _systems = null!;
35+
private DrawSystem _drawSystem = null!;
3636

3737
// Monogame stuff
3838
private GraphicsDeviceManager _graphics;
39-
private SpriteBatch _spriteBatch;
40-
private Texture2D _texture2D;
41-
private Random _random;
39+
private SpriteBatch _spriteBatch = null!;
40+
private Texture2D _texture2D = null!;
41+
private Random _random = null!;
4242

4343
public Game()
4444
{

Arch.Extended.Sample/Serializer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ public class SpriteSerializer : IJsonFormatter<Sprite>, IMessagePackFormatter<Sp
1515
/// <summary>
1616
/// The <see cref="GraphicsDevice"/> to create <see cref="Texture2D"/>s from.
1717
/// </summary>
18-
public GraphicsDevice GraphicsDevice { get; set; }
19-
18+
public GraphicsDevice GraphicsDevice { get; set; } = null!;
19+
2020
public void Serialize(ref JsonWriter writer, Sprite value, IJsonFormatterResolver formatterResolver)
2121
{
2222
writer.WriteBeginObject();

Arch.LowLevel.Tests/UnsafeArrayTest.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ public void UnsafeArrayFill()
5454
var array = new UnsafeArray<int>(35);
5555
using (array)
5656
{
57+
#pragma warning disable CS0728 // Possibly incorrect assignment to local which is the argument to a using or lock statement
5758
UnsafeArray.Fill(ref array, 8);
59+
#pragma warning restore CS0728 // Possibly incorrect assignment to local which is the argument to a using or lock statement
5860

5961
for (var i = 0; i < array.Length; i++)
6062
That(array[i], Is.EqualTo(8));
@@ -72,8 +74,10 @@ public void UnsafeArrayCopy()
7274
for (var i = 0; i < src.Length; i++)
7375
src[i] = i;
7476

77+
#pragma warning disable CS0728 // Possibly incorrect assignment to local which is the argument to a using or lock statement
7578
UnsafeArray.Fill(ref dst);
7679
UnsafeArray.Copy(ref src, 4, ref dst, 1, 4);
80+
#pragma warning restore CS0728 // Possibly incorrect assignment to local which is the argument to a using or lock statement
7781

7882
Multiple(() =>
7983
{

0 commit comments

Comments
 (0)