Skip to content

Commit 6d79ebd

Browse files
authored
Merge pull request #443 from drewnoakes/update-target-frameworks
Update target frameworks
2 parents f853c28 + 327e70a commit 6d79ebd

32 files changed

+83
-113
lines changed

Annotations.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
44

5-
#if NETFRAMEWORK || NETSTANDARD1_3
5+
#if NETSTANDARD2_0
66

77
namespace System.Diagnostics.CodeAnalysis
88
{

Directory.Build.props

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@
2121

2222
<!-- https://aka.ms/vs-build-acceleration -->
2323
<AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio>
24+
25+
<ModernDotNetTargetFrameworkAlias>net8.0</ModernDotNetTargetFrameworkAlias>
2426
</PropertyGroup>
2527

2628
<ItemGroup>
2729
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
28-
29-
<!-- Avoid needing to have targeting packs installed for .NET Framework. -->
30-
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="All" />
3130
</ItemGroup>
3231

3332
<!-- Analyzers -->
Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net461</TargetFramework>
4+
<TargetFramework>$(ModernDotNetTargetFrameworkAlias)</TargetFramework>
55
<OutputType>Exe</OutputType>
66
</PropertyGroup>
77

@@ -13,15 +13,4 @@
1313
<PackageReference Include="BenchmarkDotNet" Version="0.13.5" />
1414
</ItemGroup>
1515

16-
<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
17-
<Reference Include="System.Windows" />
18-
<Reference Include="PresentationCore" />
19-
<Reference Include="PresentationFramework" />
20-
<Reference Include="WindowsBase" />
21-
<Reference Include="System.Xaml" />
22-
<Reference Include="System.Drawing" />
23-
<Reference Include="System" />
24-
<Reference Include="Microsoft.CSharp" />
25-
</ItemGroup>
26-
2716
</Project>

MetadataExtractor.Benchmarks/Program.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
// Copyright (c) Drew Noakes and contributors. All Rights Reserved. Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
22

3-
using System.Drawing;
4-
using System.Text.RegularExpressions;
53
using BenchmarkDotNet.Attributes;
64
using BenchmarkDotNet.Running;
75
using MetadataExtractor.Formats.Exif;
86
using MetadataExtractor.Formats.Jpeg;
7+
8+
#if !NET
9+
using System.Drawing;
10+
using System.Text.RegularExpressions;
911
using System.Windows.Media.Imaging;
12+
#endif
1013

1114
namespace MetadataExtractor.Benchmarks
1215
{
@@ -108,6 +111,7 @@ public DateTime ImageMetadataReaderBenchmark()
108111
return subIfdDirectory.GetDateTime(ExifDirectoryBase.TagDateTimeOriginal);
109112
}
110113

114+
#if !NET
111115
private readonly Regex _dateTimeRegex = new Regex(":");
112116

113117
[Benchmark]
@@ -145,5 +149,6 @@ public DateTime WpfJpegBitmapDecoderBenchmark()
145149
var dateTakenStr = (string)metadata.GetQuery("/app1/ifd/exif/subifd:{uint=36867}");
146150
return DateTime.Parse(_dateTimeRegex.Replace(dateTakenStr, "-", count: 2));
147151
}
152+
#endif
148153
}
149154
}

MetadataExtractor.Tests/MetadataExtractor.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net8.0;net472</TargetFrameworks>
4+
<TargetFrameworks>$(ModernDotNetTargetFrameworkAlias);net472</TargetFrameworks>
55

66
<RootNamespace>MetadataExtractor</RootNamespace>
77

MetadataExtractor.Tools.FileProcessor/DeconstructionExtensions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#if NETFRAMEWORK
44

5+
#pragma warning disable IDE0130 // Namespace does not match folder structure
6+
57
namespace System.Collections.Generic;
68

79
internal static class DeconstructionExtensions

MetadataExtractor.Tools.FileProcessor/MetadataExtractor.Tools.FileProcessor.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net8.0;net48</TargetFrameworks>
4+
<TargetFrameworks>$(ModernDotNetTargetFrameworkAlias);net48</TargetFrameworks>
55
<OutputType>Exe</OutputType>
66
</PropertyGroup>
77

8-
<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0'">
8+
<PropertyGroup Condition="'$(TargetFramework)' == '$(ModernDotNetTargetFrameworkAlias)'">
99
<PublishTrimmed>true</PublishTrimmed>
1010
<PublishAot>true</PublishAot>
1111
<InvariantGlobalization>true</InvariantGlobalization>

MetadataExtractor.Tools.JpegSegmentExtractor/MetadataExtractor.Tools.JpegSegmentExtractor.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>$(ModernDotNetTargetFrameworkAlias)</TargetFramework>
55
<OutputType>Exe</OutputType>
66
</PropertyGroup>
77

MetadataExtractor/Formats/Exif/ExifTiffHandler.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -538,11 +538,7 @@ private bool ProcessMakernote(in TiffReaderContext context, int makernoteOffset)
538538
PushDirectory(new OlympusMakernoteDirectory());
539539
TiffReader.ProcessIfd(this, context, ifdOffset: makernoteOffset);
540540
}
541-
#if NETSTANDARD1_3 || NET462
542-
else if (cameraMake is not null && cameraMake.TrimStart().StartsWith("NIKON", StringComparison.OrdinalIgnoreCase))
543-
#else
544-
else if (cameraMake is not null && cameraMake.AsSpan().TrimStart().StartsWith("NIKON", StringComparison.OrdinalIgnoreCase))
545-
#endif
541+
else if (cameraMake is not null && cameraMake.AsSpan().TrimStart().StartsWith("NIKON".AsSpan(), StringComparison.OrdinalIgnoreCase))
546542
{
547543
if (headerBytes.StartsWith("Nikon"u8))
548544
{

MetadataExtractor/Formats/Icc/IccDescriptor.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@ private enum IccTagType
5656
{
5757
case IccTagType.Text:
5858
{
59-
#if !NETSTANDARD1_3
59+
Span<byte> textBytes = bytes.AsSpan(start: 8, length: bytes.Length - 8 - 1);
60+
6061
try
6162
{
62-
return Encoding.ASCII.GetString(bytes, 8, bytes.Length - 8 - 1);
63+
return Encoding.ASCII.GetString(textBytes);
6364
}
6465
catch
65-
#endif
6666
{
67-
return Encoding.UTF8.GetString(bytes, 8, bytes.Length - 8 - 1);
67+
return Encoding.UTF8.GetString(textBytes);
6868
}
6969
}
7070

MetadataExtractor/Formats/Iptc/Iso2022Converter.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,7 @@ public static class Iso2022Converter
6161

6262
if (ascii)
6363
{
64-
#if NETSTANDARD1_3
65-
return Encoding.UTF8;
66-
#else
6764
return Encoding.ASCII;
68-
#endif
6965
}
7066

7167
var utf8 = false;
@@ -97,7 +93,7 @@ public static class Iso2022Converter
9793
{
9894
int charCount = encoding.GetChars(bytes, 0, bytes.Length, charBuffer, 0);
9995

100-
if (charBuffer.AsSpan(0, charCount).IndexOf((char)65533) != -1)
96+
if (charBuffer.AsSpan(0, charCount).IndexOf((char)0xFFFD) != -1)
10197
continue;
10298
return encoding;
10399
}

MetadataExtractor/Formats/Jpeg/JpegComponent.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace MetadataExtractor.Formats.Jpeg
77
/// quantization table number.
88
/// </summary>
99
/// <author>Drew Noakes https://drewnoakes.com</author>
10-
#if !NETSTANDARD1_3
10+
#if !NET8_0_OR_GREATER
1111
[Serializable]
1212
#endif
1313
public sealed class JpegComponent

MetadataExtractor/Formats/Jpeg/JpegProcessingException.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
// Copyright (c) Drew Noakes and contributors. All Rights Reserved. Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
22

3-
#if !NETSTANDARD1_3 && !NET8_0_OR_GREATER
3+
#if !NET8_0_OR_GREATER
44
using System.Runtime.Serialization;
55
#endif
66

77
namespace MetadataExtractor.Formats.Jpeg
88
{
99
/// <summary>An exception class thrown upon unexpected and fatal conditions while processing a JPEG file.</summary>
1010
/// <author>Drew Noakes https://drewnoakes.com</author>
11-
#if !NETSTANDARD1_3 && !NET8_0_OR_GREATER
11+
#if !NET8_0_OR_GREATER
1212
[Serializable]
1313
#endif
1414
public class JpegProcessingException : ImageProcessingException
@@ -28,7 +28,7 @@ public JpegProcessingException(Exception? innerException)
2828
{
2929
}
3030

31-
#if !NETSTANDARD1_3 && !NET8_0_OR_GREATER
31+
#if !NET8_0_OR_GREATER
3232
protected JpegProcessingException(SerializationInfo info, StreamingContext context)
3333
: base(info, context)
3434
{

MetadataExtractor/Formats/Png/PngColorType.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace MetadataExtractor.Formats.Png
44
{
55
/// <author>Drew Noakes https://drewnoakes.com</author>
6-
#if !NETSTANDARD1_3 && !NET8_0_OR_GREATER
6+
#if !NET8_0_OR_GREATER
77
[Serializable]
88
#endif
99
public sealed class PngColorType

MetadataExtractor/Formats/Png/PngProcessingException.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
// Copyright (c) Drew Noakes and contributors. All Rights Reserved. Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
22

3-
#if !NETSTANDARD1_3 && !NET8_0_OR_GREATER
3+
#if !NET8_0_OR_GREATER
44
using System.Runtime.Serialization;
55
#endif
66

77
namespace MetadataExtractor.Formats.Png
88
{
99
/// <summary>An exception class thrown upon unexpected and fatal conditions while processing a JPEG file.</summary>
1010
/// <author>Drew Noakes https://drewnoakes.com</author>
11-
#if !NETSTANDARD1_3 && !NET8_0_OR_GREATER
11+
#if !NET8_0_OR_GREATER
1212
[Serializable]
1313
#endif
1414
public class PngProcessingException : ImageProcessingException
@@ -28,7 +28,7 @@ public PngProcessingException(Exception? innerException)
2828
{
2929
}
3030

31-
#if !NETSTANDARD1_3 && !NET8_0_OR_GREATER
31+
#if !NET8_0_OR_GREATER
3232
protected PngProcessingException(SerializationInfo info, StreamingContext context)
3333
: base(info, context)
3434
{

MetadataExtractor/Formats/QuickTime/QuickTimeReaderExtensions.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ namespace MetadataExtractor.Formats.QuickTime
77
/// </summary>
88
public static class QuickTimeReaderExtensions
99
{
10-
#if NET462 || NETSTANDARD1_3
11-
public static unsafe string Get4ccString(this SequentialReader reader)
12-
#else
1310
public static string Get4ccString(this SequentialReader reader)
14-
#endif
1511
{
1612
// https://en.wikipedia.org/wiki/FourCC
1713

@@ -28,14 +24,7 @@ public static string Get4ccString(this SequentialReader reader)
2824
(char)bytes[3]
2925
];
3026

31-
#if NET462 || NETSTANDARD1_3
32-
fixed (char* pChars = chars)
33-
{
34-
return new string(pChars, startIndex: 0, length: 4);
35-
}
36-
#else
37-
return new string(chars);
38-
#endif
27+
return chars.ToString();
3928
}
4029

4130
public static decimal Get16BitFixedPoint(this SequentialReader reader)

MetadataExtractor/Formats/Riff/RiffProcessingException.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
// Copyright (c) Drew Noakes and contributors. All Rights Reserved. Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
22

3-
#if !NETSTANDARD1_3 && !NET8_0_OR_GREATER
3+
#if !NET8_0_OR_GREATER
44
using System.Runtime.Serialization;
55
#endif
66

77
namespace MetadataExtractor.Formats.Riff
88
{
99
/// <summary>An exception class thrown upon unexpected and fatal conditions while processing a RIFF file.</summary>
1010
/// <author>Drew Noakes https://drewnoakes.com</author>
11-
#if !NETSTANDARD1_3 && !NET8_0_OR_GREATER
11+
#if !NET8_0_OR_GREATER
1212
[Serializable]
1313
#endif
1414
public class RiffProcessingException : ImageProcessingException
@@ -28,7 +28,7 @@ public RiffProcessingException(Exception? innerException)
2828
{
2929
}
3030

31-
#if !NETSTANDARD1_3 && !NET8_0_OR_GREATER
31+
#if !NET8_0_OR_GREATER
3232
protected RiffProcessingException(SerializationInfo info, StreamingContext context)
3333
: base(info, context)
3434
{

MetadataExtractor/Formats/Tiff/TiffProcessingException.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Copyright (c) Drew Noakes and contributors. All Rights Reserved. Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
22

3-
#if !NETSTANDARD1_3 && !NET8_0_OR_GREATER
3+
#if !NET8_0_OR_GREATER
44
using System.Runtime.Serialization;
55
#endif
66

@@ -9,7 +9,7 @@ namespace MetadataExtractor.Formats.Tiff
99
/// <summary>An exception class thrown upon unexpected and fatal conditions while processing a TIFF file.</summary>
1010
/// <author>Drew Noakes https://drewnoakes.com</author>
1111
/// <author>Darren Salomons</author>
12-
#if !NETSTANDARD1_3 && !NET8_0_OR_GREATER
12+
#if !NET8_0_OR_GREATER
1313
[Serializable]
1414
#endif
1515
public class TiffProcessingException : ImageProcessingException
@@ -29,7 +29,7 @@ public TiffProcessingException(Exception? innerException)
2929
{
3030
}
3131

32-
#if !NETSTANDARD1_3 && !NET8_0_OR_GREATER
32+
#if !NET8_0_OR_GREATER
3333
protected TiffProcessingException(SerializationInfo info, StreamingContext context)
3434
: base(info, context)
3535
{

MetadataExtractor/IO/BufferBoundsException.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Copyright (c) Drew Noakes and contributors. All Rights Reserved. Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
22

3-
#if !NETSTANDARD1_3 && !NET8_0_OR_GREATER
3+
#if !NET8_0_OR_GREATER
44
using System.Runtime.Serialization;
55
#endif
66

@@ -10,7 +10,7 @@ namespace MetadataExtractor.IO
1010
/// Thrown when the index provided to an <see cref="IndexedReader"/> is invalid.
1111
/// </summary>
1212
/// <author>Drew Noakes https://drewnoakes.com</author>
13-
#if !NETSTANDARD1_3 && !NET8_0_OR_GREATER
13+
#if !NET8_0_OR_GREATER
1414
[Serializable]
1515
#endif
1616
public class BufferBoundsException : IOException
@@ -43,7 +43,7 @@ private static string GetMessage(int index, int bytesRequested, long bufferLengt
4343
return $"Attempt to read from beyond end of underlying data source (requested index: {index}, requested count: {bytesRequested}, max index: {bufferLength - 1})";
4444
}
4545

46-
#if !NETSTANDARD1_3 && !NET8_0_OR_GREATER
46+
#if !NET8_0_OR_GREATER
4747
protected BufferBoundsException(SerializationInfo info, StreamingContext context)
4848
: base(info, context)
4949
{

MetadataExtractor/IO/BufferReader.Indexed.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public readonly long GetInt64(int index)
129129
/// <exception cref="IOException"/>
130130
public readonly float GetFloat32(int index)
131131
{
132-
#if NET462 || NETSTANDARD1_3
132+
#if NETSTANDARD2_0
133133
return BitConverter.ToSingle(BitConverter.GetBytes(GetInt32(index)), 0);
134134
#else
135135
Span<byte> bytes = stackalloc byte[4];
@@ -153,7 +153,7 @@ public readonly float GetFloat32(int index)
153153

154154
public readonly double GetDouble64(int index)
155155
{
156-
#if NET462 || NETSTANDARD1_3
156+
#if NETSTANDARD2_0
157157
return BitConverter.Int64BitsToDouble(GetInt64(index));
158158
#else
159159
Span<byte> bytes = stackalloc byte[8];

MetadataExtractor/IO/IndexedCapturingReader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public void Dispose()
143143

144144
private void GetPosition(int index, out int chunkIndex, out int innerIndex)
145145
{
146-
#if NET462 || NETSTANDARD2_1
146+
#if NETSTANDARD2_1
147147
chunkIndex = Math.DivRem(index, _chunkLength, out innerIndex);
148148
#elif NET6_0_OR_GREATER
149149
(chunkIndex, innerIndex) = Math.DivRem(index, _chunkLength);

MetadataExtractor/IO/IndexedReader.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ public float GetS15Fixed16(int index)
280280
/// <exception cref="IOException"/>
281281
public float GetFloat32(int index)
282282
{
283-
#if NET462 || NETSTANDARD1_3
283+
#if NETSTANDARD2_0
284284
return BitConverter.ToSingle(BitConverter.GetBytes(GetInt32(index)), 0);
285285
#else
286286
Span<byte> bytes = stackalloc byte[4];
@@ -299,7 +299,7 @@ public float GetFloat32(int index)
299299
/// <exception cref="IOException"/>
300300
public double GetDouble64(int index)
301301
{
302-
#if NET462 || NETSTANDARD1_3
302+
#if NETSTANDARD2_0
303303
return BitConverter.Int64BitsToDouble(GetInt64(index));
304304
#else
305305
Span<byte> bytes = stackalloc byte[8];

0 commit comments

Comments
 (0)