mirror of
				https://github.com/jellyfin/jellyfin.git
				synced 2025-10-31 10:37:22 -04:00 
			
		
		
		
	Merge pull request #4749 from crobibero/guid-standard
This commit is contained in:
		
						commit
						933e7fa159
					
				| @ -1,4 +1,5 @@ | ||||
| using System; | ||||
| using System.Globalization; | ||||
| using System.Text.Json; | ||||
| using System.Text.Json.Serialization; | ||||
| 
 | ||||
| @ -19,7 +20,7 @@ namespace MediaBrowser.Common.Json.Converters | ||||
|         /// <inheritdoc /> | ||||
|         public override void Write(Utf8JsonWriter writer, Guid value, JsonSerializerOptions options) | ||||
|         { | ||||
|             writer.WriteStringValue(value); | ||||
|             writer.WriteStringValue(value.ToString("N", CultureInfo.InvariantCulture)); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -1,4 +1,5 @@ | ||||
| using System; | ||||
| using System.Globalization; | ||||
| using System.Text.Json; | ||||
| using MediaBrowser.Common.Json.Converters; | ||||
| using Xunit; | ||||
| @ -46,7 +47,23 @@ namespace Jellyfin.Common.Tests.Json | ||||
|         [Fact] | ||||
|         public void Serialize_EmptyGuid_EmptyGuid() | ||||
|         { | ||||
|             Assert.Equal($"\"{Guid.Empty}\"", JsonSerializer.Serialize(Guid.Empty, _options)); | ||||
|             Assert.Equal($"\"{Guid.Empty:N}\"", JsonSerializer.Serialize(Guid.Empty, _options)); | ||||
|         } | ||||
| 
 | ||||
|         [Fact] | ||||
|         public void Serialize_Valid_NoDash_Success() | ||||
|         { | ||||
|             var guid = new Guid("531797E9-9457-40E0-88BC-B1D6D38752FA"); | ||||
|             var str = JsonSerializer.Serialize(guid, _options); | ||||
|             Assert.Equal($"\"{guid:N}\"", str); | ||||
|         } | ||||
| 
 | ||||
|         [Fact] | ||||
|         public void Serialize_Nullable_Success() | ||||
|         { | ||||
|             Guid? guid = new Guid("531797E9-9457-40E0-88BC-B1D6D38752FA"); | ||||
|             var str = JsonSerializer.Serialize(guid, _options); | ||||
|             Assert.Equal($"\"{guid:N}\"", str); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user