Skip to content

Commit

Permalink
Implement changes from review
Browse files Browse the repository at this point in the history
* Removed redundant check in `Attachment.cs` `CopyFrom` method.
* Updated `Period.cs` and `Trigger.cs` to use `Copy<IDateTime>()` method.
* Modified `Alarm` class to implement `IComparable<Alarm>` with `CompareTo` method.
  • Loading branch information
axunonb committed Oct 22, 2024
1 parent 1a8c88e commit 0ebef51
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 22 deletions.
26 changes: 11 additions & 15 deletions Ical.Net.Benchmarks/Ical.Net.Benchmarks.csproj
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net6.0;netcoreapp3.1;net48</TargetFrameworks>
<OutputType>Exe</OutputType>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Ical.Net\Ical.Net.csproj" />
</ItemGroup>

<PropertyGroup>
<TargetFrameworks>net8.0;net6.0;netcoreapp3.1;net48</TargetFrameworks>
<OutputType>Exe</OutputType>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Ical.Net\Ical.Net.csproj" />
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions Ical.Net.Tests/Ical.Net.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<TargetFrameworks>net8.0;net6.0;net48</TargetFrameworks>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\IcalNetStrongnameKey.snk</AssemblyOriginatorKeyFile>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
Expand Down
13 changes: 10 additions & 3 deletions Ical.Net/CalendarComponents/Alarm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ namespace Ical.Net.CalendarComponents
/// A class that represents an RFC 2445 VALARM component.
/// FIXME: move GetOccurrences() logic into an AlarmEvaluator.
/// </summary>
public class Alarm : CalendarComponent
public class Alarm : CalendarComponent, IComparable<Alarm>
{
//ToDo: Implement IEquatable
public virtual string Action
{
get => Properties.Get<string>(AlarmAction.Key);
Expand Down Expand Up @@ -176,5 +175,13 @@ protected virtual void AddRepeatedItems()
}
}
}

/// <inheritdoc/>
public int CompareTo(Alarm other)
{
return other == null
? 1
: string.Compare(Summary, other.Summary, StringComparison.Ordinal);
}
}
}
}
2 changes: 1 addition & 1 deletion Ical.Net/DataTypes/Attachment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public override void CopyFrom(ICopyable obj)
base.CopyFrom(obj);

Uri = att.Uri != null ? new Uri(att.Uri.ToString()) : null;
if (att.Data != null && att.Data.Length != 0)
if (att.Data != null)
{
Data = new byte[att.Data.Length];
Array.Copy(att.Data, Data, att.Data.Length);
Expand Down
4 changes: 2 additions & 2 deletions Ical.Net/DataTypes/Period.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public override void CopyFrom(ICopyable obj)

if (obj is not Period p) return;

StartTime = p.StartTime;
EndTime = p.EndTime;
StartTime = p.StartTime?.Copy<IDateTime>();
EndTime = p.EndTime?.Copy<IDateTime>();
Duration = p.Duration;
}

Expand Down
2 changes: 1 addition & 1 deletion Ical.Net/DataTypes/Trigger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public override void CopyFrom(ICopyable obj)
return;
}

DateTime = t.DateTime;
DateTime = t.DateTime?.Copy<IDateTime>();
Duration = t.Duration;
Related = t.Related;
}
Expand Down

0 comments on commit 0ebef51

Please sign in to comment.