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
11 changes: 6 additions & 5 deletions UtilitiesCS/EmailIntelligence/Ctf/CtfIncidence.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#nullable enable
using System;
using System.Collections.Generic;

namespace UtilitiesCS
Expand Down Expand Up @@ -28,11 +29,11 @@ List<int> emailConversationCount
{
EmailConversationID = emailConversationID;
FolderCount = folderCount;
EmailFolders = emailFolder;
EmailCounts = emailConversationCount;
_emailFolders = emailFolder;
_emailCounts = emailConversationCount;
}

private string _emailConversationID;
private string? _emailConversationID;
private int _folderCount;
private List<string> _emailFolders;
private List<int> _emailCounts;
Expand All @@ -44,7 +45,7 @@ public int MaxFoldersPerConv
set => _maxFoldersPerConv = value;
}

public string EmailConversationID
public string? EmailConversationID
{
get => _emailConversationID;
set => _emailConversationID = value;
Expand Down
15 changes: 8 additions & 7 deletions UtilitiesCS/EmailIntelligence/Ctf/CtfIncidenceList.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#nullable enable
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
Expand Down Expand Up @@ -84,7 +85,7 @@ public void CtfIncidencePositionAdd(int idx, CtfMapEntry CtfMap)
this[idx].EmailFolders[j + 1] = this[idx].EmailFolders[j];
}
this[idx].EmailCounts[i] = CtfMap.EmailCount;
this[idx].EmailFolders[i] = CtfMap.EmailFolder;
this[idx].EmailFolders[i] = CtfMap.EmailFolder!;
added = true;
break;
}
Expand All @@ -95,7 +96,7 @@ public void CtfIncidencePositionAdd(int idx, CtfMapEntry CtfMap)
if (CtfMap.EmailCount > this[idx].EmailCounts[_maxFoldersPerConv])
{
this[idx].EmailCounts[_maxFoldersPerConv] = CtfMap.EmailCount;
this[idx].EmailFolders[_maxFoldersPerConv] = CtfMap.EmailFolder;
this[idx].EmailFolders[_maxFoldersPerConv] = CtfMap.EmailFolder!;
}
}
}
Expand Down Expand Up @@ -150,7 +151,7 @@ CtfMapEntry Map
this[Inc_Num].FolderCount = Folder_Count;
this[Inc_Num].EmailConversationID = Map.ConversationID;
this[Inc_Num].EmailCounts[Inc_Position] = Map.EmailCount;
this[Inc_Num].EmailFolders[Inc_Position] = Map.EmailFolder;
this[Inc_Num].EmailFolders[Inc_Position] = Map.EmailFolder!;
}

#region "Backup Loader and Writer"
Expand Down Expand Up @@ -178,7 +179,7 @@ public void CTF_Incidence_Text_File_WRITE(string folderpath, string filename)
var loopTo = CTF_Inc_Ct;
for (i = 1; i <= loopTo; i++)
{
listOutput.Add(this[i].EmailConversationID);
listOutput.Add(this[i].EmailConversationID!);
listOutput.Add(this[i].FolderCount.ToString());
var loopTo1 = this[i].FolderCount;
for (j = 1; j <= loopTo1; j++)
Expand Down Expand Up @@ -221,7 +222,7 @@ public static IList<CtfIncidence> ProcessQueue(Queue<string> lines)
return listCTF;
}

public static CtfIncidence TryDequeueIncidence(ref Queue<string> lines)
public static CtfIncidence? TryDequeueIncidence(ref Queue<string> lines)
{
var incidence = new CtfIncidence();
try
Expand Down Expand Up @@ -292,7 +293,7 @@ internal static Queue<string> ArrayToQueue(string[] array)
internal static string[] ReadFileToArray(string filepath)
{
//QUESTION: Is ReadFileToArray method duplicative of read csv? Should it be moved to a common location?
string[] filecontents = null;
string[]? filecontents = null;
try
{
filecontents = File.ReadAllLines(filepath, System.Text.Encoding.ASCII);
Expand Down
7 changes: 4 additions & 3 deletions UtilitiesCS/EmailIntelligence/Ctf/CtfMap.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#nullable enable
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
Expand Down Expand Up @@ -105,7 +106,7 @@ public static IList<CtfMapEntry> ProcessQueue(Queue<string> lines)
return listCTF;
}

public static CtfMapEntry TryDequeueEntry(ref Queue<string> lines)
public static CtfMapEntry? TryDequeueEntry(ref Queue<string> lines)
{
var entry = new CtfMapEntry();
try
Expand Down Expand Up @@ -190,7 +191,7 @@ private static Queue<string> ArrayToQueue(string[] array)
private static string[] ReadFileToArray(string filepath)
{
//QUESTION: Is ReadFileToArray method duplicative of read csv? Should it be moved to a common location?
string[] filecontents = null;
string[]? filecontents = null;
try
{
filecontents = File.ReadAllLines(filepath, System.Text.Encoding.ASCII);
Expand Down
11 changes: 6 additions & 5 deletions UtilitiesCS/EmailIntelligence/Ctf/CtfMapEntry.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace UtilitiesCS
#nullable enable
namespace UtilitiesCS
{
public class CtfMapEntry
{
Expand All @@ -11,17 +12,17 @@ public CtfMapEntry(string emailFolder, string conversationID, int emailCount)
_emailCount = emailCount;
}

private string _emailFolder;
private string _conversationID;
private string? _emailFolder;
private string? _conversationID;
private int _emailCount;

public string EmailFolder
public string? EmailFolder
{
get => _emailFolder;
set => _emailFolder = value;
}

public string ConversationID
public string? ConversationID
{
get => _conversationID;
set => _conversationID = value;
Expand Down
5 changes: 3 additions & 2 deletions UtilitiesCS/EmailIntelligence/EmailParsingSorting/AutoFile.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#nullable enable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand Down Expand Up @@ -142,7 +143,7 @@ private static bool Category_IsAlreadySelected(dynamic objItem, string strCat)
bool blSelected;

blSelected = false;
string[] varCats = (objItem.Categories as string).Split(',', trim: true);
string[] varCats = (objItem.Categories as string)!.Split(',', trim: true);
var loopTo = varCats.Length;
for (i = 0; i < loopTo; i++)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#nullable enable
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
Expand Down Expand Up @@ -34,7 +35,7 @@ internal virtual FolderTree GetOlFolderTree()
}

[ExcludeFromCodeCoverage]
internal virtual FolderTree GetOlFolderTree(ProgressTracker progress)
internal virtual FolderTree GetOlFolderTree(ProgressTracker? progress)
{
var snapshot = GetOlFolderSnapshotAsync(progress).GetAwaiter().GetResult();
var selectionOverlay = new FolderTreeSelectionOverlay(
Expand Down Expand Up @@ -73,14 +74,14 @@ internal virtual IEnumerable<FolderWrapper> QueryOlFolderInfo(FolderTree tree)
}

internal virtual async Task<FolderTreeSnapshot> GetOlFolderSnapshotAsync(
ProgressTracker progress = null
ProgressTracker? progress = null
)
{
progress?.Report(0, "Getting cached folders");
var archiveRoot = _globals.Ol.ArchiveRoot;
var request = string.IsNullOrWhiteSpace(archiveRoot?.StoreID)
? FolderTreeRequest.AllStores(allowStaleSnapshot: true)
: FolderTreeRequest.ForStore(archiveRoot.StoreID, allowStaleSnapshot: true);
: FolderTreeRequest.ForStore(archiveRoot!.StoreID, allowStaleSnapshot: true);
var snapshot = await _globals
.Ol.FolderTreeService.GetSnapshotAsync(request, CancellationToken.None)
.ConfigureAwait(false);
Expand Down Expand Up @@ -127,7 +128,7 @@ internal async Task<FolderWrapper[]> GetInitializedFolderInfo()
{
var (tokenSource, cancel, progress, sw) = await ProgressPackage.CreateAsTupleAsync();
//screen: _globals.Ol.GetExplorerScreen());
FolderWrapper[] folders = null;
FolderWrapper[]? folders = null;

progress.Report(0, "Getting Folders");
var snapshot = await GetOlFolderSnapshotAsync(progress).ConfigureAwait(false);
Expand Down Expand Up @@ -160,7 +161,7 @@ internal FolderStruct[] AddRollingMeasures(long maxChunkSize, FolderWrapper[] fo
{
var folderRecords = folders
.Scan(
new FolderStruct(default(FolderWrapper), 0L, 0L, 0),
new FolderStruct(default(FolderWrapper)!, 0L, 0L, 0),
(current, next) =>
new FolderStruct
{
Expand Down Expand Up @@ -265,7 +266,7 @@ internal static bool TryResolveMapiHandles(FolderTree tree, FolderWrapper[] fold

var handles = tree.Roots.SelectMany(root => root.Flatten()).ToList();
int last = -1;
FolderWrapper handle = null;
FolderWrapper? handle = null;

foreach (var folder in folders)
{
Expand Down Expand Up @@ -309,7 +310,7 @@ internal static bool TryResolveMapiHandles(FolderTree tree, FolderWrapper[] fold
internal async Task<FolderWrapper[][]> ExtractOlFolderChunks(bool reload = false)
{
// Grab selected OlFolderInfo objects from a OlFolderTree, flatten to an array, and initialize
FolderWrapper[] folders = null;
FolderWrapper[]? folders = null;
if (!reload)
{
folders = Deserialize<FolderWrapper[]>("StagingFolderRecords");
Expand Down Expand Up @@ -420,10 +421,10 @@ ProgressTracker progress
)
{
var prelimCount = folders.Select(folder => folder.Items.Count).Sum();
_sw.LogDuration("Get Preliminary Count");
_sw!.LogDuration("Get Preliminary Count");

var mailList = mailItems.ToList(prelimCount, progress);
_sw.LogDuration("Load MailItems");
_sw!.LogDuration("Load MailItems");

return mailList;
}
Expand All @@ -446,31 +447,31 @@ ProgressTracker progress
internal IEnumerable<MailItem> ScrapeEmailsCore()
{
var snapshot = GetOlFolderSnapshotAsync().GetAwaiter().GetResult();
_sw.LogDuration(nameof(GetOlFolderSnapshotAsync));
_sw!.LogDuration(nameof(GetOlFolderSnapshotAsync));

var folders = QueryOlFolders(snapshot);
_sw.LogDuration(nameof(QueryOlFolders));
_sw!.LogDuration(nameof(QueryOlFolders));

var mailItemsQuery = QueryMailItems(folders);
_sw.LogDuration(nameof(QueryMailItems));
_sw!.LogDuration(nameof(QueryMailItems));

_sw.WriteToLog(clear: false);
_sw!.WriteToLog(clear: false);
return mailItemsQuery;
}

internal IEnumerable<MailItem> ScrapeEmailsCore(ProgressTracker progress)
{
progress.Report(0, "Building Outlook Folder Tree");
var snapshot = GetOlFolderSnapshotAsync(progress).GetAwaiter().GetResult();
_sw.LogDuration(nameof(GetOlFolderSnapshotAsync));
_sw!.LogDuration(nameof(GetOlFolderSnapshotAsync));

var folders = QueryOlFolders(snapshot);
_sw.LogDuration(nameof(QueryOlFolders));
_sw!.LogDuration(nameof(QueryOlFolders));

var mailItemsQuery = QueryMailItems(folders);
_sw.LogDuration(nameof(QueryMailItems));
_sw!.LogDuration(nameof(QueryMailItems));

_sw.WriteToLog(clear: false);
_sw!.WriteToLog(clear: false);
return mailItemsQuery;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#nullable enable
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
Expand All @@ -14,7 +15,7 @@ public partial class EmailDataMiner
{
#region Testing Sizing and Serialization Methods

internal virtual T Deserialize<T>(string fileNameSeed, string fileNameSuffix = "")
internal virtual T? Deserialize<T>(string fileNameSeed, string fileNameSuffix = "")
{
if (!_globals.FS.SpecialFolders.TryGetValue("AppData", out var folderRoot))
{
Expand All @@ -33,7 +34,7 @@ internal virtual T Deserialize<T>(string fileNameSeed, string fileNameSuffix = "
);
}

internal static T DeserializeFromFolder<T>(
internal static T? DeserializeFromFolder<T>(
string folderPath,
string fileNameSeed,
string fileNameSuffix,
Expand Down Expand Up @@ -62,7 +63,7 @@ Func<string, string> readAllText
return default(T);
}

internal static async Task<T> DeserializeAsync<T>(
internal static async Task<T?> DeserializeAsync<T>(
string folderPath,
string fileNameSeed,
string fileNameSuffix = ""
Expand All @@ -77,7 +78,7 @@ internal static async Task<T> DeserializeAsync<T>(
);
}

internal static async Task<T> DeserializeAsync<T>(
internal static async Task<T?> DeserializeAsync<T>(
string folderPath,
string fileNameSeed,
string fileNameSuffix,
Expand Down Expand Up @@ -265,7 +266,7 @@ internal virtual void SerializeMailInfo(MailItem mailItem)
SerializeFsSave(mailInfo, "MailItemInfo", serializer, disk);

var (minedInfo, sizeMinedInfo1) = TryLoadObjectAndGetMemorySize(() =>
new MinedMailInfo(mailInfo)
new MinedMailInfo(mailInfo!)
);
var sizeMinedInfo2 = 0; // ObjectSize(minedInfo);
LogSizeComparison(
Expand All @@ -278,7 +279,7 @@ internal virtual void SerializeMailInfo(MailItem mailItem)
SerializeFsSave(minedInfo, "MinedMailInfo", serializer, disk);
}

internal virtual (T Object, long Size) TryLoadObjectAndGetMemorySize<T>(
internal virtual (T? Object, long Size) TryLoadObjectAndGetMemorySize<T>(
Func<T> loader,
int copiesToLoad = 1
)
Expand Down Expand Up @@ -371,7 +372,11 @@ public virtual async Task<bool> ValidateJson<T>(
return false;
}
var folderPath = Path.Combine(folderRoot, "Bayesian");
T obj = await DeserializeForValidation<T>(folderPath, fileNameSeed, fileNameSuffix);
T? obj = await DeserializeForValidation<T>(
folderPath,
fileNameSeed,
fileNameSuffix
);
if (obj != null)
return true;
else
Expand All @@ -390,7 +395,7 @@ public virtual async Task<bool> ValidateJson<T>(
}
}

internal virtual Task<T> DeserializeForValidation<T>(
internal virtual Task<T?> DeserializeForValidation<T>(
string folderPath,
string fileNameSeed,
string fileNameSuffix = ""
Expand Down
Loading