Skip to content

Commit

Permalink
New objects: IAimpImage2, IAImpMemoryStream, IAimpFileStream
Browse files Browse the repository at this point in the history
Fixed: IAimpMessageDispatcher
Improvements: Add IDispose for AIMP objects
  • Loading branch information
martin211 committed Apr 8, 2021
1 parent e0a85c8 commit 544502b
Show file tree
Hide file tree
Showing 77 changed files with 1,962 additions and 370 deletions.
8 changes: 2 additions & 6 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ variables:
output_path: "$CI_PROJECT_DIR/output/"
output_packages_path: "$output_path/packages/"

cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- src/packages/
- .tmp/

before_script:
- cd $build_path
Expand All @@ -34,7 +29,7 @@ sonarqube:
variables:
GIT_STRATEGY: "none"
script:
- powershell -File $CI_PROJECT_DIR\build.ps1 SonarQube --Configuation $Configuration --SonarUrl $SONAR_URL --SonarUser $SONAR_USER --SonarProjectKey $SONAR_PROJECT_KEY --SonarProjectName $SONAR_PROJECT_NAME
- powershell -File $CI_PROJECT_DIR\build.ps1 SonarQube --Configuation $Configuration --SonarUrl $SONAR_URL --SonarUser $SONAR_USER --SonarProjectKey $SONAR_PROJECT_KEY --SonarProjectName $SONAR_PROJECT_NAME --RequestSourceBranch $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME --RequestTargetBranch $CI_MERGE_REQUEST_TARGET_BRANCH_NAME --RequestId $CI_MERGE_REQUEST_IID

integrationTests:
stage: test
Expand Down Expand Up @@ -71,6 +66,7 @@ artifacts:
paths:
- output/
- tests/
expire_in: 1 week

deploy_release:
stage: deploy
Expand Down
35 changes: 29 additions & 6 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,32 @@
next-version: 4.60.2167
assembly-versioning-scheme: MajorMinorPatchTag
assembly-file-versioning-scheme: MajorMinorPatchTag
mode: Mainline
branches:
release:
regex: ^release?[/-]
tag: ''
increment: Patch
master:
regex: master
mode: ContinuousDelivery
tag: stable
increment: None
prevent-increment-of-merged-branch-version: true
track-merge-target: false
tracks-release-branches: false
is-release-branch: false
bugfix:
regex: ^bugfix?[/-]
mode: ContinuousDeployment
tag: preview
increment: None
prevent-increment-of-merged-branch-version: false
track-merge-target: false
tracks-release-branches: false
is-release-branch: false
source-branches: ['master']
feature:
regex: ^feature?[/]
mode: ContinuousDeployment
tag: preview
increment: None
prevent-increment-of-merged-branch-version: false
track-merge-target: false
tracks-release-branches: false
is-release-branch: false
source-branches: ['master']
50 changes: 46 additions & 4 deletions build/Build.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
Expand All @@ -9,12 +10,10 @@
using Nuke.Common.IO;
using Nuke.Common.ProjectModel;
using Nuke.Common.Tooling;
using Nuke.Common.Tools.DotNet;
using Nuke.Common.Tools.GitVersion;
using Nuke.Common.Tools.MSBuild;
using Nuke.Common.Tools.NuGet;
using Nuke.Common.Tools.SonarScanner;
using Nuke.Common.Utilities;
using Nuke.Common.Utilities.Collections;
using static Nuke.Common.IO.FileSystemTasks;
using static Nuke.Common.IO.PathConstruction;
Expand Down Expand Up @@ -42,6 +41,10 @@ partial class Build : NukeBuild
[Parameter] readonly string Source;
[Parameter] readonly string NugetApiKey;

[Parameter] readonly string RequestSourceBranch;
[Parameter] readonly string RequestTargetBranch;
[Parameter] readonly string RequestId;

AbsolutePath SourceDirectory => RootDirectory / "src";
AbsolutePath TestsDirectory => RootDirectory / "tests";
AbsolutePath OutputDirectory => RootDirectory / "output";
Expand Down Expand Up @@ -93,7 +96,7 @@ partial class Build : NukeBuild
Logger.Info($"Update version for '{rcFile}'");
Logger.Info($"Assembly version: {GitVersion.AssemblySemVer}");
var fileContent = File.ReadAllText(rcFile);
fileContent = fileContent.Replace("1,0,0,1", _version).Replace("1.0.0.1",_version);
fileContent = fileContent.Replace("1,0,0,1", _version.Replace(".", ",")).Replace("1.0.0.1",_version);
File.WriteAllText(rcFile, fileContent);
}
});
Expand Down Expand Up @@ -140,6 +143,14 @@ partial class Build : NukeBuild

configuration = configuration.SetProjectBaseDir(SourceDirectory);

if (!string.IsNullOrWhiteSpace(RequestSourceBranch) && !string.IsNullOrWhiteSpace(RequestTargetBranch))
{
configuration = configuration
.SetPullRequestBase(RequestSourceBranch)
.SetPullRequestBranch(RequestTargetBranch)
.SetPullRequestKey(RequestId);
}

var path = ToolPathResolver.GetPackageExecutable(
packageId: "dotnet-sonarscanner|MSBuild.SonarQube.Runner.Tool",
packageExecutable: "SonarScanner.MSBuild.exe",
Expand Down Expand Up @@ -224,6 +235,7 @@ partial class Build : NukeBuild
Target Artifacts => _ => _
.Executes(() =>
{
List<string> plugins = new List<string>();
EnsureCleanDirectory(OutputDirectory / "Artifacts");
Directory.CreateDirectory(OutputDirectory / "Artifacts");

Expand All @@ -233,9 +245,10 @@ partial class Build : NukeBuild
{
var di = new DirectoryInfo(directory);
var pluginName = di.Parent?.Parent?.Name;
plugins.Add(pluginName);

Directory.CreateDirectory(OutputDirectory / "Artifacts" / "Plugins" / pluginName);

Logger.Info(pluginName);
var files = di.GetFiles("*.dll");
foreach (var file in files)
{
Expand All @@ -255,6 +268,7 @@ partial class Build : NukeBuild
outFile = OutputDirectory / "Artifacts" / "Plugins" / pluginName / $"{pluginName}.dll";
}

Logger.Normal($"Copy '{file.FullName}' to '{outFile}'");
file.CopyTo(outFile, true);
}
}
Expand All @@ -269,6 +283,34 @@ partial class Build : NukeBuild
file.CopyTo(outFile, true);
}

Logger.Info("Validate output");

bool validatePluginFolder(string plugin, IEnumerable<FileInfo> files)
{
var isValid = true;

isValid &= files.Any(c => c.Name.StartsWith("AIMP.SDK"));
isValid &= files.Any(c => c.Name == $"{plugin}.dll");
isValid &= files.Any(c => c.Name == $"{plugin}_plugin.dll");

return isValid;
}

var isValid = true;
foreach (var plugin in plugins)
{
var pluginFolder = OutputDirectory / "Artifacts" / "Plugins" / plugin;
var di = new DirectoryInfo(pluginFolder);
var files = di.GetFiles("*.dll");
if (!validatePluginFolder(plugin, files))
{
Logger.Error($"Plugin {plugin} not valid.");
isValid = false;
}
}

ControlFlow.Assert(isValid, "Artifacts not valid");

Logger.Info("Compress artifacts");
ZipFile.CreateFromDirectory(OutputDirectory / "Artifacts", OutputDirectory / "aimp.sdk.zip");
});
Expand Down
43 changes: 38 additions & 5 deletions build/IntegrationTest.Build.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Xml;
using System.Xml.XPath;
using System.Xml.Xsl;
Expand Down Expand Up @@ -86,7 +87,7 @@ void copyFilesFromFolder(string folder)
{
if (file.EndsWith("aimp_dotnet.dll"))
{
CopyFile(file, IntegrationTestPluginPath / "AimpTestRunner.dll");
//CopyFile(file, IntegrationTestPluginPath / "AimpTestRunner.dll");
}
else if (file.EndsWith("AimpTestRunner.dll"))
{
Expand All @@ -113,6 +114,16 @@ void copyFilesFromFolder(string folder)
Logger.Normal($"Copy {d}/nunit.engine.addins to {IntegrationTestPluginPath}");
CopyFileToDirectory(d / "nunit.engine.addins", IntegrationTestPluginPath);
});

var sdkFolder = new DirectoryInfo(SourceDirectory / $"{Configuration}");
var sdkFiles = sdkFolder.GetFiles("*.dll");
foreach (var file in sdkFiles)
{
if (file.FullName.EndsWith("aimp_dotnet.dll"))
{
file.CopyTo(IntegrationTestPluginPath / "AimpTestRunner.dll", true);
}
}
}

CopyDirectoryRecursively(ResourcesPath / "integrationTests", IntegrationTestPluginPath / "resources");
Expand Down Expand Up @@ -154,10 +165,27 @@ void copyFilesFromFolder(string folder)
}
else
{
CopyFileToDirectory(testResultFile, OutputDirectory);
CopyFileToDirectory(testResultLogFile, OutputDirectory);
var isValid = true;

CopyFileToDirectory(testResultFile, OutputDirectory, FileExistsPolicy.Overwrite);
CopyFileToDirectory(testResultLogFile, OutputDirectory, FileExistsPolicy.Overwrite);

var content = File.ReadAllText(testResultLogFile);
var r = new Regex(@"Failed:\s(\d*)");
var matches = r.Matches(content);

Logger.Info(File.ReadAllText(testResultLogFile));
if (matches.Count > 0 && matches[0].Groups.Count >= 1)
{
if (int.TryParse(matches[0].Groups[1].Value, out var failed))
{
if (failed > 0)
{
isValid = false;
}
}
}

Logger.Info(content);

if (IsJUnit)
{
Expand All @@ -172,6 +200,11 @@ void copyFilesFromFolder(string folder)
};
xslt.Transform(doc, null, writer, null);
}

if (!isValid)
{
ControlFlow.Fail("Test is failed.");
}
}
}
else
Expand All @@ -181,7 +214,7 @@ void copyFilesFromFolder(string folder)
}
});

private void LogError(string message)
void LogError(string message)
{
Logger.Error(message);
}
Expand Down
Binary file added resources/integrationTests/img1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/integrationTests/img2.bmp
Binary file not shown.
8 changes: 7 additions & 1 deletion src/AIMP.SDK/AIMP.SDK.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@
<Compile Include="Core\IAimpServiceShutdown.cs" />
<Compile Include="Core\IAimpServiceVersionInfo.cs" />
<Compile Include="Extensions.cs" />
<Compile Include="IAimpDPIAware.cs" />
<Compile Include="IAimpErrorInfo.cs" />
<Compile Include="Objects\IAimpFileStream.cs" />
<Compile Include="Objects\IAimpImage.cs" />
<Compile Include="IAimpLogger.cs" />
<Compile Include="IAimpProgressCallback.cs" />
<Compile Include="IAimpService.cs" />
Expand Down Expand Up @@ -102,12 +105,15 @@
<Compile Include="IAimpExternalSettingsDialog.cs" />
<Compile Include="IAimpObject.cs" />
<Compile Include="IAimpObjectList.cs" />
<Compile Include="IAimpStream.cs" />
<Compile Include="Objects\IAimpMemoryStream.cs" />
<Compile Include="Objects\IAimpStream.cs" />
<Compile Include="Lyrics\IAimpLyrics.cs" />
<Compile Include="Lyrics\IAimpServiceLyrics.cs" />
<Compile Include="MessageDispatcher\IAimpMessageHook.cs" />
<Compile Include="MessageDispatcher\IAimpServiceMessageDispatcher.cs" />
<Compile Include="MessageDispatcher\PointerExtension.cs" />
<Compile Include="MusicLibrary\DataStorage\AimpDataField.cs" />
<Compile Include="Objects\IAimpImage2.cs" />
<Compile Include="Objects\IAimpString.cs" />
<Compile Include="MusicLibrary\DataFilter\IAimpDataFieldFilter.cs" />
<Compile Include="MusicLibrary\DataFilter\IAimpDataFieldFilterByArray.cs" />
Expand Down
6 changes: 6 additions & 0 deletions src/AIMP.SDK/AimpPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
// ----------------------------------------------------

using System;
using System.IO;
using System.Threading;
using AIMP.SDK.MessageDispatcher;
using AIMP.SDK.Player;

namespace AIMP.SDK
Expand Down Expand Up @@ -84,6 +87,9 @@ internal void OnInitialize(IAimpPlayer player, int unId)
{
PluginId = unId;
AimpPlayer = player;
var path = Path.GetDirectoryName(GetType().Assembly.Location);
AppDomain.CurrentDomain.SetData("APPBASE", path);
Environment.CurrentDirectory = path;
Initialize();
}
}
Expand Down
19 changes: 9 additions & 10 deletions src/AIMP.SDK/FileManager/IAimpServiceFileStreaming.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,35 @@ public enum FileStreamingType
/// <summary>
/// The aimp service filestreaming flag read
/// </summary>
AIMP_SERVICE_FILESTREAMING_FLAG_READ = 0,
Read = 0,

/// <summary>
/// The aimp service filestreaming flag createnew
/// </summary>
AIMP_SERVICE_FILESTREAMING_FLAG_CREATENEW = 1,
CreateNew = 1,

/// <summary>
/// The aimp service filestreaming flag readwrite
/// </summary>
AIMP_SERVICE_FILESTREAMING_FLAG_READWRITE = 2,
ReadWrite = 2,

/// <summary>
/// The aimp service filestreaming flag maptomemory
/// </summary>
AIMP_SERVICE_FILESTREAMING_FLAG_MAPTOMEMORY = 4
MapToMemory = 4
}

/// <summary>
/// Class CeateStreamResult.
/// </summary>
public class CeateStreamResult
public class CreateStreamResult
{
/// <summary>
/// Initializes a new instance of the <see cref="CeateStreamResult" /> class.
/// Initializes a new instance of the <see cref="CreateStreamResult" /> class.
/// </summary>
/// <param name="virtualFile">The virtual file.</param>
/// <param name="stream">The stream.</param>
public CeateStreamResult(IAimpVirtualFile virtualFile, IAimpStream stream)
public CreateStreamResult(IAimpVirtualFile virtualFile, IAimpStream stream)
{
VirtualFile = virtualFile;
Stream = stream;
Expand Down Expand Up @@ -84,14 +84,13 @@ public interface IAimpServiceFileStreaming : IAimpService
/// <param name="offset">The offset.</param>
/// <param name="size">The size.</param>
/// <returns>AimpActionResult&lt;IAimpStream&gt;.</returns>
AimpActionResult<IAimpStream> CreateStreamForFile(string fileName, FileStreamingType flags, long offset,
long size);
AimpActionResult<IAimpStream> CreateStreamForFile(string fileName, FileStreamingType flags, long offset, long size);

/// <summary>
/// Creates the stream for file URI.
/// </summary>
/// <param name="fileUrl">The file URL.</param>
/// <returns>AimpActionResult&lt;CeateStreamResult&gt;.</returns>
AimpActionResult<CeateStreamResult> CreateStreamForFileUri(string fileUrl);
AimpActionResult<CreateStreamResult> CreateStreamForFileUri(string fileUrl);
}
}
Loading

0 comments on commit 544502b

Please sign in to comment.