Skip to content

Commit

Permalink
Remove Debug.Asserts
Browse files Browse the repository at this point in the history
TODO: Create an issue to remove !
  • Loading branch information
maxkoshevoi committed Aug 25, 2021
1 parent e7ac46c commit 57dee24
Showing 1 changed file with 11 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -358,10 +358,7 @@ private List<Target> ReadTargets(ref Utf8JsonReader reader)

while (reader.Read() && reader.IsTokenTypeProperty())
{
string? targetName = reader.GetString();
Debug.Assert(targetName != null);

targets.Add(ReadTarget(ref reader, targetName));
targets.Add(ReadTarget(ref reader, reader.GetString()!));
}

reader.CheckEndObject();
Expand All @@ -377,10 +374,7 @@ private Target ReadTarget(ref Utf8JsonReader reader, string targetName)

while (reader.Read() && reader.IsTokenTypeProperty())
{
string? targetLibraryName = reader.GetString();
Debug.Assert(targetLibraryName != null);

libraries.Add(ReadTargetLibrary(ref reader, targetLibraryName));
libraries.Add(ReadTargetLibrary(ref reader, reader.GetString()!));
}

reader.CheckEndObject();
Expand Down Expand Up @@ -454,9 +448,7 @@ private IEnumerable<Dependency> ReadTargetLibraryDependencies(ref Utf8JsonReader

while (reader.TryReadStringProperty(out string? name, out string? version))
{
Debug.Assert(name != null);
Debug.Assert(version != null);
dependencies.Add(new Dependency(Pool(name), Pool(version)));
dependencies.Add(new Dependency(Pool(name)!, Pool(version)!));
}

reader.CheckEndObject();
Expand All @@ -472,8 +464,7 @@ private static List<string> ReadPropertyNames(ref Utf8JsonReader reader)

while (reader.Read() && reader.IsTokenTypeProperty())
{
string? libraryName = reader.GetString();
Debug.Assert(libraryName != null);
string? libraryName = reader.GetString()!;
reader.Skip();

runtimes.Add(libraryName);
Expand All @@ -495,8 +486,7 @@ private static List<RuntimeFile> ReadRuntimeFiles(ref Utf8JsonReader reader)
string? assemblyVersion = null;
string? fileVersion = null;

string? path = reader.GetString();
Debug.Assert(path != null);
string? path = reader.GetString()!;

reader.ReadStartObject();

Expand Down Expand Up @@ -531,12 +521,9 @@ private List<RuntimeTargetEntryStub> ReadTargetLibraryRuntimeTargets(ref Utf8Jso

while (reader.Read() && reader.IsTokenTypeProperty())
{
string? path = reader.GetString();
Debug.Assert(path != null);

var runtimeTarget = new RuntimeTargetEntryStub
{
Path = path
Path = reader.GetString()!
};

reader.ReadStartObject();
Expand All @@ -546,12 +533,10 @@ private List<RuntimeTargetEntryStub> ReadTargetLibraryRuntimeTargets(ref Utf8Jso
switch (propertyName)
{
case DependencyContextStrings.RidPropertyName:
Debug.Assert(propertyValue != null);
runtimeTarget.Rid = Pool(propertyValue);
runtimeTarget.Rid = Pool(propertyValue)!;
break;
case DependencyContextStrings.AssetTypePropertyName:
Debug.Assert(propertyValue != null);
runtimeTarget.Type = Pool(propertyValue);
runtimeTarget.Type = Pool(propertyValue)!;
break;
case DependencyContextStrings.AssemblyVersionPropertyName:
runtimeTarget.AssemblyVersion = propertyValue;
Expand Down Expand Up @@ -580,7 +565,7 @@ private List<ResourceAssembly> ReadTargetLibraryResources(ref Utf8JsonReader rea

while (reader.Read() && reader.IsTokenTypeProperty())
{
string? path = reader.GetString();
string? path = reader.GetString()!;
string? locale = null;

reader.ReadStartObject();
Expand All @@ -597,7 +582,6 @@ private List<ResourceAssembly> ReadTargetLibraryResources(ref Utf8JsonReader rea

if (locale != null)
{
Debug.Assert(path != null);
resources.Add(new ResourceAssembly(path, Pool(locale)));
}
}
Expand All @@ -615,9 +599,7 @@ private Dictionary<string, LibraryStub> ReadLibraries(ref Utf8JsonReader reader)

while (reader.Read() && reader.IsTokenTypeProperty())
{
string? libraryName = reader.GetString();
Debug.Assert(libraryName != null);

string? libraryName = reader.GetString()!;
libraries.Add(Pool(libraryName), ReadOneLibrary(ref reader));
}

Expand Down Expand Up @@ -667,12 +649,10 @@ private LibraryStub ReadOneLibrary(ref Utf8JsonReader reader)

reader.CheckEndObject();

Debug.Assert(type != null);

return new LibraryStub()
{
Hash = hash,
Type = Pool(type),
Type = Pool(type)!,
Serviceable = serviceable,
Path = path,
HashPath = hashPath,
Expand Down

0 comments on commit 57dee24

Please sign in to comment.