Skip to content

Commit

Permalink
ref - Adjusted code for .NET 8.0
Browse files Browse the repository at this point in the history
---

Type: ref
Breaking: False
Doc Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Nov 25, 2023
1 parent af714db commit 84ebba3
Show file tree
Hide file tree
Showing 25 changed files with 347 additions and 347 deletions.
2 changes: 1 addition & 1 deletion VisualCard.ShowContacts/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ static void Main(string[] args)
android ? AndroidContactsDb.GetContactsFromDb(args[0]) :
mecard ? MeCard.GetContactsFromMeCardString(meCardString) :
CardTools.GetCardParsers(args[0]);
List<Card> Contacts = new();
List<Card> Contacts = [];

// Parse all contacts
foreach (BaseVcardParser ContactParser in ContactParsers)
Expand Down
240 changes: 120 additions & 120 deletions VisualCard.Tests/ContactData.cs

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions VisualCard.Tests/ContactParseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void GetCardParsersFromDifferentContacts(string cardText)
[TestCaseSource(typeof(ContactData), nameof(ContactData.remainingContacts))]
public void ParseDifferentContacts(string cardText)
{
List<BaseVcardParser> parsers = new();
List<BaseVcardParser> parsers = [];
Should.NotThrow(() => parsers = CardTools.GetCardParsersFromString(cardText));
foreach (BaseVcardParser parser in parsers)
Should.NotThrow(parser.Parse);
Expand All @@ -63,16 +63,16 @@ public void ParseDifferentContacts(string cardText)
[TestCaseSource(typeof(ContactData), nameof(ContactData.remainingContacts))]
public void ParseDifferentContactsAndTestEquality(string cardText)
{
List<BaseVcardParser> parsers = new();
List<Card> cards = new();
List<BaseVcardParser> parsers = [];
List<Card> cards = [];

// Parse the cards
Should.NotThrow(() => parsers = CardTools.GetCardParsersFromString(cardText));
foreach (BaseVcardParser parser in parsers)
cards.Add(Should.NotThrow(parser.Parse));

// Test equality with available data
List<bool> foundCards = new();
List<bool> foundCards = [];
foreach (Card card in cards)
{
bool found = false;
Expand All @@ -94,9 +94,9 @@ public void ParseDifferentContactsAndTestEquality(string cardText)
[TestCaseSource(typeof(ContactData), nameof(ContactData.remainingContacts))]
public void ParseDifferentContactsSaveToStringAndTestEquality(string cardText)
{
List<BaseVcardParser> parsers = new();
List<Card> cards = new();
List<Card> savedCards = new();
List<BaseVcardParser> parsers = [];
List<Card> cards = [];
List<Card> savedCards = [];

// Parse the cards
Should.NotThrow(() => parsers = CardTools.GetCardParsersFromString(cardText));
Expand All @@ -113,7 +113,7 @@ public void ParseDifferentContactsSaveToStringAndTestEquality(string cardText)
}

// Test equality with available data
List<bool> foundCards = new();
List<bool> foundCards = [];
foreach (Card card in savedCards)
{
bool found = false;
Expand All @@ -132,7 +132,7 @@ public void ParseDifferentContactsSaveToStringAndTestEquality(string cardText)
[TestCaseSource(typeof(ContactData), nameof(ContactData.vCardFromMeCardContacts))]
public void ParseAndCheckDifferentMeCardContacts((string, string) cardText)
{
List<BaseVcardParser> parsers = new();
List<BaseVcardParser> parsers = [];
Should.NotThrow(() => parsers = MeCard.GetContactsFromMeCardString(cardText.Item1));
Card card = default;
foreach (BaseVcardParser parser in parsers)
Expand All @@ -144,7 +144,7 @@ public void ParseAndCheckDifferentMeCardContacts((string, string) cardText)
[TestCaseSource(typeof(ContactData), nameof(ContactData.meCardContacts))]
public void ParseDifferentMeCardContacts(string cardText)
{
List<BaseVcardParser> parsers = new();
List<BaseVcardParser> parsers = [];
Should.NotThrow(() => parsers = MeCard.GetContactsFromMeCardString(cardText));
foreach (BaseVcardParser parser in parsers)
Should.NotThrow(parser.Parse);
Expand All @@ -154,16 +154,16 @@ public void ParseDifferentMeCardContacts(string cardText)
[TestCaseSource(typeof(ContactData), nameof(ContactData.meCardContacts))]
public void ParseDifferentMeCardContactsAndTestEquality(string cardText)
{
List<BaseVcardParser> parsers = new();
List<Card> cards = new();
List<BaseVcardParser> parsers = [];
List<Card> cards = [];

// Parse the cards
Should.NotThrow(() => parsers = MeCard.GetContactsFromMeCardString(cardText));
foreach (BaseVcardParser parser in parsers)
cards.Add(Should.NotThrow(parser.Parse));

// Test equality with available data
List<bool> foundCards = new();
List<bool> foundCards = [];
foreach (Card card in cards)
{
bool found = false;
Expand All @@ -182,9 +182,9 @@ public void ParseDifferentMeCardContactsAndTestEquality(string cardText)
[TestCaseSource(typeof(ContactData), nameof(ContactData.meCardContacts))]
public void ParseDifferentMeCardContactsSaveToStringAndTestEquality(string cardText)
{
List<BaseVcardParser> parsers = new();
List<Card> cards = new();
List<Card> savedCards = new();
List<BaseVcardParser> parsers = [];
List<Card> cards = [];
List<Card> savedCards = [];

// Parse the cards
Should.NotThrow(() => parsers = MeCard.GetContactsFromMeCardString(cardText));
Expand All @@ -201,7 +201,7 @@ public void ParseDifferentMeCardContactsSaveToStringAndTestEquality(string cardT
}

// Test equality with available data
List<bool> foundCards = new();
List<bool> foundCards = [];
foreach (Card card in savedCards)
{
bool found = false;
Expand All @@ -225,7 +225,7 @@ public void InvalidContactShouldThrowWhenGettingCardParsers(string cardText)
[TestCaseSource(typeof(ContactDataBogus), nameof(ContactDataBogus.invalidContactsParser))]
public void InvalidContactShouldThrowWhenParsing(string cardText)
{
List<BaseVcardParser> parsers = new();
List<BaseVcardParser> parsers = [];
Should.NotThrow(() => parsers = CardTools.GetCardParsersFromString(cardText));
foreach (BaseVcardParser parser in parsers)
Should.Throw<InvalidDataException>(parser.Parse);
Expand All @@ -240,7 +240,7 @@ public void BogusButSeemsValidShouldNotThrowWhenGettingCardParsers(string cardTe
[TestCaseSource(typeof(ContactDataBogus), nameof(ContactDataBogus.seemsValidContacts))]
public void BogusButSeemsValidShouldNotThrowWhenParsing(string cardText)
{
List<BaseVcardParser> parsers = new();
List<BaseVcardParser> parsers = [];
Should.NotThrow(() => parsers = CardTools.GetCardParsersFromString(cardText));
foreach (BaseVcardParser parser in parsers)
Should.NotThrow(parser.Parse);
Expand Down
2 changes: 1 addition & 1 deletion VisualCard/CardTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static List<BaseVcardParser> GetCardParsers(string Path)
public static List<BaseVcardParser> GetCardParsers(StreamReader stream)
{
// Variables and flags
List<BaseVcardParser> FinalParsers = new();
List<BaseVcardParser> FinalParsers = [];
bool BeginSpotted = false;
bool VersionSpotted = false;
bool EndSpotted = false;
Expand Down
2 changes: 1 addition & 1 deletion VisualCard/Converters/AndroidContactsDb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static List<BaseVcardParser> GetContactsFromDb(string pathToDb)
"folder, for example, /data/user/0/com.motorola.blur.providers.contacts/databases/.";
if (!File.Exists(pathToDb))
throw new FileNotFoundException("The Android contact database file obtained from the contact provider is not found." + dbObtainTip);
List<BaseVcardParser> cardParsers = new();
List<BaseVcardParser> cardParsers = [];

try
{
Expand Down
66 changes: 33 additions & 33 deletions VisualCard/Parsers/Four/VcardFour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,22 @@ public override Card Parse()
string _caladrUri = "";
DateTime _rev = DateTime.MinValue;
DateTime _bday = DateTime.MinValue;
List<NameInfo> _names = new();
List<TelephoneInfo> _telephones = new();
List<EmailInfo> _emails = new();
List<AddressInfo> _addresses = new();
List<OrganizationInfo> _orgs = new();
List<TitleInfo> _titles = new();
List<LogoInfo> _logos = new();
List<PhotoInfo> _photos = new();
List<SoundInfo> _sounds = new();
List<NicknameInfo> _nicks = new();
List<RoleInfo> _roles = new();
List<string> _categories = new();
List<TimeZoneInfo> _timezones = new();
List<GeoInfo> _geos = new();
List<ImppInfo> _impps = new();
List<XNameInfo> _xes = new();
List<NameInfo> _names = [];
List<TelephoneInfo> _telephones = [];
List<EmailInfo> _emails = [];
List<AddressInfo> _addresses = [];
List<OrganizationInfo> _orgs = [];
List<TitleInfo> _titles = [];
List<LogoInfo> _logos = [];
List<PhotoInfo> _photos = [];
List<SoundInfo> _sounds = [];
List<NicknameInfo> _nicks = [];
List<RoleInfo> _roles = [];
List<string> _categories = [];
List<TimeZoneInfo> _timezones = [];
List<GeoInfo> _geos = [];
List<ImppInfo> _impps = [];
List<XNameInfo> _xes = [];

// Full Name specifier is required
bool fullNameSpecifierSpotted = false;
Expand Down Expand Up @@ -120,7 +120,7 @@ public override Card Parse()
string[] splitArgs = splitValueParts[0].Split(VcardConstants._fieldDelimiter);
splitArgs = splitArgs.Except(new string[] { splitArgs[0] }).ToArray();
string[] splitValues = splitValueParts[1].Split(VcardConstants._fieldDelimiter);
List<string> finalArgs = new();
List<string> finalArgs = [];
int altId = 0;

if (splitArgs.Length > 0)
Expand Down Expand Up @@ -500,29 +500,29 @@ public override Card Parse()
return new Card(this, CardVersion, _kind)
{
CardRevision = _rev,
ContactNames = _names.ToArray(),
ContactNames = [.. _names],
ContactFullName = _fullName,
ContactTelephones = _telephones.ToArray(),
ContactAddresses = _addresses.ToArray(),
ContactOrganizations = _orgs.ToArray(),
ContactTitles = _titles.ToArray(),
ContactTelephones = [.. _telephones],
ContactAddresses = [.. _addresses],
ContactOrganizations = [.. _orgs],
ContactTitles = [.. _titles],
ContactURL = _url,
ContactNotes = _note,
ContactMails = _emails.ToArray(),
ContactXNames = _xes.ToArray(),
ContactPhotos = _photos.ToArray(),
ContactNicknames = _nicks.ToArray(),
ContactMails = [.. _emails],
ContactXNames = [.. _xes],
ContactPhotos = [.. _photos],
ContactNicknames = [.. _nicks],
ContactBirthdate = _bday,
ContactMailer = "",
ContactRoles = _roles.ToArray(),
ContactCategories = _categories.ToArray(),
ContactLogos = _logos.ToArray(),
ContactRoles = [.. _roles],
ContactCategories = [.. _categories],
ContactLogos = [.. _logos],
ContactProdId = _prodId,
ContactSortString = _sortString,
ContactTimeZone = _timezones.ToArray(),
ContactGeo = _geos.ToArray(),
ContactSounds = _sounds.ToArray(),
ContactImpps = _impps.ToArray(),
ContactTimeZone = [.. _timezones],
ContactGeo = [.. _geos],
ContactSounds = [.. _sounds],
ContactImpps = [.. _impps],
ContactSource = _source,
ContactXml = _xml,
ContactFreeBusyUrl = _fbUrl,
Expand Down
68 changes: 34 additions & 34 deletions VisualCard/Parsers/Three/VcardThree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,23 +72,23 @@ public override Card Parse()
string _class = "";
DateTime _rev = DateTime.MinValue;
DateTime _bday = DateTime.MinValue;
List<NameInfo> _names = new();
List<TelephoneInfo> _telephones = new();
List<EmailInfo> _emails = new();
List<AddressInfo> _addresses = new();
List<LabelAddressInfo> _labels = new();
List<OrganizationInfo> _orgs = new();
List<TitleInfo> _titles = new();
List<PhotoInfo> _photos = new();
List<LogoInfo> _logos = new();
List<SoundInfo> _sounds = new();
List<NicknameInfo> _nicks = new();
List<RoleInfo> _roles = new();
List<string> _categories = new();
List<TimeZoneInfo> _timezones = new();
List<GeoInfo> _geos = new();
List<ImppInfo> _impps = new();
List<XNameInfo> _xes = new();
List<NameInfo> _names = [];
List<TelephoneInfo> _telephones = [];
List<EmailInfo> _emails = [];
List<AddressInfo> _addresses = [];
List<LabelAddressInfo> _labels = [];
List<OrganizationInfo> _orgs = [];
List<TitleInfo> _titles = [];
List<PhotoInfo> _photos = [];
List<LogoInfo> _logos = [];
List<SoundInfo> _sounds = [];
List<NicknameInfo> _nicks = [];
List<RoleInfo> _roles = [];
List<string> _categories = [];
List<TimeZoneInfo> _timezones = [];
List<GeoInfo> _geos = [];
List<ImppInfo> _impps = [];
List<XNameInfo> _xes = [];

// Name and Full Name specifiers are required
bool nameSpecifierSpotted = false;
Expand Down Expand Up @@ -393,30 +393,30 @@ public override Card Parse()
return new Card(this, CardVersion, "individual")
{
CardRevision = _rev,
ContactNames = _names.ToArray(),
ContactNames = [.. _names],
ContactFullName = _fullName,
ContactTelephones = _telephones.ToArray(),
ContactAddresses = _addresses.ToArray(),
ContactLabels = _labels.ToArray(),
ContactOrganizations = _orgs.ToArray(),
ContactTitles = _titles.ToArray(),
ContactTelephones = [.. _telephones],
ContactAddresses = [.. _addresses],
ContactLabels = [.. _labels],
ContactOrganizations = [.. _orgs],
ContactTitles = [.. _titles],
ContactURL = _url,
ContactNotes = _note,
ContactMails = _emails.ToArray(),
ContactXNames = _xes.ToArray(),
ContactPhotos = _photos.ToArray(),
ContactNicknames = _nicks.ToArray(),
ContactMails = [.. _emails],
ContactXNames = [.. _xes],
ContactPhotos = [.. _photos],
ContactNicknames = [.. _nicks],
ContactBirthdate = _bday,
ContactMailer = _mailer,
ContactRoles = _roles.ToArray(),
ContactCategories = _categories.ToArray(),
ContactLogos = _logos.ToArray(),
ContactRoles = [.. _roles],
ContactCategories = [.. _categories],
ContactLogos = [.. _logos],
ContactProdId = _prodId,
ContactSortString = _sortString,
ContactTimeZone = _timezones.ToArray(),
ContactGeo = _geos.ToArray(),
ContactSounds = _sounds.ToArray(),
ContactImpps = _impps.ToArray(),
ContactTimeZone = [.. _timezones],
ContactGeo = [.. _geos],
ContactSounds = [.. _sounds],
ContactImpps = [.. _impps],
ContactSource = _source,
ContactXml = "",
ContactFreeBusyUrl = "",
Expand Down
Loading

0 comments on commit 84ebba3

Please sign in to comment.