Skip to content

Commit edb0ca6

Browse files
committed
fix warning
1 parent d4ab40b commit edb0ca6

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

Test/SetOrginHatch.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,17 @@ public void setOriginHatch()
6868
using (Transaction tr2 = doc.TransactionManager.StartTransaction())
6969
{
7070
Entity ent = (Entity) tr2.GetObject(mHatchId, OpenMode.ForWrite);
71-
if (ent != null)
7271
{
73-
Hatch nHatch = ent as Hatch;
74-
String hatchName = nHatch.PatternName;
72+
Hatch? nHatch = ent as Hatch;
73+
string? hatchName = nHatch?.PatternName;
7574
Point2d setOrigin = new Point2d(6.698, 2.78);
76-
nHatch.Origin = setOrigin;
77-
nHatch.SetHatchPattern(HatchPatternType.PreDefined, hatchName);
78-
nHatch.EvaluateHatch(true);
79-
nHatch.Draw();
75+
if (nHatch != null)
76+
{
77+
nHatch.Origin = setOrigin;
78+
nHatch.SetHatchPattern(HatchPatternType.PreDefined, hatchName);
79+
nHatch.EvaluateHatch(true);
80+
nHatch.Draw();
81+
}
8082
}
8183

8284
tr2.Commit();

Test/TestCircle.cs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,18 @@ public void cmdCreateCricle()
1919
using (var tr = db.TransactionManager.StartTransaction())
2020
{
2121
var bt = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
22-
var ms = tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
23-
var circle = new Autodesk.AutoCAD.DatabaseServices.Circle();
24-
Random ran = new Random();
25-
int c = ran.Next(0, 100);
26-
circle.Center = new Point3d(0, 10, 0);
27-
circle.Radius = c;
28-
ms.AppendEntity(circle);
29-
tr.AddNewlyCreatedDBObject(circle, true);
22+
if (bt != null)
23+
{
24+
var ms = tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
25+
var circle = new Autodesk.AutoCAD.DatabaseServices.Circle();
26+
Random ran = new Random();
27+
int c = ran.Next(0, 100);
28+
circle.Center = new Point3d(0, 10, 0);
29+
circle.Radius = c;
30+
ms?.AppendEntity(circle);
31+
tr.AddNewlyCreatedDBObject(circle, true);
32+
}
33+
3034
tr.Commit();
3135

3236
}

Test/TestLine.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public void FindCmdDuplicatesCmd()
5353

5454
{
5555
string asmPath = SelectAssembly();
56-
if (asmPath == null) return;
56+
if (string.IsNullOrEmpty(asmPath)) return;
5757
FindCmdDuplicates(asmPath);
5858
}
5959

@@ -103,7 +103,7 @@ private string SelectAssembly()
103103
}
104104

105105

106-
return null;
106+
return String.Empty;
107107
}
108108

109109

0 commit comments

Comments
 (0)