Skip to content
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
2 changes: 1 addition & 1 deletion eng/Analyzers.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ file which is not marked as such, making StyleCop fail. -->
</PropertyGroup>
<ItemGroup Condition="'$(MSBuildProjectExtension)' == '.csproj'">
<AdditionalFiles Include="$(MSBuildThisFileDirectory)\stylecop.json" Link="stylecop.json" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
<PackageReference Include="StyleCop.Analyzers" Version="1.3.180">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
7 changes: 6 additions & 1 deletion eng/StyleCop.Analyzers.ruleset
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
<Rule Id="SA1136" Action="Error" />
<Rule Id="SA1137" Action="Error" />
<Rule Id="SA1139" Action="Error" />
<Rule Id="SA1143" Action="Error" /> <!-- Conditional expressions must be formatted consistently -->
<Rule Id="SA1167" Action="Error" /> <!-- Elements must have same indentation -->
<Rule Id="SA1200" Action="Error" />
<Rule Id="SA1201" Action="None" /> <!--Enum should not follow a class -->
Expand Down Expand Up @@ -105,6 +106,8 @@
<Rule Id="SA1312" Action="Error" />
<Rule Id="SA1313" Action="None" />
<Rule Id="SA1314" Action="Error" />
<Rule Id="SA1315" Action="None" /> <!-- Parameter names should match inherited names. Many public overrides use different names and renaming them would break callers using named arguments -->
<Rule Id="SA1317" Action="Error" /> <!-- Identifiers should use only Latin letters -->
<Rule Id="SA1400" Action="Error" />
<Rule Id="SA1401" Action="None" />
<Rule Id="SA1402" Action="None" /> <!-- File may only contain a single type -->
Expand All @@ -122,7 +125,7 @@
<Rule Id="SA1501" Action="Error" />
<Rule Id="SA1502" Action="Error" />
<Rule Id="SA1503" Action="Error" />
<Rule Id="SA1504" Action="Error" />
<Rule Id="SA1504" Action="None" /> <!-- All accessors should be single-line or multi-line. Since 1.3 it also flags "get => x; set { ... }", see https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/4391 -->
<Rule Id="SA1505" Action="Error" />
<Rule Id="SA1506" Action="Error" />
<Rule Id="SA1507" Action="Error" />
Expand Down Expand Up @@ -181,6 +184,8 @@
<Rule Id="SA1649" Action="None" /> <!-- Maybe todo: File name should match first type name -->
<Rule Id="SA1651" Action="Error" />
<Rule Id="SA1652" Action="Error" />
<Rule Id="SA1653" Action="Error" /> <!-- Only one part of a partial type should have a <summary> -->
<Rule Id="SA1654" Action="Error" /> <!-- Use braces for generic type arguments in cref, e.g. List{T} -->
<Rule Id="SX1101" Action="Error" /> <!-- Do not prefix local members with this -->
<Rule Id="SX1309" Action="Error" /> <!-- Members should be prefixed with _ -->
</Rules>
Expand Down
15 changes: 10 additions & 5 deletions src/devices/CharacterLcd/Hd44780.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand All @@ -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));
}

Expand All @@ -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));
}

Expand All @@ -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));
}

Expand All @@ -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));
}

Expand Down
3 changes: 0 additions & 3 deletions src/devices/Mcp23xxx/SpiAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@

namespace Iot.Device.Mcp23xxx
{
/// <summary>
/// Base class for Mcp23xxx GPIO expanders
/// </summary>
public abstract partial class Mcp23xxx
{
/// <summary>
Expand Down
3 changes: 0 additions & 3 deletions src/devices/Media/VideoDevice/VideoDevice.Converter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@

namespace Iot.Device.Media
{
/// <summary>
/// The communications channel to a video device.
/// </summary>
public abstract partial class VideoDevice
{
/// <summary>
Expand Down
12 changes: 6 additions & 6 deletions src/devices/Nmea0183/AisSentences/StaticDataReportMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
}
}
2 changes: 1 addition & 1 deletion src/devices/Pca9685/samples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions src/devices/Pcd8544/Pcd8544.cs
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,9 @@ public void CreateCustomCharacter(int location, ReadOnlySpan<byte> 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))
{
Expand Down
3 changes: 0 additions & 3 deletions src/devices/Seesaw/SeesawNeopixel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@

namespace Iot.Device.Seesaw
{
/// <summary>
/// Seesaw GPIO driver
/// </summary>
public partial class Seesaw : IDisposable
{
/// <summary>
Expand Down
3 changes: 0 additions & 3 deletions src/devices/Ssd1351/Ssd1351Commands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,6 @@ public enum ScrollSpeed : byte
Slowest = 0x03
}

/// <summary>
/// Constructs Ssd1351 instance
/// </summary>
public partial class Ssd1351 : IDisposable
{
/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/devices/Ssd13xx/Ssd1306.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private void SendCommand(ICommand command)
{
Span<byte> 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.");
}
Expand Down
2 changes: 1 addition & 1 deletion src/devices/Ssd13xx/Ssd1309.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private void SendCommand(ICommand command)
{
Span<byte> 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.");
}
Expand Down
2 changes: 1 addition & 1 deletion src/devices/Ssd13xx/Ssd1327.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion src/devices/Tca955x/Tca955x.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/devices/UFireIse/samples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 3 additions & 1 deletion src/devices/Vcnl4040/samples/Explorer/Explorer.Ps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tools/ArduinoCsCompiler/ExecutionSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand Down
6 changes: 3 additions & 3 deletions tools/ArduinoCsCompiler/Runtime/MiniPathInternal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,9 @@ public static bool EndsInDirectorySeparator(ReadOnlySpan<char> path)
=> path.Length > 0 && IsDirectorySeparator(path[path.Length - 1]);

public static ReadOnlySpan<char> TrimEndingDirectorySeparator(ReadOnlySpan<char> 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<char> path)
Expand Down
Loading