Skip to content

Commit

Permalink
Update directives
Browse files Browse the repository at this point in the history
  • Loading branch information
Nice3point committed Mar 10, 2024
1 parent 014b571 commit dfceb70
Show file tree
Hide file tree
Showing 23 changed files with 101 additions and 97 deletions.
5 changes: 4 additions & 1 deletion build/Build.CI.GitHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ sealed partial class Build
{
Name = Version,
Body = changelog,
TargetCommitish = GitRepository.Commit
TargetCommitish = GitRepository.Commit,
Prerelease = Version.Contains("-beta") ||
Version.Contains("-dev") ||
Version.Contains("-preview")
};

var release = await GitHubTasks.GitHubClient.Repository.Release.Create(gitHubOwner, gitHubName, newRelease);
Expand Down
2 changes: 1 addition & 1 deletion build/Build.Configuration.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
sealed partial class Build
{
const string Version = "4.0.0";
const string Version = "4.0.0-preview.1.0";
readonly AbsolutePath ArtifactsDirectory = RootDirectory / "output";
readonly AbsolutePath ChangeLogPath = RootDirectory / "Changelog.md";

Expand Down
6 changes: 3 additions & 3 deletions source/Nice3point.Revit.AddIn.Application/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class Application : ExternalApplication
{
public override void OnStartup()
{
#if UseIoc
#if (UseIoc)
Host.Start();
#endif
#if (log && !UseIoc)
Expand All @@ -26,9 +26,9 @@ public override void OnStartup()

public override void OnShutdown()
{
#if Hosting
#if (Hosting)
Host.Stop();
#elseif log
#elseif (log)
Log.CloseAndFlush();
#endif
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#if Container
#if (Container)
using Microsoft.Extensions.DependencyInjection;
#endif
#if Hosting
#if (Hosting)
using Microsoft.Extensions.Logging;
#endif
using Serilog.Core;
Expand All @@ -11,21 +11,21 @@ namespace Nice3point.Revit.AddIn.Config;

public static class LoggerConfigurator
{
#if Container
#if (Container)
private const string LogTemplate = "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}]: {Message:lj}{NewLine}{Exception}";
#elseif Hosting
#elseif (Hosting)
private const string LogTemplate = "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] {SourceContext}: {Message:lj}{NewLine}{Exception}";
#endif

#if Container
#if (Container)
public static void AddSerilogConfiguration(this IServiceCollection services)
{
var logger = CreateDefaultLogger();
services.AddSingleton<ILogger>(logger);

AppDomain.CurrentDomain.UnhandledException += OnOnUnhandledException;
}
#elseif Hosting
#elseif (Hosting)
public static void AddSerilogConfiguration(this ILoggingBuilder builder)
{
var logger = CreateDefaultLogger();
Expand All @@ -43,14 +43,14 @@ private static Logger CreateDefaultLogger()
.CreateLogger();
}

#if Container
#if (Container)
private static void OnOnUnhandledException(object sender, UnhandledExceptionEventArgs args)
{
var exception = (Exception)args.ExceptionObject;
var logger = Host.GetService<ILogger>();
logger.Fatal(exception, "Domain unhandled exception");
}
#elseif Hosting
#elseif (Hosting)
private static void OnOnUnhandledException(object sender, UnhandledExceptionEventArgs args)
{
var exception = (Exception)args.ExceptionObject;
Expand Down
24 changes: 12 additions & 12 deletions source/Nice3point.Revit.AddIn.Application/Host.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#if Hosting
using System.IO
#if (Hosting)
using System.IO;
using System.Reflection;
using Microsoft.Extensions.Hosting;
#endif
#if (log && Hosting)
using Microsoft.Extensions.Logging;
#endif
#if Container
#if (Container)
using Microsoft.Extensions.DependencyInjection;
#endif
#if (log && UseIoc)
Expand All @@ -20,10 +20,10 @@ namespace Nice3point.Revit.AddIn;
/// </summary>
public static class Host
{
#if Container
#if (Container)
private static IServiceProvider _serviceProvider;
#endif
#if Hosting
#if (Hosting)
private static IHost _host;
#endif

Expand All @@ -32,22 +32,22 @@ public static class Host
/// </summary>
public static void Start()
{
#if Container
#if (Container)
var services = new ServiceCollection();
#if log
#if (log)

services.AddSerilogConfiguration();
#endif

_serviceProvider = services.BuildServiceProvider();
#endif
#if Hosting
#if (Hosting)
var builder = Microsoft.Extensions.Hosting.Host.CreateApplicationBuilder(new HostApplicationBuilderSettings
{
ContentRootPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly()!.Location),
DisableDefaults = true
});
#if log
#if (log)

builder.Logging.ClearProviders();
builder.Logging.AddSerilogConfiguration();
Expand All @@ -57,7 +57,7 @@ public static void Start()
_host.Start();
#endif
}
#if Hosting
#if (Hosting)

/// <summary>
/// Stops the host.
Expand All @@ -75,10 +75,10 @@ public static void Stop()
/// <returns>A service object of type T or null if there is no such service.</returns>
public static T GetService<T>() where T : class
{
#if Container
#if (Container)
return _serviceProvider.GetService(typeof(T)) as T;
#endif
#if Hosting
#if (Hosting)
return _host.Services.GetService(typeof(T)) as T;
#endif
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<RevitAddIns>
#if Command
#if (Command)
<AddIn Type="Command">
#elseif Application
#elseif (Application)
<AddIn Type="Application">
#endif
<Name>Nice3point.Revit.AddIn</Name>
<Assembly>Nice3point.Revit.AddIn/Nice3point.Revit.AddIn.dll</Assembly>
<AddInId>AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA</AddInId>
#if Command
#if (Command)
<FullClassName>Nice3point.Revit.AddIn.Commands.StartupCommand</FullClassName>
<Text>Nice3point.Revit.AddIn</Text>
#elseif Application
#elseif (Application)
<FullClassName>Nice3point.Revit.AddIn.Application</FullClassName>
#endif
<VendorId>Development</VendorId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
<Resource Include="Resources\Icons\RibbonIcon16.png"/>
<Resource Include="Resources\Icons\RibbonIcon32.png"/>
</ItemGroup>
<!--#endif-->

<Target Name="CopyFiles" AfterTargets="CoreBuild">
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Nice3point.Revit.Toolkit.External;
using Nice3point.Revit.AddIn.Views;
#if Modeless
#if (Modeless)
using Nice3point.Revit.AddIn.Utils;
using Microsoft.Extensions.DependencyInjection;
#endif
Expand All @@ -10,20 +10,20 @@ namespace Nice3point.Revit.AddIn.CommandHandlers;
/// <summary>
/// Command entry point invoked from the Revit AddIn Application
/// </summary>
#if Modeless
#if (Modeless)
public class ShowWindowHandler(IServiceProvider serviceProvider)
#else
public class ShowWindowHandler(Nice3point.Revit.AddInView view)
#endif
{
public void Execute(ExternalCommand shell)
{
#if Modeless
#if (Modeless)
if (WindowController.Focus<Nice3point.Revit.AddInView>()) return;

var view = serviceProvider.GetService<Nice3point.Revit.AddInView>();
WindowController.Show(view, shell.UiApplication.MainWindowHandle);
#elseif Modal
#elseif (Modal)
view.ShowDialog();
#endif
}
Expand Down
14 changes: 7 additions & 7 deletions source/Nice3point.Revit.AddIn.Module/Commands/StartupCommand.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
using Autodesk.Revit.Attributes;
using Nice3point.Revit.Toolkit.External;
#if NoWindow
#if (NoWindow)
using Autodesk.Revit.UI;
#endif
#if !NoWindow
#if (!NoWindow)
using Nice3point.Revit.AddIn.ViewModels;
#endif
#if !NoWindow
#if (!NoWindow)
using Nice3point.Revit.AddIn.Views;
#endif
#if Modeless
#if (Modeless)
using Nice3point.Revit.AddIn.Utils;
#endif

Expand All @@ -24,17 +24,17 @@ public class StartupCommand : ExternalCommand
{
public override void Execute()
{
#if Modeless
#if (Modeless)
if (WindowController.Focus<Nice3point.Revit.AddInView>()) return;

var viewModel = new Nice3point.Revit.AddInViewModel();
var view = new Nice3point.Revit.AddInView(viewModel);
WindowController.Show(view, UiApplication.MainWindowHandle);
#elseif Modal
#elseif (Modal)
var viewModel = new Nice3point.Revit.AddInViewModel();
var view = new Nice3point.Revit.AddInView(viewModel);
view.ShowDialog();
#elseif NoWindow
#elseif (NoWindow)
TaskDialog.Show(Document.Title, "Nice3point.Revit.AddIn");
#endif
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{EEEEEEEE-EEEE-EEEE-EEEE-EEEEEEEEEEEE}"
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
#if GitHubPipeline
#if (GitHubPipeline)
Changelog.md = Changelog.md
#endif
Readme.md = Readme.md
Expand All @@ -12,7 +12,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Project("{AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA}") = "Build", "build\Build.csproj", "{CCCCCCCC-CCCC-CCCC-CCCC-CCCCCCCCCCCC}"
EndProject
#if installer
#if (installer)
Project("{AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA}") = "Installer", "install\Installer.csproj", "{BBBBBBBB-BBBB-BBBB-BBBB-BBBBBBBBBBBB}"
EndProject
#endif
Expand All @@ -30,7 +30,7 @@ Global
Release R23|Any CPU = Release R23|Any CPU
Release R24|Any CPU = Release R24|Any CPU
Release R25|Any CPU = Release R25|Any CPU
#if installer
#if (installer)
Installer|Any CPU = Installer|Any CPU
#endif
EndGlobalSection
Expand Down
4 changes: 2 additions & 2 deletions source/Nice3point.Revit.AddIn.Solution/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ stages:
inputs:
#if (bundle && installer)
script: './.nuke/build.cmd CreateBundle CreateInstaller'
#elseif installer
#elseif (installer)
script: './.nuke/build.cmd CreateInstaller'
#elseif bundle
#elseif (bundle)
script: './.nuke/build.cmd CreateBundle'
#else
script: './.nuke/build.cmd'
Expand Down
4 changes: 2 additions & 2 deletions source/Nice3point.Revit.AddIn.Solution/build/Build.Bundle.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Autodesk.PackageBuilder;
using System.Xml.Linq;
#if !NoPipeline
#if (!NoPipeline)
using Nuke.Common.Git;
#endif
using Nuke.Common.ProjectModel;
Expand All @@ -10,7 +10,7 @@ sealed partial class Build
{
Target CreateBundle => _ => _
.DependsOn(Compile)
#if !NoPipeline
#if (!NoPipeline)
.OnlyWhenStatic(() => IsLocalBuild || GitRepository.IsOnMainOrMasterBranch())
#endif
.Executes(() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ sealed partial class Build
Target PublishGitHub => _ => _
#if (installer && bundle)
.DependsOn(CreateInstaller, CreateBundle)
#elseif installer
#elseif (installer)
.DependsOn(CreateInstaller)
#elseif bundle
#elseif (bundle)
.DependsOn(CreateBundle)
#else
.DependsOn(Compile)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#if (bundle || installer || GitHubPipeline)
readonly AbsolutePath ArtifactsDirectory = RootDirectory / "output";
#endif
#if GitHubPipeline
#if (GitHubPipeline)
readonly AbsolutePath ChangeLogPath = RootDirectory / "Changelog.md";
#endif

Expand All @@ -13,18 +13,18 @@ protected override void OnBuildInitialized()
Configurations =
[
"Release*",
#if installer
#if (installer)
"Installer*"
#endif
];
#if bundle
#if (bundle)

Bundles =
[
Solution.Nice3point.Revit.AddIn
];
#endif
#if installer
#if (installer)

InstallersMap = new()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Diagnostics.CodeAnalysis;
#if !NoPipeline
#if (!NoPipeline)
using Nuke.Common.Git;
#endif
using Nuke.Common.Tooling;
Expand Down
6 changes: 3 additions & 3 deletions source/Nice3point.Revit.AddIn.Solution/build/Build.Regex.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

sealed partial class Build
{
#if bundle
#if (bundle)
readonly Regex YearRegex = YearRegexGenerator();
#endif
#if installer
#if (installer)
readonly Regex ArgumentsRegex = ArgumentsRegexGenerator();
#endif
#if bundle
#if (bundle)

[GeneratedRegex(@"\d{4}")]
private static partial Regex YearRegexGenerator();
Expand Down
Loading

0 comments on commit dfceb70

Please sign in to comment.