Skip to content

Commit

Permalink
chore(csvHelper): upgrade CSVHelper library to latest version 33.0.1 (#…
Browse files Browse the repository at this point in the history
…169)

chore(runtime): upgrade project to VS2022 / .NET 4.8
chore(build): removed post build task to merge in library dependencies.

Co-authored-by: Damien Haynes <[email protected]>
  • Loading branch information
damienhaynes and Damien Haynes authored Aug 25, 2024
1 parent 8b86b37 commit 444a20f
Show file tree
Hide file tree
Showing 24 changed files with 218 additions and 227 deletions.
40 changes: 4 additions & 36 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,7 @@
*.pdb
*.suo
.vs
/obj/x86/Release/DesignTimeResolveAssemblyReferences.cache
/obj/x86/Release/DesignTimeResolveAssemblyReferencesInput.cache
/obj/x86/Release/TempPE/Properties.Resources.Designer.cs.dll
/obj/x86/Release/TraktRater.Properties.Resources.resources
/obj/x86/Release/TraktRater.TraktRater.resources
/obj/x86/Release/TraktRater.UI.MaintenanceDialog.resources
/obj/x86/Release/TraktRater.csproj.FileListAbsolute.txt
/obj/x86/Release/TraktRater.csproj.GenerateResource.Cache
/obj/x86/Release/TraktRater.csprojResolveAssemblyReference.cache
/bin/Release/*.zip
obj
/app.config
/bin/Debug/CsvHelper.dll
/bin/Debug/CsvHelper.xml
/bin/Debug/TraktRater.exe.config
/bin/Debug/TraktRater.vshost.exe.config
/bin/Debug/merge.bat
/bin/Release/CsvHelper.dll
/bin/Release/CsvHelper.xml
/bin/Release/TraktRater.exe.config
/bin/Release/TraktRater.vshost.exe.config
/bin/Release/merge.bat
/packages/CsvHelper.2.16.3.0/CsvHelper.2.16.3.0.nupkg
/packages/CsvHelper.2.16.3.0/lib/net20/CsvHelper.dll
/packages/CsvHelper.2.16.3.0/lib/net20/CsvHelper.xml
/packages/CsvHelper.2.16.3.0/lib/net35/CsvHelper.dll
/packages/CsvHelper.2.16.3.0/lib/net35/CsvHelper.xml
/packages/CsvHelper.2.16.3.0/lib/net40/CsvHelper.dll
/packages/CsvHelper.2.16.3.0/lib/net40/CsvHelper.xml
/packages/CsvHelper.2.16.3.0/lib/net45/CsvHelper.dll
/packages/CsvHelper.2.16.3.0/lib/net45/CsvHelper.xml
/packages/CsvHelper.2.16.3.0/lib/netstandard1.3/CsvHelper.dll
/packages/CsvHelper.2.16.3.0/lib/netstandard1.3/CsvHelper.xml
/packages/CsvHelper.2.16.3.0/lib/portable40-net40+sl5+win8+wp8+wpa81/CsvHelper.dll
/packages/CsvHelper.2.16.3.0/lib/portable40-net40+sl5+win8+wp8+wpa81/CsvHelper.xml
/packages/CsvHelper.2.16.3.0/.signature.p7s
/obj
/packages
/bin/Debug
/bin/Release
2 changes: 1 addition & 1 deletion Export.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,7 @@ private static void WriteToCsv(string filename, List<object> records)
Directory.CreateDirectory(directory);

using (var writer = new StreamWriter(filename))
using (var csv = new CsvWriter(writer))
using (var csv = new CsvWriter(writer, new System.Globalization.CultureInfo("en-US")))
{
csv.WriteRecords(records);
}
Expand Down
4 changes: 2 additions & 2 deletions Logger/FileLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

internal static class FileLog
{
private static Object lockObject = new object();
private static readonly object mLockObject = new object();

internal static readonly string LogDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"TraktRater", @"Logs");
internal static string LogFileName { private get; set; }
Expand Down Expand Up @@ -106,7 +106,7 @@ private static void WriteToFile(String log)

try
{
lock (lockObject)
lock (mLockObject)
{
StreamWriter sw = File.AppendText(filename);
sw.WriteLine(log);
Expand Down
126 changes: 63 additions & 63 deletions Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Sites/API/Criticker/CritickerItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace TraktRater.Sites.API.Criticker
{
sealed class CSVFileDefinitionMap : CsvClassMap<CritickerItem>
sealed class CSVFileDefinitionMap : ClassMap<CritickerItem>
{
public CSVFileDefinitionMap()
{
Expand Down
5 changes: 2 additions & 3 deletions Sites/API/IMDb/IMDbRateItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using global::TraktRater.TraktAPI.DataStructures;
using System;

sealed class IMDbRatingCsvMap : CsvClassMap<IMDbRateItem>
sealed class IMDbRatingCsvMap : ClassMap<IMDbRateItem>
{
public IMDbRatingCsvMap()
{
Expand Down Expand Up @@ -95,13 +95,12 @@ public TraktMovieWatched ToTraktWatchedMovie()

private string GetFormattedDate(string imdbDateTime)
{
DateTime result;
string createdDate = DateTime.Now.ToString().ToISO8601();

if (!string.IsNullOrEmpty(imdbDateTime))
{
// date is in the form 'YYYY-MM-DD' (but no guarantee for other locales)
if (DateTime.TryParse(imdbDateTime, out result))
if (DateTime.TryParse(imdbDateTime, out DateTime result))
{
createdDate = result.ToString().ToISO8601();
}
Expand Down
2 changes: 1 addition & 1 deletion Sites/API/IMDb/IMDbWatchlistItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using CsvHelper.Configuration;
using global::TraktRater.TraktAPI.DataStructures;

sealed class IMDbListCsvMap : CsvClassMap<IMDbListItem>
sealed class IMDbListCsvMap : ClassMap<IMDbListItem>
{
public IMDbListCsvMap()
{
Expand Down
2 changes: 1 addition & 1 deletion Sites/API/Letterboxd/LetterboxdListItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using CsvHelper.Configuration;
using global::TraktRater.TraktAPI.DataStructures;

sealed class LetterboxdListCsvMap : CsvClassMap<LetterboxdListItem>
sealed class LetterboxdListCsvMap : ClassMap<LetterboxdListItem>
{
public LetterboxdListCsvMap()
{
Expand Down
2 changes: 1 addition & 1 deletion Sites/API/MovieLens/MovieLensActivityItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace TraktRater.Sites.API.MovieLens
{
sealed class CSVActivityFileDefinitionMap : CsvClassMap<MovieLensActivityItem>
sealed class CSVActivityFileDefinitionMap : ClassMap<MovieLensActivityItem>
{
public CSVActivityFileDefinitionMap()
{
Expand Down
2 changes: 1 addition & 1 deletion Sites/API/MovieLens/MovieLensRatingItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace TraktRater.Sites.API.MovieLens
{
sealed class CSVRatingsFileDefinitionMap : CsvClassMap<MovieLensRatingItem>
sealed class CSVRatingsFileDefinitionMap : ClassMap<MovieLensRatingItem>
{
public CSVRatingsFileDefinitionMap()
{
Expand Down
4 changes: 1 addition & 3 deletions Sites/API/MovieLens/MovieLensWishlistItem.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using CsvHelper.Configuration;
using System;
using TraktRater.Extensions;
using TraktRater.TraktAPI.DataStructures;

namespace TraktRater.Sites.API.MovieLens
{
sealed class CSVWishlistFileDefinitionMap : CsvClassMap<MovieLensWishlistItem>
sealed class CSVWishlistFileDefinitionMap : ClassMap<MovieLensWishlistItem>
{
public CSVWishlistFileDefinitionMap()
{
Expand Down
2 changes: 1 addition & 1 deletion Sites/API/ToDoMovies/ToDoMoviesListItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace TraktRater.Sites.API.ToDoMovies
{
sealed class CSVFileDefinitionMap : CsvClassMap<ToDoMoviesListItem>
sealed class CSVFileDefinitionMap : ClassMap<ToDoMoviesListItem>
{
public CSVFileDefinitionMap()
{
Expand Down
8 changes: 4 additions & 4 deletions Sites/CheckMovies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ namespace TraktRater.Sites
{
internal class CheckMovies : IRateSite
{
private string CheckMoviesFilename;
private int DelimiterOption;
private bool ImportCancelled;
private readonly CsvConfiguration csvConfiguration = new CsvConfiguration()
private readonly string CheckMoviesFilename;
private readonly int DelimiterOption;

private readonly CsvConfiguration csvConfiguration = new CsvConfiguration(System.Globalization.CultureInfo.InvariantCulture)
{
HasHeaderRecord = true,
IsHeaderCaseSensitive = false
};

public CheckMovies(string checkMoviesFilename, int delimiter)
Expand Down
6 changes: 2 additions & 4 deletions Sites/Common/IMDbHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,7 @@ public static IMDbEpisode GetIMDbEpisodeFromTVDb(Dictionary<string, string> epis
// we can also lookup by airDate if using a csv export file
if (episode[IMDbFieldMapping.cProvider].IsCSVExport())
{
string episodeAirDate = null;
episode.TryGetValue(IMDbFieldMapping.cReleaseDate, out episodeAirDate);
episode.TryGetValue(IMDbFieldMapping.cReleaseDate, out string episodeAirDate);
if (!string.IsNullOrEmpty(episodeAirDate))
{
tvdbEpisodeInfo = tvdbShowInfo.Episodes.Find(e => e.AirDate == episodeAirDate);
Expand Down Expand Up @@ -507,13 +506,12 @@ static string GetLastCreatedDate(Dictionary<string, string> item)

static string GetLastCreatedDate(string imdbDateTime)
{
DateTime result;
string createdDate = DateTime.Now.ToString().ToISO8601();

if (!string.IsNullOrEmpty(imdbDateTime))
{
// date is in the form 'YYYY-MM-DD' (but no guarantee for other locales)
if (DateTime.TryParse(imdbDateTime, out result))
if (DateTime.TryParse(imdbDateTime, out DateTime result))
{
createdDate = result.ToString().ToISO8601();
}
Expand Down
8 changes: 4 additions & 4 deletions Sites/Criticker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using global::TraktRater.TraktAPI.DataStructures;
using global::TraktRater.UI;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;
Expand All @@ -15,9 +16,9 @@ public class Criticker : IRateSite
{
#region Variables

private string CritickerFilename;
private bool ImportCancelled;
private readonly CsvConfiguration csvConfiguration = new CsvConfiguration();
private readonly string CritickerFilename;
private readonly CsvConfiguration csvConfiguration = new CsvConfiguration(CultureInfo.InvariantCulture);

#endregion

Expand Down Expand Up @@ -254,12 +255,11 @@ private void HandleShowResponse(TraktSyncResponse response)

private List<CritickerItem> ParseCritickerCsv()
{
csvConfiguration.RegisterClassMap<CSVFileDefinitionMap>();

UIUtils.UpdateStatus("Parsing Criticker CSV file");
var textReader = File.OpenText(CritickerFilename);

var csv = new CsvReader(textReader, csvConfiguration);
csv.Context.RegisterClassMap<CSVFileDefinitionMap>();
return csv.GetRecords<CritickerItem>().ToList();
}

Expand Down
Loading

0 comments on commit 444a20f

Please sign in to comment.