Skip to content

Commit ee3584d

Browse files
committed
merge version stuff
2 parents e295e9a + db8098b commit ee3584d

File tree

4 files changed

+97
-96
lines changed

4 files changed

+97
-96
lines changed

global.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"projects": [ "src", "test" ],
3-
"sdk": {
4-
"version": "1.0.0-preview2-003131"
5-
}
3+
"sdk": {
4+
"version": "1.0.0-preview2-003131"
5+
}
66
}

src/FreeImage-dotnet-core/FreeImageWrapper.cs

+76-75
Original file line numberDiff line numberDiff line change
@@ -115,52 +115,52 @@ public static partial class FreeImage
115115

116116
#region General functions
117117

118-
private const string FreeImageVersion = "3.17.0";
119-
120-
/// <summary>
121-
/// Returns the internal version of this FreeImage .NET wrapper.
122-
/// </summary>
123-
/// <returns>The internal version of this FreeImage .NET wrapper.</returns>
124-
public static Version GetWrapperVersion()
125-
{
126-
if (WrapperVersion == null)
127-
{
128-
lock (WrapperVersionLock)
129-
{
130-
if (WrapperVersion == null)
131-
{
132-
Assembly assembly = GetFreeImageAssembly();
133-
AssemblyInformationalVersionAttribute attribute = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
134-
135-
if (attribute == null)
136-
{
137-
throw new InvalidOperationException("Failed to get assembly version attribute");
138-
}
139-
140-
if (string.IsNullOrWhiteSpace(attribute.InformationalVersion))
141-
{
142-
throw new InvalidOperationException("No assembly version present");
143-
}
144-
145-
string version = attribute.InformationalVersion;
146-
147-
string[] versionParts = version.Split(new[] { '-' }, StringSplitOptions.RemoveEmptyEntries);
148-
149-
if (versionParts.Length < 1)
150-
{
151-
throw new InvalidOperationException("Invalid assembly version");
152-
}
153-
154-
if (false == Version.TryParse(versionParts[0], out WrapperVersion))
155-
{
156-
throw new InvalidOperationException("Unable to parse assembly version");
157-
}
158-
}
159-
}
160-
}
161-
162-
return WrapperVersion;
163-
}
118+
private static readonly Version ExpectedNativeFreeImageVersion = new Version("3.17.0");
119+
120+
///// <summary>
121+
///// Returns the internal version of this FreeImage .NET wrapper.
122+
///// </summary>
123+
///// <returns>The internal version of this FreeImage .NET wrapper.</returns>
124+
//public static Version GetWrapperVersion()
125+
//{
126+
// if (WrapperVersion == null)
127+
// {
128+
// lock (WrapperVersionLock)
129+
// {
130+
// if (WrapperVersion == null)
131+
// {
132+
// Assembly assembly = GetFreeImageAssembly();
133+
// AssemblyInformationalVersionAttribute attribute = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
134+
//
135+
// if (attribute == null)
136+
// {
137+
// throw new InvalidOperationException("Failed to get assembly version attribute");
138+
// }
139+
//
140+
// if (string.IsNullOrWhiteSpace(attribute.InformationalVersion))
141+
// {
142+
// throw new InvalidOperationException("No assembly version present");
143+
// }
144+
//
145+
// string version = attribute.InformationalVersion;
146+
//
147+
// string[] versionParts = version.Split(new[] { '-' }, StringSplitOptions.RemoveEmptyEntries);
148+
//
149+
// if (versionParts.Length < 1)
150+
// {
151+
// throw new InvalidOperationException("Invalid assembly version");
152+
// }
153+
//
154+
// if (false == Version.TryParse(versionParts[0], out WrapperVersion))
155+
// {
156+
// throw new InvalidOperationException("Unable to parse assembly version");
157+
// }
158+
// }
159+
// }
160+
// }
161+
//
162+
// return WrapperVersion;
163+
//}
164164

165165
internal static Assembly GetFreeImageAssembly()
166166
{
@@ -185,36 +185,37 @@ public static Version GetNativeVersion()
185185
return new Version(GetVersion());
186186
}
187187

188-
/// <summary>
189-
/// Validates that the FreeImage library is available on the system - throws an exception if not
190-
/// </summary>
191-
/// <remarks>
192-
/// The FreeImage.NET library is a wrapper for the native C++ library
193-
/// (FreeImage.dll ... dont mix ist up with this library FreeImageNet.dll).
194-
/// The native library <b>must</b> be either in the same folder as the program's
195-
/// executable or in a folder contained in the envirent variable <i>PATH</i>
196-
/// (for example %WINDIR%\System32).<para/>
197-
/// Further more must both libraries, including the program itself,
198-
/// be the same architecture (x86 or x64) and be a compatible version.
199-
/// </remarks>
200-
public static void ValidateAvailability()
201-
{
202-
try
203-
{
204-
Version nativeVersion = new Version(GetVersion());
205-
Version wrapperVersion = GetWrapperVersion();
188+
/// <summary>
189+
/// Validates that the FreeImage library is available on the system - throws an exception if not
190+
/// </summary>
191+
/// <remarks>
192+
/// The FreeImage.NET library is a wrapper for the native C++ library
193+
/// (FreeImage.dll ... dont mix ist up with this library FreeImageNet.dll).
194+
/// The native library <b>must</b> be either in the same folder as the program's
195+
/// executable or in a folder contained in the envirent variable <i>PATH</i>
196+
/// (for example %WINDIR%\System32).<para/>
197+
/// Further more must both libraries, including the program itself,
198+
/// be the same architecture (x86 or x64) and be a compatible version.
199+
/// </remarks>
200+
public static void ValidateAvailability()
201+
{
202+
try
203+
{
204+
Version nativeVersion = new Version(GetVersion());
205+
//Version wrapperVersion = GetWrapperVersion();
206206

207-
if (false == ((nativeVersion.Major > wrapperVersion.Major) ||
208-
((nativeVersion.Major == wrapperVersion.Major) && (nativeVersion.Minor > wrapperVersion.Minor)) ||
209-
((nativeVersion.Major == wrapperVersion.Major) && (nativeVersion.Minor == wrapperVersion.Minor) && (nativeVersion.Build >= wrapperVersion.Build))))
210-
{
211-
throw new FreeImageException("FreeImage library version mismatch");
212-
}
213-
}
214-
catch (DllNotFoundException e)
215-
{
216-
throw new FreeImageException("FreeImage library not found", e);
217-
}
207+
//if (false == ((nativeVersion.Major > wrapperVersion.Major) ||
208+
// ((nativeVersion.Major == wrapperVersion.Major) && (nativeVersion.Minor > wrapperVersion.Minor)) ||
209+
// ((nativeVersion.Major == wrapperVersion.Major) && (nativeVersion.Minor == wrapperVersion.Minor) && (nativeVersion.Build >= wrapperVersion.Build))))
210+
if (nativeVersion != ExpectedNativeFreeImageVersion)
211+
{
212+
throw new FreeImageException("FreeImage library version mismatch");
213+
}
214+
}
215+
catch (DllNotFoundException e)
216+
{
217+
throw new FreeImageException("FreeImage library not found", e);
218+
}
218219
#if NET462 || NET461 || NET46 || NET452 || NET451 || NET45 || NET40 || NET35 || NET20
219220
catch (EntryPointNotFoundException e)
220221
{

src/FreeImage-dotnet-core/project.json

+17-17
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "3.17.1-*",
2+
"version": "4.0.0-*",
33
"title": "FreeImage dotnet core",
44
"copyright": "(c) 2016-present Matt Graham",
55
"authors": [ "Matt Graham" ],
@@ -14,22 +14,22 @@
1414
]
1515
},
1616

17-
"packOptions": {
18-
"iconUrl": "http://freeimage.sourceforge.net/images/logo.jpg",
19-
"licenseUrl": "http://freeimage.sourceforge.net/license.html",
20-
"projectUrl": "https://github.com/matgr1/FreeImage-dotnet-core",
21-
"repository": {
22-
"type": "git",
23-
"url": "https://github.com/matgr1/FreeImage-dotnet-core"
24-
},
25-
"tags": [ "FreeImage", "netcore", "dotnetcore" ],
26-
"files": {
27-
"mappings": {
28-
"runtimes/win7-x86/native/": [ "../../runtimes/win7-x86/native/FreeImage.dll" ],
29-
"runtimes/win7-x64/native/": [ "../../runtimes/win7-x64/native/FreeImage.dll" ]
30-
}
31-
}
32-
},
17+
"packOptions": {
18+
"iconUrl": "http://freeimage.sourceforge.net/images/logo.jpg",
19+
"licenseUrl": "http://freeimage.sourceforge.net/license.html",
20+
"projectUrl": "https://github.com/matgr1/FreeImage-dotnet-core",
21+
"repository": {
22+
"type": "git",
23+
"url": "https://github.com/matgr1/FreeImage-dotnet-core"
24+
},
25+
"tags": [ "FreeImage", "netcore", "dotnetcore" ],
26+
"files": {
27+
"mappings": {
28+
"runtimes/win7-x86/native/": [ "../../runtimes/win7-x86/native/FreeImage.dll" ],
29+
"runtimes/win7-x64/native/": [ "../../runtimes/win7-x64/native/FreeImage.dll" ]
30+
}
31+
}
32+
},
3333

3434
"dependencies": {
3535
"NETStandard.Library": "1.6.0"

src/UnitTest/project.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"dependencies": {
1414
"dotnet-test-nunit": "3.4.0-beta-2",
1515
"FreeImage-dotnet-core": {
16-
"version": "3.17.1-*",
16+
"version": "4.0.0-*",
1717
"target": "project"
1818
},
1919
"NUnit": "3.4.1"

0 commit comments

Comments
 (0)