Mayor code cleanup

Add Argument*Exceptions now use proper nameof operators.

Added exception messages to quite a few Argument*Exceptions.

Fixed rethorwing to be proper syntax.

Added a ton of null checkes. (This is only a start, there are about 500 places that need proper null handling)

Added some TODOs to log certain exceptions.

Fix sln again.

Fixed all AssemblyInfo's and added proper copyright (where I could find them)

We live in *current year*.

Fixed the use of braces.

Fixed a ton of properties, and made a fair amount of functions static that should be and can be static.

Made more Methods that should be static static.

You can now use static to find bad functions!

Removed unused variable. And added one more proper XML comment.
This commit is contained in:
Erwin de Haan
2019-01-06 21:50:43 +01:00
parent 3d867c2c46
commit ec1f5dc317
334 changed files with 1632 additions and 2603 deletions

View File

@@ -101,14 +101,10 @@ namespace UniversalDetector
base.Reset();
}
public string Charset {
get { return charset; }
}
public string Charset => charset;
public float Confidence => confidence;
public float Confidence {
get { return confidence; }
}
protected override void Report(string charset, float confidence)
{
this.charset = charset;

View File

@@ -77,14 +77,8 @@ namespace UniversalDetector.Core
currentState = SMModel.START;
}
public int CurrentCharLen
{
get { return currentCharLen; }
}
public int CurrentCharLen => currentCharLen;
public string ModelName
{
get { return model.Name; }
}
public string ModelName => model.Name;
}
}

View File

@@ -55,18 +55,14 @@ namespace UniversalDetector.Core
private string name;
public string Name {
get { return name; }
}
public string Name => name;
private int classFactor;
public int ClassFactor {
get { return classFactor; }
}
public int ClassFactor => classFactor;
public SMModel(BitPackage classTable, int classFactor,
BitPackage stateTable, int[] charLenTable, String name)
BitPackage stateTable, int[] charLenTable, string name)
{
this.classTable = classTable;
this.classFactor = classFactor;

View File

@@ -52,29 +52,23 @@ namespace UniversalDetector.Core
// freqSeqs / totalSeqs
protected float typicalPositiveRatio;
public float TypicalPositiveRatio {
get { return typicalPositiveRatio; }
}
public float TypicalPositiveRatio => typicalPositiveRatio;
// not used
protected bool keepEnglishLetter;
public bool KeepEnglishLetter {
get { return keepEnglishLetter; }
}
protected String charsetName;
public bool KeepEnglishLetter => keepEnglishLetter;
protected string charsetName;
public string CharsetName => charsetName;
public string CharsetName {
get { return charsetName; }
}
public SequenceModel(
byte[] charToOrderMap,
byte[] precedenceMatrix,
float typicalPositiveRatio,
bool keepEnglishLetter,
String charsetName)
string charsetName)
{
this.charToOrderMap = charToOrderMap;
this.precedenceMatrix = precedenceMatrix;