public static void ReportError <T, TProperty>( T entity, LocatedNullable <TProperty> value, IDiagnostics diags, IUniqueConstraint <T> constraint) where TProperty : struct { diags.ReportError(value.Location, constraint.FormatMessage(entity)); }
public Task( LocatedRef <QName> name, LocatedVal <ushort> value, LocatedRef <string> symbol, LocatedNullable <Guid> guid, LocalizedString message) : this(name, value) { Symbol = symbol; Guid = guid; Message = message; }
public void Constructor() { var value = new X(); var location = new SourceLocation("z:\\foo", 23, 42); var located = new LocatedNullable <X>(value, location); Assert.Equal(value, located.Value); Assert.Equal(location, located.Location); }
public void ImplicitConversion() { var value = new X(); X?convertedValue = new LocatedNullable <X>(value, new SourceLocation()); LocatedNullable <X> convertedNullable = convertedValue; Assert.Equal(value, convertedValue); Assert.Equal(value, convertedNullable.Value); Assert.Null(convertedNullable.Location); }
public void Equatable() { var sameValue = new EquatableX(1); var equalValue = new EquatableX(1); var notEqualValue = new EquatableX(3); var location = new SourceLocation("a", 1, 1); var otherLocation = new SourceLocation("b", 2, 2); var located = new LocatedNullable <EquatableX>(sameValue, location); var same = new LocatedNullable <EquatableX>(sameValue); var equal = new LocatedNullable <EquatableX>(equalValue); var notEqual = new LocatedNullable <EquatableX>(notEqualValue); var sameWithLoc = new LocatedNullable <EquatableX>(sameValue, otherLocation); var equalWithLoc = new LocatedNullable <EquatableX>(equalValue, otherLocation); var notEqualWithLoc = new LocatedNullable <EquatableX>(notEqualValue, otherLocation); Assert.True(located.Equals(located)); Assert.True(located.Equals(same)); Assert.True(located.Equals(equal)); Assert.False(located.Equals(notEqual)); Assert.True(located.Equals(sameWithLoc)); Assert.True(located.Equals(equalWithLoc)); Assert.False(located.Equals(notEqualWithLoc)); Assert.True(located.Equals((object)same)); Assert.True(located.Equals((object)equal)); Assert.False(located.Equals((object)notEqual)); Assert.True(located.Equals((object)sameWithLoc)); Assert.True(located.Equals((object)equalWithLoc)); Assert.False(located.Equals((object)notEqualWithLoc)); Assert.True(located.Equals(sameValue)); Assert.True(located.Equals(equalValue)); Assert.False(located.Equals(notEqualValue)); Assert.True(located.Equals((object)sameValue)); Assert.True(located.Equals((object)equalValue)); Assert.False(located.Equals((object)notEqualValue)); Assert.True(located.Equals((object)sameValue.Value)); Assert.True(located.Equals((object)equalValue.Value)); Assert.False(located.Equals((object)notEqualValue.Value)); }
public void Comparable() { var sameValue = new ComparableX(10); var equalValue = new ComparableX(10); var smallerValue = new ComparableX(9); var largerValue = new ComparableX(11); var location = new SourceLocation("a", 1, 1); var otherLocation = new SourceLocation("b", 2, 2); var located = new LocatedNullable <ComparableX>(sameValue, location); var same = new LocatedNullable <ComparableX>(sameValue); var equal = new LocatedNullable <ComparableX>(equalValue); var smaller = new LocatedNullable <ComparableX>(smallerValue); var larger = new LocatedNullable <ComparableX>(largerValue); var sameWithLoc = new LocatedNullable <ComparableX>(sameValue, otherLocation); var equalWithLoc = new LocatedNullable <ComparableX>(equalValue, otherLocation); var smallerWithLoc = new LocatedNullable <ComparableX>(smallerValue, otherLocation); var largerWithLoc = new LocatedNullable <ComparableX>(largerValue, otherLocation); Assert.Equal(0, located.CompareTo(located)); Assert.Equal(0, located.CompareTo(same)); Assert.Equal(0, located.CompareTo(equal)); Assert.Equal(1, located.CompareTo(smaller)); Assert.Equal(-1, located.CompareTo(larger)); Assert.Equal(0, located.CompareTo(sameWithLoc)); Assert.Equal(0, located.CompareTo(equalWithLoc)); Assert.Equal(1, located.CompareTo(smallerWithLoc)); Assert.Equal(-1, located.CompareTo(largerWithLoc)); Assert.Equal(0, located.CompareTo(sameValue)); Assert.Equal(0, located.CompareTo(equalValue)); Assert.Equal(1, located.CompareTo(smallerValue)); Assert.Equal(-1, located.CompareTo(largerValue)); }