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
3 changes: 2 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Company>closure.ch</Company>
<Copyright>© 2024-2026 Robert Bill</Copyright>
<Copyright>© 2024-2026 Closure OSS Contributors</Copyright>
<Authors>Robert Bill</Authors>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
</PropertyGroup>
<PropertyGroup>
<UseArtifactsOutput>true</UseArtifactsOutput>
Expand Down
5 changes: 3 additions & 2 deletions GitVersion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ branches:
label: "beta"
feature:
mode: ContinuousDelivery
assembly-versioning-format: '{MajorMinorPatch}.{WeightedPreReleaseNumber}'
assembly-versioning-format: '{MajorMinorPatch}.0'
assembly-file-versioning-format: '{MajorMinorPatch}.{WeightedPreReleaseNumber}'
assembly-informational-format: '{MajorMinorPatch}.{WeightedPreReleaseNumber}'
assembly-informational-format: '{MajorMinorPatch}+{ShortSha}'
commit-date-format: yyyy-MM-ddTHH:mm:ssZ
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024-2025 Robert Bill
Copyright (c) 2024-2026 Closure OSS Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
17 changes: 17 additions & 0 deletions VSyntaxReader.Tests/Parsing/ParsingTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Calendare.VSyntaxReader.Components;
using Calendare.VSyntaxReader.Properties;
using Xunit.Abstractions;

namespace VSyntaxReader.Tests.Parsing;
Expand Down Expand Up @@ -51,6 +52,22 @@ public void ParseFileSimple(string filename, string verificationFilename)
}
}

[Theory]
[InlineData("wrong-mixed-format.ics", DeserializeErrorCategory.Syntax)]
[InlineData("wrong-file-format.json", DeserializeErrorCategory.WrongFormat)]
[InlineData("wrong-file-format-long.ics", DeserializeErrorCategory.WrongFormat)]
[InlineData("empty.ics", DeserializeErrorCategory.NoContent)]
[InlineData("empty-long.ics", DeserializeErrorCategory.NoContent)]
public void ParseInvalidData(string filename, DeserializeErrorCategory errorCategory)
{
var sourceFilename = FileExtensions.BuildSourceFilename(filename);
var parseResult = Builder.Parser.TryParseFile(sourceFilename, out var vcalendar);
Assert.Null(vcalendar);
Assert.False(parseResult.Success, parseResult.ErrorMessage);
Assert.Equal(errorCategory, parseResult.ErrorCategory);
}


[Theory]
[InlineData("Calendars/Alarm/ALARM1.ics")]
[InlineData("Calendars/Alarm/ALARM2.ics")]
Expand Down
25 changes: 25 additions & 0 deletions VSyntaxReader.Tests/Parsing/data/empty-long.ics
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

























13 changes: 13 additions & 0 deletions VSyntaxReader.Tests/Parsing/data/wrong-file-format-long.ics
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@












{ "Calendar": "i'm not" }
3 changes: 3 additions & 0 deletions VSyntaxReader.Tests/Parsing/data/wrong-file-format.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"Calendar": "i'm not"
}
20 changes: 20 additions & 0 deletions VSyntaxReader.Tests/Parsing/data/wrong-mixed-format.ics
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
BEGIN:VCALENDAR
VERSION:2.0
PRODID:DAVx5/4.4.2-ose ical4j/3.2.19 (at.techbee.jtx)
BEGIN:VTODO
DTSTAMP:20240813T061445Z
UID:02261d66-ea00-4404-a4d6-08e21012534c
SEQUENCE:20
CREATED:20240813T060745Z
LAST-MODIFIED:20240813T061437Z
SUMMARY:Task in TZ Hongkong
DESCRIPTION:What should I say\, that will give you a good sense of the type
of issues we are facing?
DTSTART;TZID=Hongkong:20240813T151500
PRIORITY:0
{
"Calendar": "i'm not",
"Correct": false
}
END:VTODO
END:VCALENDAR
2 changes: 1 addition & 1 deletion VSyntaxReader.Tests/VSyntaxReader.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<IsTestProject>true</IsTestProject>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="10.0.0">
<PackageReference Include="coverlet.collector" Version="10.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
6 changes: 3 additions & 3 deletions VSyntaxReader.Tests/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"net10.0": {
"coverlet.collector": {
"type": "Direct",
"requested": "[10.0.0, )",
"resolved": "10.0.0",
"contentHash": "WFejCcOUR6k8UYyDnnR6Gk+obFYMsWrZuNqPJnsVFGVhpPSN0y20D4qbdKJnXinYGx9PQ397Hf9TnU1NBST8vA=="
"requested": "[10.0.1, )",
"resolved": "10.0.1",
"contentHash": "27jXSV/0DbVqF5jDrAxuQFZ9oaz6gmG03p8ttxAFk+X0M4woFYj7MoWDLCna5EGLb0CE6OE7X6ZH3Wt5smTtaA=="
},
"GitVersion.MsBuild": {
"type": "Direct",
Expand Down
5 changes: 3 additions & 2 deletions VSyntaxReader/Parsers/CalendarParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,11 @@ public DeserializeResult TryParse(Stream fr, [NotNullWhen(true)] out VCalendar?
else
{
vcalendar = null;
return new DeserializeResult(false, $"{line.LineNo:0000}: ERROR {line.Raw} [{line.PhysicalLineCount}-{line.PhysicalLineNo + line.PhysicalLineCount}]");
var errCategory = line.LineNo != 0 ? DeserializeErrorCategory.Syntax : DeserializeErrorCategory.WrongFormat;
return new DeserializeResult(false, $"{line.LineNo:0000}: ERROR {line.Raw} [{line.PhysicalLineCount}-{line.PhysicalLineNo + line.PhysicalLineCount}]", errCategory);
}
}
lineReader.Close();
return vcalendar is not null ? new DeserializeResult(true) : new DeserializeResult(false, "Nothing to parse");
return vcalendar is not null ? new DeserializeResult(true) : new DeserializeResult(false, "Nothing to parse", DeserializeErrorCategory.NoContent);
}
}
9 changes: 8 additions & 1 deletion VSyntaxReader/Properties/DeserializeResult.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
namespace Calendare.VSyntaxReader.Properties;

public record DeserializeResult(bool Success, string? ErrorMessage = null)
public enum DeserializeErrorCategory
{
Syntax,
NoContent,
WrongFormat,
}

public record DeserializeResult(bool Success, string? ErrorMessage = null, DeserializeErrorCategory ErrorCategory = DeserializeErrorCategory.Syntax)
{
public static implicit operator bool(DeserializeResult dr) => dr.Success;
}
11 changes: 5 additions & 6 deletions VSyntaxReader/Properties/TextProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,15 @@ public string? Value
}
if (Raw.Parameters.TryFindOneParameter(EncodingParam, out var encoding))
{
switch (encoding.Value)
return encoding.Value switch
{
case "BASE64":
return Encoding.UTF8.GetString(Convert.FromBase64String(Raw.Value));
default:
return null; // NOT VALID AS ENCODING METHOD NOT SUPPORTED
}
"BASE64" => Encoding.UTF8.GetString(Convert.FromBase64String(Raw.Value)),
_ => null,// NOT VALID AS ENCODING METHOD NOT SUPPORTED
};
}
return EscapingExtensions.UnescapeText(Raw.Value);
}

set
{
Raw = Raw with { Value = EscapingExtensions.EscapeText(value) };
Expand Down
18 changes: 9 additions & 9 deletions VSyntaxReader/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
},
"Microsoft.NET.ILLink.Tasks": {
"type": "Direct",
"requested": "[10.0.7, )",
"resolved": "10.0.7",
"contentHash": "AA/yhzFHNtQZXLdqjzujPy25G8EWwGWsAnxOE2zYSBoT/8QHP6ketN3CToD3DFreO653ipUwnKHo22B8AlBMCw=="
"requested": "[10.0.8, )",
"resolved": "10.0.8",
"contentHash": "dVbSXGIFNR5nZcv2tOLoWI+a9T4jtFd77IYjuND+QVe360qWgAF7H0WtoopYhRw/+SgpGUTyrkrh+65+ClNnfw=="
},
"NodaTime": {
"type": "Direct",
Expand Down Expand Up @@ -51,9 +51,9 @@
},
"Microsoft.NET.ILLink.Tasks": {
"type": "Direct",
"requested": "[8.0.26, )",
"resolved": "8.0.26",
"contentHash": "o7/yVssM2r9Wyln2s9edBd5ANZXqdSdBI+g7JqXkyJmXrhs2WsJp25K5yPnYrTgdKBCjKB8bg+O2oew4sgzFaA=="
"requested": "[8.0.27, )",
"resolved": "8.0.27",
"contentHash": "rQi9TxifHRnXP7lVRZH05DxD2/XGbJp12q0ozcbrlBlBnyyzssFTH/2vLhtKWUp2CT1qVscTrcYTFiwTyKPKRg=="
},
"NodaTime": {
"type": "Direct",
Expand Down Expand Up @@ -86,9 +86,9 @@
},
"Microsoft.NET.ILLink.Tasks": {
"type": "Direct",
"requested": "[9.0.15, )",
"resolved": "9.0.15",
"contentHash": "EejcbfCMR77Dthy77qxRbEShmzLApHZUPqXMBVQK+A0pNrRThkaHoGGMGvbq/gTkC/waKcDEgjBkbaejB58Wtw=="
"requested": "[9.0.16, )",
"resolved": "9.0.16",
"contentHash": "ccPBYGLPJt8DeJTUzQ0JzOh/iuUAgnjayU63PokVywAhUOx+dzDKSPTL7AG94U/VpvNXflTT2AjsFAIF1+bXBw=="
},
"NodaTime": {
"type": "Direct",
Expand Down