Cleanup warnings

This commit is contained in:
Martijn van Dijk
2023-03-08 12:19:18 +01:00
parent 5b7793b238
commit 3142d73ae3
9 changed files with 53 additions and 54 deletions
+5 -5
View File
@@ -5,7 +5,7 @@
<PackageProjectUrl>https://github.com/Speckle-Next/xunit-Revit</PackageProjectUrl>
<Authors>Speckle</Authors>
<Owners>Speckle</Owners>
<PackageTags>xunit revit runner</PackageTags>
<PackageTags>xunit revit runner</PackageTags>
<PackageReleaseNotes>https://github.com/Speckle-Next/xunit-Revit/releases</PackageReleaseNotes>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageReadmeFile>readme.md</PackageReadmeFile>
@@ -18,10 +18,10 @@
<Product>$(AssemblyName) ($(TargetFramework))</Product>
<Version>1.0.5</Version>
<AssemblyName>xUnitRevitUtils</AssemblyName>
<RootNamespace>xUnitRevitUtils</RootNamespace>
<AssemblyName>xUnitRevitUtils</AssemblyName>
<RootNamespace>xUnitRevitUtils</RootNamespace>
<!--<Nullable>enable</Nullable>-->
<!--<Nullable>enable</Nullable>-->
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>latest</LangVersion>
<NoWarn>$(NoWarn);1591;1701;1702;1705;VSX1000;CS0109;CS0108;CS0618;CS0114;NU1603</NoWarn>
@@ -35,7 +35,7 @@
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<IsPackable>true</IsPackable>
<IsPackable Condition="'$(IsLibraryProject)' == 'true'">true</IsPackable>
<!--<SymbolPackageFormat>snupkg</SymbolPackageFormat>-->
<IncludeSymbols>false</IncludeSymbols>
+4 -3
View File
@@ -73,9 +73,10 @@
<Compile Include="Utils.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="xUnitRevitUtils.2021">
<Version>1.0.4</Version>
</PackageReference>
<ProjectReference Include="..\xUnitRevitUtils2021\xUnitRevitUtils2021.csproj">
<Project>{977e0b63-5706-4c2b-9c01-3c02d9ebe377}</Project>
<Name>xUnitRevitUtils2021</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
+12 -14
View File
@@ -15,13 +15,13 @@ namespace SampleLibrary
public void WallsHaveVolume()
{
var testModel = Utils.GetTestModel("walls.rvt");
var doc = xru.OpenDoc(testModel);
using var doc = xru.OpenDoc(testModel);
var walls = new FilteredElementCollector(doc).WhereElementIsNotElementType().OfCategory(BuiltInCategory.OST_Walls).ToElements();
foreach (var wall in walls)
{
var volumeParam = wall.get_Parameter(BuiltInParameter.HOST_VOLUME_COMPUTED);
using var volumeParam = wall.get_Parameter(BuiltInParameter.HOST_VOLUME_COMPUTED);
Assert.NotNull(volumeParam);
Assert.True(volumeParam.AsDouble() > 0);
}
@@ -42,7 +42,7 @@ namespace SampleLibrary
public void GetWallGrossAreaAndRollBack()
{
var testModel = Utils.GetTestModel("walls.rvt");
var doc = xru.OpenDoc(testModel);
using var doc = xru.OpenDoc(testModel);
var walls = new FilteredElementCollector(doc).WhereElementIsNotElementType().OfCategory(BuiltInCategory.OST_Walls).ToElements();
var wall = walls[0] as Wall;
double grossArea = 0;
@@ -50,17 +50,15 @@ namespace SampleLibrary
var inserts = wall.FindInserts(true, true, true, true);
xru.Run(() =>
{
using (Transaction transaction = new Transaction(doc, "Temporary - only to get gross area"))
{
transaction.Start();
foreach (ElementId insertId in inserts) { doc.Delete(insertId); }
doc.Regenerate();
var wallFaceReference = HostObjectUtils.GetSideFaces(wall, ShellLayerType.Exterior);
var face = doc.GetElement(wallFaceReference.First()).GetGeometryObjectFromReference(wallFaceReference.First()) as PlanarFace;
var wallFaceEdges = face.GetEdgesAsCurveLoops();
grossArea = ExporterIFCUtils.ComputeAreaOfCurveLoops(wallFaceEdges);
transaction.RollBack();
}
using var transaction = new Transaction(doc, "Temporary - only to get gross area");
transaction.Start();
foreach (ElementId insertId in inserts) { doc.Delete(insertId); }
doc.Regenerate();
var wallFaceReference = HostObjectUtils.GetSideFaces(wall, ShellLayerType.Exterior);
using var face = doc.GetElement(wallFaceReference[0]).GetGeometryObjectFromReference(wallFaceReference[0]) as PlanarFace;
var wallFaceEdges = face.GetEdgesAsCurveLoops();
grossArea = ExporterIFCUtils.ComputeAreaOfCurveLoops(wallFaceEdges);
transaction.RollBack();
}, doc).Wait();
Assert.True(grossArea > 0);
}
+3 -3
View File
@@ -22,8 +22,8 @@ namespace SampleLibrary
[Fact]
public void WallOffset()
{
var wall = fixture.Doc.GetElement(new ElementId(346573));
var param = wall.get_Parameter(BuiltInParameter.WALL_BASE_OFFSET);
using var wall = fixture.Doc.GetElement(new ElementId(346573));
using var param = wall.get_Parameter(BuiltInParameter.WALL_BASE_OFFSET);
#if pre2021
var baseOffset = UnitUtils.ConvertFromInternalUnits(param.AsDouble(), param.DisplayUnitType);
@@ -57,7 +57,7 @@ namespace SampleLibrary
foreach (var wall in walls)
{
var param = wall.get_Parameter(BuiltInParameter.WALL_BASE_OFFSET);
using var param = wall.get_Parameter(BuiltInParameter.WALL_BASE_OFFSET);
#if pre2021
var baseOffset = UnitUtils.ConvertFromInternalUnits(param.AsDouble(), param.DisplayUnitType);
#else
+3 -3
View File
@@ -16,12 +16,12 @@ namespace xUnitRevit
private void ControlledApplication_ApplicationInitialized(object sender, Autodesk.Revit.DB.Events.ApplicationInitializedEventArgs e)
{
Application app = sender as Application;
UIApplication uiapp = new UIApplication(app);
var app = sender as Application;
using var uiapp = new UIApplication(app);
Runner.ReadConfig();
if (Runner.Config.autoStart)
if (Runner.Config.AutoStart)
Runner.Launch(uiapp);
}
+1 -3
View File
@@ -19,11 +19,9 @@ namespace xUnitRevit
ref string message,
ElementSet elements)
{
UIApplication uiapp = commandData.Application;
var uiapp = commandData.Application;
Runner.Launch(uiapp);
return Result.Succeeded;
}
}
}
+1 -1
View File
@@ -8,6 +8,6 @@ namespace xUnitRevit
public class Configuration
{
public IList<string> StartupAssemblies { get; set; } = new List<string>();
public bool autoStart { get; set; } = false;
public bool AutoStart { get; set; } = false;
}
}
+8 -6
View File
@@ -23,20 +23,22 @@ namespace xUnitRevit
try
{
var queue = new List<Action>();
var eventHandler = ExternalEvent.Create(new ExternalEventHandler(queue));
using var eventHandler = ExternalEvent.Create(new ExternalEventHandler(queue));
xru.Initialize(uiapp, SynchronizationContext.Current, eventHandler, queue);
var main = new MainWindow();
main.Title = "xUnit Revit by Speckle";
main.MaxHeight = 800;
var main = new MainWindow
{
Title = "xUnit Revit by Speckle",
MaxHeight = 800
};
//pre-load asssemblies, if you're a lazy developer
if (main.DataContext is MainViewModel mainViewModel)
mainViewModel.StartupAssemblies = Config.StartupAssemblies.ToList();
main.Show();
}
catch (Exception)
catch
{
//fail silently
}
@@ -48,7 +50,7 @@ namespace xUnitRevit
{
var dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var path = Path.Combine(dir, "config.json");
JavaScriptSerializer JavaScriptSerializer = new JavaScriptSerializer();
var JavaScriptSerializer = new JavaScriptSerializer();
var json = File.ReadAllText(path);
Config = JavaScriptSerializer.Deserialize<Configuration>(json);
}
+16 -16
View File
@@ -44,7 +44,7 @@ namespace xUnitRevitUtils
Assert.NotNull(Uiapp);
Document doc = null;
//OpenAndActivateDocument only works if run from the current context
UiContext.Send(x => { doc = Uiapp.OpenAndActivateDocument(filePath).Document; }, null);
UiContext.Send(x => doc = Uiapp.OpenAndActivateDocument(filePath).Document, null);
Assert.NotNull(doc);
return doc;
}
@@ -66,7 +66,9 @@ namespace xUnitRevitUtils
if (overwrite && File.Exists(filePath))
File.Delete(filePath);
}
catch { }
catch
{
}
//OpenAndActivateDocument only works if run from the current context
UiContext.Send(x =>
@@ -101,20 +103,18 @@ namespace xUnitRevitUtils
{
try
{
using (Transaction transaction = new Transaction(doc, transactionName))
{
transaction.Start();
if (ignoreWarnings)
{
var options = transaction.GetFailureHandlingOptions();
options.SetFailuresPreprocessor(new IgnoreAllWarnings());
transaction.SetFailureHandlingOptions(options);
}
action.Invoke();
transaction.Commit();
}
using var transaction = new Transaction(doc, transactionName);
transaction.Start();
if (ignoreWarnings)
{
using var options = transaction.GetFailureHandlingOptions();
options.SetFailuresPreprocessor(new IgnoreAllWarnings());
transaction.SetFailureHandlingOptions(options);
}
action.Invoke();
transaction.Commit();
}
catch (Exception e)
{