-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Merge pull request #44 from Cysharp/hadashiA/fix-net8
Fix compilation errors in .net8 with explicit static members
Showing
11 changed files
with
322 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
219 changes: 219 additions & 0 deletions
219
sandbox/Generated/UnitGenerator/UnitGenerator.SourceGenerator/FileGenerate.D.g.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,219 @@ | ||
// <auto-generated> | ||
// THIS (.cs) FILE IS GENERATED BY UnitGenerator. DO NOT CHANGE IT. | ||
// </auto-generated> | ||
#pragma warning disable CS8669 | ||
using System; | ||
using System.Globalization; | ||
#if NET7_0_OR_GREATER | ||
using System.Numerics; | ||
#endif | ||
namespace FileGenerate | ||
{ | ||
[System.ComponentModel.TypeConverter(typeof(DTypeConverter))] | ||
readonly partial struct D | ||
: IEquatable<D> | ||
, IComparable<D> | ||
, IFormattable | ||
#if NET6_0_OR_GREATER | ||
, ISpanFormattable | ||
#endif | ||
#if NET7_0_OR_GREATER | ||
, IComparisonOperators<D, D, bool> | ||
#endif | ||
#if NET8_0_OR_GREATER | ||
, IEqualityOperators<D, D, bool> | ||
, IUtf8SpanFormattable | ||
#endif | ||
{ | ||
readonly System.Guid value; | ||
|
||
public System.Guid AsPrimitive() => value; | ||
|
||
public D(System.Guid value) | ||
{ | ||
this.value = value; | ||
} | ||
|
||
public static explicit operator System.Guid(D value) | ||
{ | ||
return value.value; | ||
} | ||
|
||
public static explicit operator D(System.Guid value) | ||
{ | ||
return new D(value); | ||
} | ||
|
||
public bool Equals(D other) | ||
{ | ||
return value.Equals(other.value); | ||
} | ||
|
||
public override bool Equals(object obj) | ||
{ | ||
if (obj == null) return false; | ||
var t = obj.GetType(); | ||
if (t == typeof(D)) | ||
{ | ||
return Equals((D)obj); | ||
} | ||
if (t == typeof(System.Guid)) | ||
{ | ||
return value.Equals((System.Guid)obj); | ||
} | ||
|
||
return value.Equals(obj); | ||
} | ||
|
||
public static bool operator ==(D x, D y) | ||
{ | ||
return x.value.Equals(y.value); | ||
} | ||
|
||
public static bool operator !=(D x, D y) | ||
{ | ||
return !x.value.Equals(y.value); | ||
} | ||
|
||
public override int GetHashCode() | ||
{ | ||
return value.GetHashCode(); | ||
} | ||
|
||
public override string ToString() => value.ToString(); | ||
|
||
public string ToString(string? format, IFormatProvider? formatProvider) => value.ToString(format, formatProvider); | ||
|
||
#if NET6_0_OR_GREATER | ||
public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider) => | ||
((ISpanFormattable)value).TryFormat(destination, out charsWritten, format, provider); | ||
#endif | ||
#if NET8_0_OR_GREATER | ||
public bool TryFormat (Span<byte> utf8Destination, out int bytesWritten, ReadOnlySpan<char> format, IFormatProvider? provider) => | ||
((IUtf8SpanFormattable)value).TryFormat(utf8Destination, out bytesWritten, format, provider); | ||
#endif | ||
|
||
public static readonly D Empty = default(D); | ||
|
||
public static D New() | ||
{ | ||
return new D(Guid.NewGuid()); | ||
} | ||
|
||
public static D NewD() | ||
{ | ||
return new D(Guid.NewGuid()); | ||
} | ||
|
||
// UnitGenerateOptions.ParseMethod | ||
|
||
public static D Parse(string s) | ||
{ | ||
return new D(System.Guid.Parse(s)); | ||
} | ||
|
||
public static bool TryParse(string s, out D result) | ||
{ | ||
if (System.Guid.TryParse(s, out var r)) | ||
{ | ||
result = new D(r); | ||
return true; | ||
} | ||
else | ||
{ | ||
result = default(D); | ||
return false; | ||
} | ||
} | ||
|
||
// UnitGenerateOptions.Comparable | ||
|
||
public int CompareTo(D other) | ||
{ | ||
return value.CompareTo(other.value); | ||
} | ||
public static bool operator >(D x, D y) | ||
{ | ||
return x.value > y.value; | ||
} | ||
|
||
public static bool operator <(D x, D y) | ||
{ | ||
return x.value < y.value; | ||
} | ||
|
||
public static bool operator >=(D x, D y) | ||
{ | ||
return x.value >= y.value; | ||
} | ||
|
||
public static bool operator <=(D x, D y) | ||
{ | ||
return x.value <= y.value; | ||
} | ||
|
||
// Default | ||
|
||
private class DTypeConverter : System.ComponentModel.TypeConverter | ||
{ | ||
private static readonly Type WrapperType = typeof(D); | ||
private static readonly Type ValueType = typeof(System.Guid); | ||
|
||
public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, Type sourceType) | ||
{ | ||
if (sourceType == WrapperType || sourceType == ValueType) | ||
{ | ||
return true; | ||
} | ||
|
||
return base.CanConvertFrom(context, sourceType); | ||
} | ||
|
||
public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, Type destinationType) | ||
{ | ||
if (destinationType == WrapperType || destinationType == ValueType) | ||
{ | ||
return true; | ||
} | ||
|
||
return base.CanConvertTo(context, destinationType); | ||
} | ||
|
||
public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) | ||
{ | ||
if (value != null) | ||
{ | ||
var t = value.GetType(); | ||
if (t == typeof(D)) | ||
{ | ||
return (D)value; | ||
} | ||
if (t == typeof(System.Guid)) | ||
{ | ||
return new D((System.Guid)value); | ||
} | ||
} | ||
|
||
return base.ConvertFrom(context, culture, value); | ||
} | ||
|
||
public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) | ||
{ | ||
if (value is D wrappedValue) | ||
{ | ||
if (destinationType == WrapperType) | ||
{ | ||
return wrappedValue; | ||
} | ||
|
||
if (destinationType == ValueType) | ||
{ | ||
return wrappedValue.AsPrimitive(); | ||
} | ||
} | ||
|
||
return base.ConvertTo(context, culture, value, destinationType); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters