diff --git a/eng/Analyzers.props b/eng/Analyzers.props index b134dd71d8..6bda364756 100644 --- a/eng/Analyzers.props +++ b/eng/Analyzers.props @@ -8,7 +8,7 @@ file which is not marked as such, making StyleCop fail. --> - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/eng/StyleCop.Analyzers.ruleset b/eng/StyleCop.Analyzers.ruleset index 379337e8e4..f7581b15eb 100644 --- a/eng/StyleCop.Analyzers.ruleset +++ b/eng/StyleCop.Analyzers.ruleset @@ -72,6 +72,7 @@ + @@ -105,6 +106,8 @@ + + @@ -122,7 +125,7 @@ - + @@ -181,6 +184,8 @@ + + diff --git a/src/devices/CharacterLcd/Hd44780.cs b/src/devices/CharacterLcd/Hd44780.cs index 2988f1d1f5..d37582c1d7 100644 --- a/src/devices/CharacterLcd/Hd44780.cs +++ b/src/devices/CharacterLcd/Hd44780.cs @@ -262,7 +262,8 @@ public void SetCursorPosition(int left, int top) public bool DisplayOn { get => (_displayControl & DisplayControl.DisplayOn) > 0; - set => SendCommandAndWait((byte)(value ? _displayControl |= DisplayControl.DisplayOn + set => SendCommandAndWait((byte)(value + ? _displayControl |= DisplayControl.DisplayOn : _displayControl &= ~DisplayControl.DisplayOn)); } @@ -272,7 +273,8 @@ public bool DisplayOn public bool UnderlineCursorVisible { get => (_displayControl & DisplayControl.CursorOn) > 0; - set => SendCommandAndWait((byte)(value ? _displayControl |= DisplayControl.CursorOn + set => SendCommandAndWait((byte)(value + ? _displayControl |= DisplayControl.CursorOn : _displayControl &= ~DisplayControl.CursorOn)); } @@ -282,7 +284,8 @@ public bool UnderlineCursorVisible public bool BlinkingCursorVisible { get => (_displayControl & DisplayControl.BlinkOn) > 0; - set => SendCommandAndWait((byte)(value ? _displayControl |= DisplayControl.BlinkOn + set => SendCommandAndWait((byte)(value + ? _displayControl |= DisplayControl.BlinkOn : _displayControl &= ~DisplayControl.BlinkOn)); } @@ -292,7 +295,8 @@ public bool BlinkingCursorVisible public bool AutoShift { get => (_displayMode & DisplayEntryMode.DisplayShift) > 0; - set => SendCommandAndWait((byte)(value ? _displayMode |= DisplayEntryMode.DisplayShift + set => SendCommandAndWait((byte)(value + ? _displayMode |= DisplayEntryMode.DisplayShift : _displayMode &= ~DisplayEntryMode.DisplayShift)); } @@ -302,7 +306,8 @@ public bool AutoShift public bool Increment { get => (_displayMode & DisplayEntryMode.Increment) > 0; - set => SendCommandAndWait((byte)(value ? _displayMode |= DisplayEntryMode.Increment + set => SendCommandAndWait((byte)(value + ? _displayMode |= DisplayEntryMode.Increment : _displayMode &= ~DisplayEntryMode.Increment)); } diff --git a/src/devices/Mcp23xxx/SpiAdapter.cs b/src/devices/Mcp23xxx/SpiAdapter.cs index f2b077b54e..9b489223b9 100644 --- a/src/devices/Mcp23xxx/SpiAdapter.cs +++ b/src/devices/Mcp23xxx/SpiAdapter.cs @@ -7,9 +7,6 @@ namespace Iot.Device.Mcp23xxx { - /// - /// Base class for Mcp23xxx GPIO expanders - /// public abstract partial class Mcp23xxx { /// diff --git a/src/devices/Media/VideoDevice/VideoDevice.Converter.cs b/src/devices/Media/VideoDevice/VideoDevice.Converter.cs index 701cf49f4b..cd0b8ae2fd 100644 --- a/src/devices/Media/VideoDevice/VideoDevice.Converter.cs +++ b/src/devices/Media/VideoDevice/VideoDevice.Converter.cs @@ -8,9 +8,6 @@ namespace Iot.Device.Media { - /// - /// The communications channel to a video device. - /// public abstract partial class VideoDevice { /// diff --git a/src/devices/Nmea0183/AisSentences/StaticDataReportMessage.cs b/src/devices/Nmea0183/AisSentences/StaticDataReportMessage.cs index d8510582f6..3029c3f259 100644 --- a/src/devices/Nmea0183/AisSentences/StaticDataReportMessage.cs +++ b/src/devices/Nmea0183/AisSentences/StaticDataReportMessage.cs @@ -35,12 +35,6 @@ private StaticDataReportMessage(Payload payload) public override AisTransceiverClass TransceiverType => AisTransceiverClass.B; - public override void Encode(Payload payload) - { - base.Encode(payload); - payload.WriteUInt(PartNumber, 2); - } - public static AisMessage Create(Payload payload) { var message = new StaticDataReportMessage(payload); @@ -51,5 +45,11 @@ public static AisMessage Create(Payload payload) return new StaticDataReportPartBMessage(message, payload); } + + public override void Encode(Payload payload) + { + base.Encode(payload); + payload.WriteUInt(PartNumber, 2); + } } } diff --git a/src/devices/Pca9685/samples/Program.cs b/src/devices/Pca9685/samples/Program.cs index a819b60b67..ae84d24761 100644 --- a/src/devices/Pca9685/samples/Program.cs +++ b/src/devices/Pca9685/samples/Program.cs @@ -35,7 +35,7 @@ while (true) { string[]? command = Console.ReadLine()?.ToLower()?.Split(' '); - if (command?[0] is not { Length: >0 }) + if (command?[0] is not { Length: > 0 }) { return; } diff --git a/src/devices/Pcd8544/Pcd8544.cs b/src/devices/Pcd8544/Pcd8544.cs index 405ff2966f..acc6cd6b9c 100644 --- a/src/devices/Pcd8544/Pcd8544.cs +++ b/src/devices/Pcd8544/Pcd8544.cs @@ -324,9 +324,9 @@ public void CreateCustomCharacter(int location, ReadOnlySpan characterMap) throw new ArgumentException($"Character can only be 8 or 5 bytes array"); } - byte[] character = characterMap.Length == 8 ? - LcdCharacterEncodingFactory.ConvertFont8to5bytes(characterMap.ToArray()) : - characterMap.ToArray(); + byte[] character = characterMap.Length == 8 + ? LcdCharacterEncodingFactory.ConvertFont8to5bytes(characterMap.ToArray()) + : characterMap.ToArray(); if (_font.ContainsKey((char)location)) { diff --git a/src/devices/Seesaw/SeesawNeopixel.cs b/src/devices/Seesaw/SeesawNeopixel.cs index 75c3e3584d..17540bdf28 100644 --- a/src/devices/Seesaw/SeesawNeopixel.cs +++ b/src/devices/Seesaw/SeesawNeopixel.cs @@ -11,9 +11,6 @@ namespace Iot.Device.Seesaw { - /// - /// Seesaw GPIO driver - /// public partial class Seesaw : IDisposable { /// diff --git a/src/devices/Ssd1351/Ssd1351Commands.cs b/src/devices/Ssd1351/Ssd1351Commands.cs index 86b7375fde..5069694170 100644 --- a/src/devices/Ssd1351/Ssd1351Commands.cs +++ b/src/devices/Ssd1351/Ssd1351Commands.cs @@ -187,9 +187,6 @@ public enum ScrollSpeed : byte Slowest = 0x03 } - /// - /// Constructs Ssd1351 instance - /// public partial class Ssd1351 : IDisposable { /// diff --git a/src/devices/Ssd13xx/Ssd1306.cs b/src/devices/Ssd13xx/Ssd1306.cs index 45180ec37c..7bdcb9dc0c 100644 --- a/src/devices/Ssd13xx/Ssd1306.cs +++ b/src/devices/Ssd13xx/Ssd1306.cs @@ -48,7 +48,7 @@ private void SendCommand(ICommand command) { Span commandBytes = command?.GetBytes(); - if (commandBytes is not { Length: >0 }) + if (commandBytes is not { Length: > 0 }) { throw new ArgumentNullException(nameof(command), "Argument is either null or there were no bytes to send."); } diff --git a/src/devices/Ssd13xx/Ssd1309.cs b/src/devices/Ssd13xx/Ssd1309.cs index 82dec53b30..68bb0111c4 100644 --- a/src/devices/Ssd13xx/Ssd1309.cs +++ b/src/devices/Ssd13xx/Ssd1309.cs @@ -72,7 +72,7 @@ private void SendCommand(ICommand command) { Span commandBytes = command?.GetBytes(); - if (commandBytes is not { Length: >0 }) + if (commandBytes is not { Length: > 0 }) { throw new ArgumentNullException(nameof(command), "Argument is either null or there were no bytes to send."); } diff --git a/src/devices/Ssd13xx/Ssd1327.cs b/src/devices/Ssd13xx/Ssd1327.cs index ae237b71b5..e4f5a794fe 100644 --- a/src/devices/Ssd13xx/Ssd1327.cs +++ b/src/devices/Ssd13xx/Ssd1327.cs @@ -114,7 +114,7 @@ private void SendCommand(ICommand command) { byte[]? commandBytes = command?.GetBytes(); - if (commandBytes is not { Length: >0 }) + if (commandBytes is not { Length: > 0 }) { throw new ArgumentException("Argument is either null or there were no bytes to send.", nameof(command)); } diff --git a/src/devices/Tca955x/Tca955x.cs b/src/devices/Tca955x/Tca955x.cs index 53978f53ad..40fcba3bd2 100644 --- a/src/devices/Tca955x/Tca955x.cs +++ b/src/devices/Tca955x/Tca955x.cs @@ -437,7 +437,7 @@ protected override PinMode GetPinMode(int pinNumber) byte register = GetRegisterIndex(pinNumber, Register.ConfigurationPort); return IsBitSet(InternalReadByte(register), GetBitNumber(pinNumber)) ? PinMode.Input - : PinMode.Output; + : PinMode.Output; } private void InterruptHandler(object sender, PinValueChangedEventArgs e) diff --git a/src/devices/UFireIse/samples/Program.cs b/src/devices/UFireIse/samples/Program.cs index 21c2d30582..06a5032bcc 100644 --- a/src/devices/UFireIse/samples/Program.cs +++ b/src/devices/UFireIse/samples/Program.cs @@ -20,7 +20,7 @@ while (true) { string[]? command = Console.ReadLine()?.ToLower()?.Split(' '); - if (command?[0] is not { Length: >0 }) + if (command?[0] is not { Length: > 0 }) { return; } diff --git a/src/devices/Vcnl4040/samples/Explorer/Explorer.Ps.cs b/src/devices/Vcnl4040/samples/Explorer/Explorer.Ps.cs index c2e05700d2..a92d034970 100644 --- a/src/devices/Vcnl4040/samples/Explorer/Explorer.Ps.cs +++ b/src/devices/Vcnl4040/samples/Explorer/Explorer.Ps.cs @@ -239,7 +239,9 @@ private void EnableProximityInterrupts() } mode = awayEventEnabled && closeEventEnabled ? ProximityInterruptMode.CloseOrAwayInterrupt : - awayEventEnabled ? ProximityInterruptMode.AwayInterrupt : closeEventEnabled ? ProximityInterruptMode.CloseInterrupt : ProximityInterruptMode.Nothing; + awayEventEnabled ? ProximityInterruptMode.AwayInterrupt : + closeEventEnabled ? ProximityInterruptMode.CloseInterrupt : + ProximityInterruptMode.Nothing; } if (mode == ProximityInterruptMode.Nothing) diff --git a/tools/ArduinoCsCompiler/ExecutionSet.cs b/tools/ArduinoCsCompiler/ExecutionSet.cs index d115741cc2..f24ffcdcac 100644 --- a/tools/ArduinoCsCompiler/ExecutionSet.cs +++ b/tools/ArduinoCsCompiler/ExecutionSet.cs @@ -1846,7 +1846,7 @@ public void AddReverseFieldLookupTable() _logger.LogDebug($"Got {fieldOrCtorTokenToClass.Count} members in reverse lookup index"); } - internal bool TryGetCachedCode(EquatableMethod method, [NotNullWhen(true)]out IlCode? ilCode) + internal bool TryGetCachedCode(EquatableMethod method, [NotNullWhen(true)] out IlCode? ilCode) { if (_codeCache.TryGetValue(method, out ilCode)) { diff --git a/tools/ArduinoCsCompiler/Runtime/MiniPathInternal.cs b/tools/ArduinoCsCompiler/Runtime/MiniPathInternal.cs index 78cf5ea465..e2887ff1e7 100644 --- a/tools/ArduinoCsCompiler/Runtime/MiniPathInternal.cs +++ b/tools/ArduinoCsCompiler/Runtime/MiniPathInternal.cs @@ -297,9 +297,9 @@ public static bool EndsInDirectorySeparator(ReadOnlySpan path) => path.Length > 0 && IsDirectorySeparator(path[path.Length - 1]); public static ReadOnlySpan TrimEndingDirectorySeparator(ReadOnlySpan path) => - EndsInDirectorySeparator(path) && !IsRoot(path) ? - path.Slice(0, path.Length - 1) : - path; + EndsInDirectorySeparator(path) && !IsRoot(path) + ? path.Slice(0, path.Length - 1) + : path; [ArduinoImplementation] public static bool IsRoot(ReadOnlySpan path)