Skip to content

Commit 8e07683

Browse files
committed
Fix TaglibSharp build
1 parent 3685d3d commit 8e07683

File tree

5 files changed

+94
-174
lines changed

5 files changed

+94
-174
lines changed

src/TaglibSharp/CorruptFileException.cs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -140,28 +140,5 @@ public CorruptFileException (string message, Exception innerException)
140140
: base (message, innerException)
141141
{
142142
}
143-
144-
/// <summary>
145-
/// Constructs and initializes a new instance of <see
146-
/// cref="CorruptFileException" /> from a specified
147-
/// serialization info and streaming context.
148-
/// </summary>
149-
/// <param name="info">
150-
/// A <see cref="SerializationInfo" /> object containing the
151-
/// serialized data to be used for the new instance.
152-
/// </param>
153-
/// <param name="context">
154-
/// A <see cref="StreamingContext" /> object containing the
155-
/// streaming context information for the new instance.
156-
/// </param>
157-
/// <remarks>
158-
/// This constructor is implemented because <see
159-
/// cref="CorruptFileException" /> implements the <see
160-
/// cref="ISerializable" /> interface.
161-
/// </remarks>
162-
protected CorruptFileException (SerializationInfo info, StreamingContext context)
163-
: base (info, context)
164-
{
165-
}
166143
}
167144
}

src/TaglibSharp/File.cs

Lines changed: 40 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// Copyright (C) 2005, 2007 Brian Nickel
1313
// Copyright (C) 2006 Novell, Inc.
1414
// Copyright (C) 2002,2003 Scott Wheeler (Original Implementation)
15-
//
15+
//
1616
// This library is free software; you can redistribute it and/or modify
1717
// it under the terms of the GNU Lesser General Public License version
1818
// 2.1 as published by the Free Software Foundation.
@@ -28,11 +28,8 @@
2828
// USA
2929
//
3030

31-
using System;
32-
using System.Collections.Generic;
3331
using System.Globalization;
34-
using System.IO;
35-
using System.Runtime.Serialization;
32+
using System.Runtime.ExceptionServices;
3633

3734
namespace TagLib
3835
{
@@ -56,10 +53,10 @@ public enum ReadStyle
5653
Average = 2,
5754

5855
/// <summary>
59-
/// Use the <see cref="PictureLazy"/> class in the
60-
/// the property <see cref="Tag.Pictures"/>.
56+
/// Use the <see cref="PictureLazy"/> class in the
57+
/// the property <see cref="Tag.Pictures"/>.
6158
/// This will avoid loading picture content when reading the Tag.
62-
/// Picture will be read lazily, when the picture content is
59+
/// Picture will be read lazily, when the picture content is
6360
/// accessed.
6461
/// </summary>
6562
PictureLazy = 4
@@ -148,7 +145,7 @@ public enum AccessMode
148145
/// methods.</para>
149146
/// <para>If the resolver returns a new <see cref="File" />,
150147
/// it will instantly be returned, by <see
151-
/// cref="Create(string)" />. If it returns <see
148+
/// cref="Create(string)" />. If it returns <see
152149
/// langword="null" />, <see cref="Create(string)" /> will
153150
/// continue to process. If the resolver throws an exception
154151
/// it will be uncaught.</para>
@@ -526,15 +523,15 @@ public void Dispose ()
526523
/// TagLib.Id3v2.Tag id3 = file.GetTag (TagLib.TagTypes.Id3v2, true);
527524
/// if (id3 != null)
528525
/// id3.SetTextFrame ("TMOO", moods);
529-
///
526+
///
530527
/// TagLib.Asf.Tag asf = file.GetTag (TagLib.TagTypes.Asf, true);
531528
/// if (asf != null)
532529
/// asf.SetDescriptorStrings (moods, "WM/Mood", "Mood");
533-
///
530+
///
534531
/// TagLib.Ape.Tag ape = file.GetTag (TagLib.TagTypes.Ape);
535532
/// if (ape != null)
536533
/// ape.SetValue ("MOOD", moods);
537-
///
534+
///
538535
/// // Whatever tag types you want...
539536
///}</code>
540537
/// </example>
@@ -572,23 +569,23 @@ public void Dispose ()
572569
/// if (f != null)
573570
/// return f.FieldList.ToArray ();
574571
/// }
575-
///
572+
///
576573
/// TagLib.Asf.Tag asf = file.GetTag (TagLib.TagTypes.Asf);
577574
/// if (asf != null) {
578575
/// string [] value = asf.GetDescriptorStrings ("WM/Mood", "Mood");
579576
/// if (value.Length &gt; 0)
580577
/// return value;
581578
/// }
582-
///
579+
///
583580
/// TagLib.Ape.Tag ape = file.GetTag (TagLib.TagTypes.Ape);
584581
/// if (ape != null) {
585582
/// Item item = ape.GetItem ("MOOD");
586583
/// if (item != null)
587584
/// return item.ToStringArray ();
588585
/// }
589-
///
586+
///
590587
/// // Whatever tag types you want...
591-
///
588+
///
592589
/// return new string [] {};
593590
///}</code>
594591
/// </example>
@@ -831,7 +828,7 @@ long RFind (ByteVector pattern, long startPosition, ByteVector after)
831828
*/
832829

833830
// Save the location of the current read pointer. We
834-
// will restore the position using Seek() before all
831+
// will restore the position using Seek() before all
835832
// returns.
836833

837834
long original_position = file_stream.Position;
@@ -985,7 +982,7 @@ public void Insert (ByteVector data, long start)
985982
/// <summary>
986983
/// Inserts a specified block-size into the file repesented
987984
/// by the current instance at a specified location. Former
988-
/// data at this location is not overwriten and may then
985+
/// data at this location is not overwriten and may then
989986
/// contain random content.
990987
/// </summary>
991988
/// <param name="size">
@@ -999,8 +996,8 @@ public void Insert (ByteVector data, long start)
999996
/// <remarks>
1000997
/// This method is usefull to reserve some space in the file.
1001998
/// To insert or replace defined data blocks, use <see
1002-
/// cref="Insert(ByteVector,long)" /> or
1003-
/// <see cref="Insert(ByteVector,long,long)"/>
999+
/// cref="Insert(ByteVector,long)" /> or
1000+
/// <see cref="Insert(ByteVector,long,long)"/>
10041001
/// </remarks>
10051002
public void Insert (long size, long start)
10061003
{
@@ -1321,8 +1318,15 @@ public static File Create (IFileAbstraction abstraction, string mimetype, ReadSt
13211318
file.MimeType = mimetype;
13221319
return file;
13231320
} catch (System.Reflection.TargetInvocationException e) {
1324-
PrepareExceptionForRethrow (e.InnerException);
1321+
#if NETSTANDARD2_0
1322+
// .NET Standard 2.0: Stack trace will be lost when rethrowing inner exception.
1323+
// This is a limitation of .NET Standard 2.0.
13251324
throw e.InnerException;
1325+
#else
1326+
// Modern .NET: preserve stack trace
1327+
ExceptionDispatchInfo.Capture (e.InnerException).Throw ();
1328+
throw; // Unreachable, but required for compiler
1329+
#endif
13261330
}
13271331
}
13281332

@@ -1335,7 +1339,7 @@ public static File Create (IFileAbstraction abstraction, string mimetype, ReadSt
13351339
/// file type recognition stack.
13361340
/// </param>
13371341
/// <remarks>
1338-
/// A <see cref="FileTypeResolver" /> adds support for
1342+
/// A <see cref="FileTypeResolver" /> adds support for
13391343
/// recognizing a file type outside of the standard mime-type
13401344
/// methods.
13411345
/// </remarks>
@@ -1352,7 +1356,7 @@ public static void AddFileTypeResolver (FileTypeResolver resolver)
13521356
#region Private/Protected Methods
13531357

13541358
/// <summary>
1355-
/// Prepare to Save the file. Thismust be called at the begining
1359+
/// Prepare to Save the file. Thismust be called at the begining
13561360
/// of every File.Save() method.
13571361
/// </summary>
13581362
protected void PreSave ()
@@ -1383,7 +1387,7 @@ protected void PreSave ()
13831387
/// <param name="data">
13841388
/// A <see cref="ByteVector" /> object containing the data to
13851389
/// insert into the file. if null, no data is writen to the
1386-
/// file and the block is just inserted without overwriting the
1390+
/// file and the block is just inserted without overwriting the
13871391
/// former data at the given location.
13881392
/// </param>
13891393
/// <param name="size">
@@ -1451,8 +1455,8 @@ void Insert (ByteVector data, long size, long start, long replace)
14511455
byte[] buffer;
14521456
byte[] about_to_overwrite;
14531457

1454-
// This is basically a special case of the loop below.
1455-
// Here we're just doing the same steps as below, but
1458+
// This is basically a special case of the loop below.
1459+
// Here we're just doing the same steps as below, but
14561460
// since we aren't using the same buffer size -- instead
14571461
// we're using the tag size -- this has to be handled as
14581462
// a special case. We're also using File::writeBlock()
@@ -1476,12 +1480,12 @@ void Insert (ByteVector data, long size, long start, long replace)
14761480
about_to_overwrite.Length);
14771481

14781482
// Ok, here's the main loop. We want to loop until the
1479-
// read fails, which means that we hit the end of the
1483+
// read fails, which means that we hit the end of the
14801484
// file.
14811485

14821486
while (buffer_length != 0) {
14831487
// Seek to the current read position and read
1484-
// the data that we're about to overwrite.
1488+
// the data that we're about to overwrite.
14851489
// Appropriately increment the readPosition.
14861490

14871491
file_stream.Position = read_position;
@@ -1527,25 +1531,8 @@ protected void Truncate (long length)
15271531
Mode = old_mode;
15281532
}
15291533

1530-
/// <summary>
1531-
/// Causes the original strack trace of the exception to be preserved when it is rethrown
1532-
/// </summary>
1533-
/// <param name="ex"></param>
1534-
static void PrepareExceptionForRethrow (Exception ex)
1535-
{
1536-
var ctx = new StreamingContext (StreamingContextStates.CrossAppDomain);
1537-
var mgr = new ObjectManager (null, ctx);
1538-
var si = new SerializationInfo (ex.GetType (), new FormatterConverter ());
1539-
1540-
ex.GetObjectData (si, ctx);
1541-
mgr.RegisterObject (ex, 1, si); // prepare for SetObjectData
1542-
mgr.DoFixups (); // ObjectManager calls SetObjectData
1543-
}
1544-
15451534
#endregion
15461535

1547-
1548-
15491536
#region Classes
15501537

15511538
/// <summary>
@@ -1669,7 +1656,7 @@ public void CloseStream (Stream stream)
16691656
/// return;
16701657
///
16711658
/// Gnome.Vfs.Vfs.Initialize ();
1672-
///
1659+
///
16731660
/// try {
16741661
/// TagLib.File file = TagLib.File.Create (
16751662
/// new VfsFileAbstraction (args [0]));
@@ -1710,24 +1697,24 @@ public void CloseStream (Stream stream)
17101697
///import Gnome.Vfs from "gnome-vfs-sharp"
17111698
///
17121699
///class VfsFileAbstraction (TagLib.File.IFileAbstraction):
1713-
///
1700+
///
17141701
/// _name as string
1715-
///
1702+
///
17161703
/// def constructor(file as string):
17171704
/// _name = file
1718-
///
1705+
///
17191706
/// Name:
17201707
/// get:
17211708
/// return _name
1722-
///
1709+
///
17231710
/// ReadStream:
17241711
/// get:
17251712
/// return VfsStream(_name, FileMode.Open)
1726-
///
1713+
///
17271714
/// WriteStream:
17281715
/// get:
17291716
/// return VfsStream(_name, FileMode.Open)
1730-
///
1717+
///
17311718
///if len(argv) == 1:
17321719
/// Vfs.Initialize()
17331720
///
@@ -1744,7 +1731,7 @@ public interface IFileAbstraction
17441731
/// implementation.
17451732
/// </summary>
17461733
/// <value>
1747-
/// A <see cref="string" /> object containing the
1734+
/// A <see cref="string" /> object containing the
17481735
/// name or identifier used by the implementation.
17491736
/// </value>
17501737
/// <remarks>

src/TaglibSharp/Riff/List.cs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -116,29 +116,6 @@ public List (TagLib.File file, long position, int length)
116116
Parse (file.ReadBlock (length));
117117
}
118118

119-
/// <summary>
120-
/// Constructs and initializes a new instance of <see
121-
/// cref="List" /> from a specified serialization info and
122-
/// streaming context.
123-
/// </summary>
124-
/// <param name="info">
125-
/// A <see cref="SerializationInfo" /> object containing the
126-
/// serialized data to be used for the new instance.
127-
/// </param>
128-
/// <param name="context">
129-
/// A <see cref="StreamingContext" /> object containing the
130-
/// streaming context information for the new instance.
131-
/// </param>
132-
/// <remarks>
133-
/// This constructor is implemented because <see
134-
/// cref="List" /> implements the <see cref="ISerializable"
135-
/// /> interface.
136-
/// </remarks>
137-
protected List (SerializationInfo info, StreamingContext context)
138-
: base (info, context)
139-
{
140-
}
141-
142119
#endregion
143120

144121
#region Public Properties

0 commit comments

Comments
 (0)