REFACTOR: Possible 'null' assignment to entity marked with 'NotNull' attribute.

This commit is contained in:
2017-12-21 14:41:38 +00:00
parent dcd053b20d
commit 9883b567ff
15 changed files with 34 additions and 33 deletions

View File

@@ -74,10 +74,10 @@ namespace DiscImageChef.Server.Controllers
Random rng = new Random();
string filename = string.Format("NewReport_{0:yyyyMMddHHmmssfff}_{1}.xml", DateTime.UtcNow, rng.Next());
while(File.Exists(Path.Combine(HostingEnvironment.MapPath("~"), "Upload", filename))) filename = string.Format("NewReport_{0:yyyyMMddHHmmssfff}_{1}.xml", DateTime.UtcNow, rng.Next());
while(File.Exists(Path.Combine(HostingEnvironment.MapPath("~") ?? throw new InvalidOperationException(), "Upload", filename))) filename = string.Format("NewReport_{0:yyyyMMddHHmmssfff}_{1}.xml", DateTime.UtcNow, rng.Next());
FileStream newFile =
new FileStream(Path.Combine(HostingEnvironment.MapPath("~"), "Upload", filename),
new FileStream(Path.Combine(HostingEnvironment.MapPath("~") ?? throw new InvalidOperationException(), "Upload", filename),
FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None);
xs.Serialize(newFile, newReport);
newFile.Close();

View File

@@ -76,7 +76,7 @@ namespace DiscImageChef.Server.Controllers
}
FileStream fs =
WaitForFile(Path.Combine(HostingEnvironment.MapPath("~"), "Statistics", "Statistics.xml"),
WaitForFile(Path.Combine(HostingEnvironment.MapPath("~") ?? throw new InvalidOperationException(), "Statistics", "Statistics.xml"),
FileMode.Open, FileAccess.ReadWrite, FileShare.None);
if(fs == null)

View File

@@ -45,7 +45,7 @@ namespace DiscImageChef.Server
{
MarkdownContent mkdown = new MarkdownContent();
StreamReader sr =
new StreamReader(Path.Combine(HostingEnvironment.MapPath("~"), "docs", "README.md"));
new StreamReader(Path.Combine(HostingEnvironment.MapPath("~") ?? throw new InvalidOperationException(), "docs", "README.md"));
string mdcontent = sr.ReadToEnd();
sr.Close();

View File

@@ -77,12 +77,12 @@ namespace DiscImageChef.Server
try
{
if(!File.Exists(Path.Combine(HostingEnvironment.MapPath("~"), "Statistics",
if(!File.Exists(Path.Combine(HostingEnvironment.MapPath("~") ?? throw new InvalidOperationException(), "Statistics",
"Statistics.xml")))
{
#if DEBUG
content.InnerHtml = string.Format("<b>Sorry, cannot load data file \"{0}\"</b>",
Path.Combine(HostingEnvironment.MapPath("~"),
Path.Combine(HostingEnvironment.MapPath("~") ?? throw new InvalidOperationException(),
"Statistics", "Statistics.xml"));
#else
content.InnerHtml = "<b>Sorry, cannot load data file</b>";
@@ -94,7 +94,7 @@ namespace DiscImageChef.Server
XmlSerializer xs = new XmlSerializer(statistics.GetType());
FileStream fs =
WaitForFile(Path.Combine(HostingEnvironment.MapPath("~"), "Statistics", "Statistics.xml"),
WaitForFile(Path.Combine(HostingEnvironment.MapPath("~") ?? throw new InvalidOperationException(), "Statistics", "Statistics.xml"),
FileMode.Open, FileAccess.Read, FileShare.Read);
statistics = (Stats)xs.Deserialize(fs);
fs.Close();

View File

@@ -82,7 +82,7 @@ namespace DiscImageChef.Server
else if(!string.IsNullOrWhiteSpace(model)) xmlFile = model + ".xml";
if(xmlFile == null ||
!File.Exists(Path.Combine(HostingEnvironment.MapPath("~"), "Reports", xmlFile)))
!File.Exists(Path.Combine(HostingEnvironment.MapPath("~") ?? throw new InvalidOperationException(), "Reports", xmlFile)))
{
content.InnerHtml = "<b>Could not find the specified report</b>";
return;
@@ -95,7 +95,7 @@ namespace DiscImageChef.Server
DeviceReport report = new DeviceReport();
XmlSerializer xs = new XmlSerializer(report.GetType());
StreamReader sr =
new StreamReader(Path.Combine(HostingEnvironment.MapPath("~"), "Reports",
new StreamReader(Path.Combine(HostingEnvironment.MapPath("~") ?? throw new InvalidOperationException(), "Reports",
xmlFile));
report = (DeviceReport)xs.Deserialize(sr);
sr.Close();
@@ -567,10 +567,10 @@ namespace DiscImageChef.Server
vendorDescription = null;
productDescription = null;
if(!File.Exists(Path.Combine(HostingEnvironment.MapPath("~"), "usb.ids"))) return;
if(!File.Exists(Path.Combine(HostingEnvironment.MapPath("~") ?? throw new InvalidOperationException(), "usb.ids"))) return;
StreamReader tocStream =
new StreamReader(Path.Combine(HostingEnvironment.MapPath("~"), "usb.ids"));
new StreamReader(Path.Combine(HostingEnvironment.MapPath("~") ?? throw new InvalidOperationException(), "usb.ids"));
string _line;
bool inManufacturer = false;
ushort number;