Skip to content

Commit

Permalink
Merge pull request #30 from seesharper/fix-build
Browse files Browse the repository at this point in the history
SDK style source package
  • Loading branch information
seesharper authored Jun 24, 2019
2 parents 3786b0b + 5063b18 commit e2c1f3f
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 36 deletions.
2 changes: 1 addition & 1 deletion build/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"program": "dotnet",
"args": [
"exec",
"/Users/bernhardrichter/.dotnet/tools/.store/dotnet-script/0.28.0/dotnet-script/0.28.0/tools/netcoreapp2.1/any/dotnet-script.dll",
"/Users/bernhardrichter/.dotnet/tools/.store/dotnet-script/0.29.1/dotnet-script/0.29.1/tools/netcoreapp2.1/any/dotnet-script.dll",
"${file}"
],
"cwd": "${workspaceRoot}",
Expand Down
4 changes: 3 additions & 1 deletion build/BuildContext.csx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#load "nuget:Dotnet.Build, 0.4.0"
#load "nuget:Dotnet.Build, 0.5.0"
using static FileUtils;
using System.Xml.Linq;

var owner = "seesharper";
var projectName = "LightInject.Interception";
var root = FileUtils.GetScriptFolder();

var repoFolder = Path.Combine(root, "..");
var solutionFolder = Path.Combine(root, "..", "src");
var projectFolder = Path.Combine(root, "..", "src", "LightInject.Interception");

Expand Down
65 changes: 32 additions & 33 deletions build/build.csx
Original file line number Diff line number Diff line change
@@ -1,49 +1,43 @@
#load "nuget:Dotnet.Build, 0.4.0"
#load "nuget:dotnet-steps, 0.0.1"
#load "nuget:Dotnet.Build, 0.5.0"
#load "nuget:github-changelog, 0.1.5"
#load "nuget:dotnet-steps, 0.0.1"
#load "BuildContext.csx"
using static FileUtils;
using static Internalizer;
using static xUnit;
using static DotNet;

using static ChangeLog;
using static ReleaseManagement;


[StepDescription("Runs the tests with test coverage")]
Step testcoverage = () =>
{
DotNet.TestWithCodeCoverage(projectName, testProjectFolder, coverageArtifactsFolder, targetFramework: "netcoreapp2.0");
DotNet.TestWithCodeCoverage(projectName, testProjectFolder, coverageArtifactsFolder, targetFramework: "netcoreapp2.0", threshold: 90);
};

[StepDescription("Runs all the tests for all target frameworks")]
Step test = () =>
{
DotNet.Test(testProjectFolder);
};

await StepRunner.Execute(Args);
return 0;

Build(projectFolder);
Test(testProjectFolder);
AnalyzeCodeCoverage(pathToTestAssembly, $"+[{projectName}]*");
Pack(projectFolder, nuGetArtifactsFolder);
[StepDescription("Creates the NuGet packages")]
Step pack = () =>
{
test();
testcoverage();
DotNet.Pack(projectFolder, nuGetArtifactsFolder, Git.Default.GetCurrentShortCommitHash());
NuGet.CreateSourcePackage(repoFolder, projectName, nuGetArtifactsFolder);
};

using (var sourceBuildFolder = new DisposableFolder())
[DefaultStep]
[StepDescription("Deploys packages if we are on a tag commit in a secure environment.")]
AsyncStep deploy = async () =>
{
string pathToSourceProjectFolder = Path.Combine(sourceBuildFolder.Path, "LightInject.Interception");
Copy(solutionFolder, sourceBuildFolder.Path, new[] { ".vs", "obj" });
Internalize(pathToSourceProjectFolder, exceptTheseTypes);
DotNet.Build(Path.Combine(sourceBuildFolder.Path, "LightInject.Interception"));
using (var nugetPackFolder = new DisposableFolder())
pack();
if (!BuildEnvironment.IsSecure)
{
var contentFolder = CreateDirectory(nugetPackFolder.Path, "content", "netstandard1.1", "LightInject.Interception");
Copy("LightInject.Interception.Source.nuspec", nugetPackFolder.Path);
string pathToSourceFileTemplate = Path.Combine(contentFolder, "LightInject.Interception.cs.pp");
Copy(Path.Combine(pathToSourceProjectFolder, "LightInject.Interception.cs"), pathToSourceFileTemplate);
FileUtils.ReplaceInFile(@"namespace \S*", $"namespace $rootnamespace$.{projectName}", pathToSourceFileTemplate);
NuGet.Pack(nugetPackFolder.Path, nuGetArtifactsFolder, version);
Logger.Log("Deployment can only be done in a secure environment");
return;
}
}

if (BuildEnvironment.IsSecure)
{
await CreateReleaseNotes();

if (Git.Default.IsTagCommit())
Expand All @@ -53,7 +47,12 @@ if (BuildEnvironment.IsSecure)
.CreateRelease(Git.Default.GetLatestTag(), pathToReleaseNotes, Array.Empty<ReleaseAsset>());
NuGet.TryPush(nuGetArtifactsFolder);
}
}
};


await StepRunner.Execute(Args);
return 0;


private async Task CreateReleaseNotes()
{
Expand All @@ -63,5 +62,5 @@ private async Task CreateReleaseNotes()
{
generator = generator.IncludeUnreleased();
}
await generator.Generate(pathToReleaseNotes);
}
await generator.Generate(pathToReleaseNotes, FormattingOptions.Default.WithPullRequestBody());
}
20 changes: 20 additions & 0 deletions src/LightInject.Interception/LightInject.Interception.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ namespace LightInject.Interception
/// <summary>
/// Implemented by all proxy types.
/// </summary>
[NoInternalize]
public interface IProxy
{
/// <summary>
Expand All @@ -194,6 +195,7 @@ public interface IProxy
/// <summary>
/// Represents a class that contains detailed information about the method being invoked.
/// </summary>
[NoInternalize]
public interface IInvocationInfo
{
/// <summary>
Expand Down Expand Up @@ -228,6 +230,7 @@ public interface IInvocationInfo
/// Represents a class that is capable of creating a delegate used to invoke
/// a method without using late-bound invocation.
/// </summary>
[NoInternalize]
public interface IMethodBuilder
{
/// <summary>
Expand All @@ -241,6 +244,7 @@ public interface IMethodBuilder
/// <summary>
/// Represents the skeleton of a dynamic method.
/// </summary>
[NoInternalize]
public interface IDynamicMethodSkeleton
{
/// <summary>
Expand All @@ -259,6 +263,7 @@ public interface IDynamicMethodSkeleton
/// <summary>
/// Represents a class that is capable of creating a proxy <see cref="Type"/>.
/// </summary>
[NoInternalize]
public interface IProxyBuilder
{
/// <summary>
Expand All @@ -273,6 +278,7 @@ public interface IProxyBuilder
/// <summary>
/// Represents a class that intercepts method calls.
/// </summary>
[NoInternalize]
public interface IInterceptor
{
/// <summary>
Expand Down Expand Up @@ -326,6 +332,7 @@ public interface IMethodSelector
/// A factory class used to create a <see cref="CompositeInterceptor"/> if the target method has
/// multiple interceptors.
/// </summary>
[NoInternalize]
public static class MethodInterceptorFactory
{
/// <summary>
Expand All @@ -348,6 +355,7 @@ public static Lazy<IInterceptor> CreateMethodInterceptor(Lazy<IInterceptor>[] in
/// <summary>
/// Contains information about the target method being intercepted.
/// </summary>
[NoInternalize]
public class TargetMethodInfo
{
/// <summary>
Expand Down Expand Up @@ -386,6 +394,7 @@ public TargetMethodInfo(MethodInfo method, MethodInfo methodInvocationTarget)
/// <summary>
/// Contains information about the open generic target method being intercepted.
/// </summary>
[NoInternalize]
public class OpenGenericTargetMethodInfo
{
private readonly MethodInfo openGenericMethod;
Expand Down Expand Up @@ -458,6 +467,7 @@ private TargetMethodInfo CreateTargetMethodInfo(Type[] types)
/// A class that is capable of creating a delegate used to invoke
/// a method without using late-bound invocation.
/// </summary>
[NoInternalize]
public class DynamicMethodBuilder : IMethodBuilder
{
private readonly Func<IDynamicMethodSkeleton> methodSkeletonFactory;
Expand Down Expand Up @@ -610,6 +620,7 @@ public Func<object, object[], object> CreateDelegate()
/// An <see cref="IMethodBuilder"/> cache decorator that ensures that
/// for a given <see cref="MethodInfo"/>, only a single dynamic method is created.
/// </summary>
[NoInternalize]
public class CachedMethodBuilder : IMethodBuilder
{
private readonly IMethodBuilder methodBuilder;
Expand Down Expand Up @@ -641,6 +652,7 @@ public Func<object, object[], object> GetDelegate(MethodInfo targetMethod)
/// An implementation of the <see cref="IInvocationInfo"/> interface that forwards
/// method calls the actual target.
/// </summary>
[NoInternalize]
public class TargetInvocationInfo : IInvocationInfo
{
private readonly TargetMethodInfo targetMethodInfo;
Expand Down Expand Up @@ -719,6 +731,7 @@ public object Proceed()
/// An implementation of the <see cref="IInvocationInfo"/> interface that forwards
/// method calls to the next <see cref="IInterceptor"/> in the interceptor chain.
/// </summary>
[NoInternalize]
public class InterceptorInvocationInfo : IInvocationInfo
{
private readonly IInvocationInfo nextInvocationInfo;
Expand Down Expand Up @@ -793,6 +806,7 @@ public object Proceed()
/// A composite <see cref="IInterceptor"/> that is responsible for
/// passing the <see cref="IInvocationInfo"/> down the interceptor chain.
/// </summary>
[NoInternalize]
public class CompositeInterceptor : IInterceptor
{
private readonly Lazy<IInterceptor>[] interceptors;
Expand Down Expand Up @@ -827,6 +841,7 @@ public object Invoke(IInvocationInfo invocationInfo)
/// <summary>
/// Contains information about a registered <see cref="IInterceptor"/>.
/// </summary>
[NoInternalize]
public class InterceptorInfo
{
/// <summary>
Expand All @@ -848,6 +863,7 @@ public class InterceptorInfo
/// <summary>
/// Represents the definition of a proxy type.
/// </summary>
[NoInternalize]
public class ProxyDefinition
{
private readonly ICollection<InterceptorInfo> interceptors = new Collection<InterceptorInfo>();
Expand Down Expand Up @@ -2482,4 +2498,8 @@ public class ExcludeFromCodeCoverageAttribute : Attribute

}
#endif
internal class NoInternalize : Attribute
{

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net46;netstandard1.1;netstandard2.0</TargetFrameworks>
<Version>2.0.3</Version>
<Authors>Bernhard Richter</Authors>
<PackageProjectUrl>http//www.lightinject.net</PackageProjectUrl>
<PackageProjectUrl>http://www.lightinject.net</PackageProjectUrl>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/seesharper/LightInject.Interception</RepositoryUrl>
<PackageLicenseUrl>http://opensource.org/licenses/MIT</PackageLicenseUrl>
Expand Down

0 comments on commit e2c1f3f

Please sign in to comment.