Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing null-suppress #30

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ public void DefaultUniqueClaimTypes_NotPresent_SerializesAllClaimTypes()
var claimsIdentity = (ClaimsIdentity)identity;

// Act
var identiferParameters = DefaultClaimUidExtractor.GetUniqueIdentifierParameters(
new ClaimsIdentity[] { claimsIdentity }
)!.ToArray();
var identiferParameters = DefaultClaimUidExtractor
.GetUniqueIdentifierParameters(new ClaimsIdentity[] { claimsIdentity })!
.ToArray();
var claims = claimsIdentity.Claims.ToList();
claims.Sort((a, b) => string.Compare(a.Type, b.Type, StringComparison.Ordinal));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ private PhotinoSynchronizationContext(PhotinoWindow window, State state)

_uiThreadId = (int)_window
.GetType()
.GetField("_managedThreadId", BindingFlags.NonPublic | BindingFlags.Instance)!.GetValue(
_window
)!;
.GetField("_managedThreadId", BindingFlags.NonPublic | BindingFlags.Instance)!
.GetValue(_window)!;

_invokeMethodInfo = _window
.GetType()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,9 @@ private object ProcessRevocationElement(XElement revocationElement)

try
{
string keyIdAsString = (string)revocationElement.Element(KeyElementName)!.Attribute(
IdAttributeName
)!;
string keyIdAsString = (string)revocationElement
.Element(KeyElementName)!
.Attribute(IdAttributeName)!;
if (keyIdAsString == RevokeAllKeysValue)
{
// this is a mass revocation of all keys as of the specified revocation date
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,15 +386,17 @@ private void UseStartup(
);

// Get the private ConfigureContainer method on this type then close over the container type
var configureCallback = typeof(GenericWebHostBuilder).GetMethod(
nameof(ConfigureContainerImpl),
BindingFlags.NonPublic | BindingFlags.Instance
)!
var configureCallback = typeof(GenericWebHostBuilder)
.GetMethod(
nameof(ConfigureContainerImpl),
BindingFlags.NonPublic | BindingFlags.Instance
)!
.MakeGenericMethod(containerType)
.CreateDelegate(actionType, this);

// _builder.ConfigureContainer<T>(ConfigureContainer);
typeof(IHostBuilder).GetMethod(nameof(IHostBuilder.ConfigureContainer))!
typeof(IHostBuilder)
.GetMethod(nameof(IHostBuilder.ConfigureContainer))!
.MakeGenericMethod(containerType)
.InvokeWithoutWrappingExceptions(_builder, new object[] { configureCallback });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2700,9 +2700,9 @@ public class ModelWithNonNullableReferenceTypeProperties
public string Name { get; set; } = default!;

public Delegate Delegate { get; set; } =
typeof(ModelWithNonNullableReferenceTypeProperties).GetMethod(
nameof(SomeMethod)
)!.CreateDelegate<Action>();
typeof(ModelWithNonNullableReferenceTypeProperties)
.GetMethod(nameof(SomeMethod))!
.CreateDelegate<Action>();

public static void SomeMethod() { }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,13 @@ IConventionProperty partitionKeyProperty
}

var foreignKey =
joinEntityTypeBuilder.HasRelationship(
skipNavigation.DeclaringEntityType,
dependentProperties,
principalKey
)!.IsUnique(false)!.Metadata;
joinEntityTypeBuilder
.HasRelationship(
skipNavigation.DeclaringEntityType,
dependentProperties,
principalKey
)!
.IsUnique(false)!.Metadata;

skipNavigation.Builder.HasForeignKey(foreignKey);

Expand Down
8 changes: 5 additions & 3 deletions efcore/src/EFCore.Cosmos/Update/Internal/DocumentSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,11 @@ public virtual JObject CreateDocument(IUpdateEntry entry, int? ordinal)
}

private IProperty? FindOrdinalKeyProperty(IEntityType entityType) =>
entityType.FindPrimaryKey()!.Properties.FirstOrDefault(
p => p.GetJsonPropertyName().Length == 0 && p.IsOrdinalKeyProperty()
);
entityType
.FindPrimaryKey()!
.Properties.FirstOrDefault(
p => p.GetJsonPropertyName().Length == 0 && p.IsOrdinalKeyProperty()
);

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,9 +436,9 @@ Type contextType
return service == null
? null
: () =>
(DbContext)factoryInterface.GetMethod(
nameof(IDbContextFactory<DbContext>.CreateDbContext)
)!.Invoke(service, null)!;
(DbContext)factoryInterface
.GetMethod(nameof(IDbContextFactory<DbContext>.CreateDbContext))!
.Invoke(service, null)!;
}

private Func<DbContext>? FindContextFactory(Type contextType)
Expand All @@ -463,7 +463,8 @@ private DbContext CreateContextFromFactory(Type factory, Type contextType)
.GetMethod(
nameof(IDesignTimeDbContextFactory<DbContext>.CreateDbContext),
new[] { typeof(string[]) }
)!.Invoke(Activator.CreateInstance(factory), new object[] { _args })!;
)!
.Invoke(Activator.CreateInstance(factory), new object[] { _args })!;
}

private KeyValuePair<Type, Func<DbContext>> FindContextType(string? name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1757,7 +1757,8 @@ var index in entityType
&& property.GetColumnName(
StoreObjectIdentifier.Table(n.Item1, n.Item2)
) != null
)!.ToList<(string Table, string? Schema)>();
)!
.ToList<(string Table, string? Schema)>();
if (tablesMappedToProperty.Count == 0)
{
propertyNotMappedToAnyTable = property;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,16 @@ IConventionContext<IConventionModelBuilder> context
foreach (var entityTypeToExampleProperty in entityTypesMissingConcurrencyColumn)
{
var exampleProperty = entityTypeToExampleProperty.Value;
entityTypeToExampleProperty.Key.Builder.CreateUniqueProperty(
exampleProperty.ClrType,
ConcurrencyPropertyPrefix + exampleProperty.Name,
!exampleProperty.IsNullable
)!.HasColumnName(concurrencyColumnName)!.HasColumnType(
exampleProperty.GetColumnType()
)!.IsConcurrencyToken(true)!.ValueGenerated(exampleProperty.ValueGenerated);
entityTypeToExampleProperty.Key.Builder
.CreateUniqueProperty(
exampleProperty.ClrType,
ConcurrencyPropertyPrefix + exampleProperty.Name,
!exampleProperty.IsNullable
)!
.HasColumnName(concurrencyColumnName)!
.HasColumnType(exampleProperty.GetColumnType())!
.IsConcurrencyToken(true)!
.ValueGenerated(exampleProperty.ValueGenerated);
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions efcore/src/EFCore.Relational/Migrations/HistoryRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ protected HistoryRepository(HistoryRepositoryDependencies dependencies)
/// </summary>
protected virtual string MigrationIdColumnName =>
_migrationIdColumnName ??= EnsureModel()
.FindEntityType(typeof(HistoryRow))!.FindProperty(
nameof(HistoryRow.MigrationId)
)!.GetColumnBaseName();
.FindEntityType(typeof(HistoryRow))!
.FindProperty(nameof(HistoryRow.MigrationId))!
.GetColumnBaseName();

private IModel EnsureModel()
{
Expand Down Expand Up @@ -131,9 +131,9 @@ private IModel EnsureModel()
/// </summary>
protected virtual string ProductVersionColumnName =>
_productVersionColumnName ??= EnsureModel()
.FindEntityType(typeof(HistoryRow))!.FindProperty(
nameof(HistoryRow.ProductVersion)
)!.GetColumnBaseName();
.FindEntityType(typeof(HistoryRow))!
.FindProperty(nameof(HistoryRow.ProductVersion))!
.GetColumnBaseName();

/// <summary>
/// Overridden by database providers to generate SQL that tests for existence of the history table.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,9 @@ public virtual IKeyValueIndex CreatePrincipalKeyValueFromOriginalValues(
IUpdateEntry entry,
IForeignKey foreignKey
) =>
foreignKey.GetDependentKeyValueFactory<TKey>()!.TryCreateFromCurrentValues(
entry,
out var keyValue
)
foreignKey
.GetDependentKeyValueFactory<TKey>()!
.TryCreateFromCurrentValues(entry, out var keyValue)
? new KeyValueIndex<TKey>(
foreignKey,
keyValue,
Expand All @@ -91,10 +90,9 @@ out var keyValue
IUpdateEntry entry,
IForeignKey foreignKey
) =>
foreignKey.GetDependentKeyValueFactory<TKey>()!.TryCreateFromOriginalValues(
entry,
out var keyValue
)
foreignKey
.GetDependentKeyValueFactory<TKey>()!
.TryCreateFromOriginalValues(entry, out var keyValue)
? new KeyValueIndex<TKey>(
foreignKey,
keyValue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,11 @@ public override IEnumerable<IAnnotation> For(ITableIndex index, bool designTime)
var includeColumns = includeProperties
.Select(
p =>
modelIndex.DeclaringEntityType.FindProperty(p)!.GetColumnName(
StoreObjectIdentifier.Table(table.Name, table.Schema)
)
modelIndex.DeclaringEntityType
.FindProperty(p)!
.GetColumnName(
StoreObjectIdentifier.Table(table.Name, table.Schema)
)
)
.ToArray();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,20 @@ static bool SameColumnNames(
IReadOnlyIndex duplicateIndex,
StoreObjectIdentifier storeObject
) =>
index.GetIncludeProperties()!
index
.GetIncludeProperties()!
.Select(
p => index.DeclaringEntityType.FindProperty(p)!.GetColumnName(storeObject)
)
.SequenceEqual(
duplicateIndex.GetIncludeProperties()!.Select(
p =>
duplicateIndex.DeclaringEntityType.FindProperty(p)!.GetColumnName(
storeObject
)
)
duplicateIndex
.GetIncludeProperties()!
.Select(
p =>
duplicateIndex.DeclaringEntityType
.FindProperty(p)!
.GetColumnName(storeObject)
)
);
}

Expand All @@ -143,9 +146,14 @@ StoreObjectIdentifier storeObject
: "{'"
+ string.Join(
"', '",
index.GetIncludeProperties()!.Select(
p => index.DeclaringEntityType.FindProperty(p)?.GetColumnName(storeObject)
)
index
.GetIncludeProperties()!
.Select(
p =>
index.DeclaringEntityType
.FindProperty(p)
?.GetColumnName(storeObject)
)
)
+ "'}";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ namespace Microsoft.EntityFrameworkCore.Sqlite.Storage.Internal
public class SqliteGeometryTypeMapping<TGeometry>
: RelationalGeometryTypeMapping<TGeometry, byte[]> where TGeometry : Geometry
{
private static readonly MethodInfo _getBytes = typeof(DbDataReader).GetRuntimeMethod(
nameof(DbDataReader.GetFieldValue),
new[] { typeof(int) }
)!.MakeGenericMethod(typeof(byte[]));
private static readonly MethodInfo _getBytes = typeof(DbDataReader)
.GetRuntimeMethod(nameof(DbDataReader.GetFieldValue), new[] { typeof(int) })!
.MakeGenericMethod(typeof(byte[]));

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand Down
7 changes: 3 additions & 4 deletions efcore/src/EFCore/ChangeTracking/CollectionEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,9 @@ public override IQueryable Query()
}

private void EnsureInitialized() =>
Metadata.GetCollectionAccessor()!.GetOrCreate(
InternalEntry.Entity,
forMaterialization: true
);
Metadata
.GetCollectionAccessor()!
.GetOrCreate(InternalEntry.Entity, forMaterialization: true);

/// <summary>
/// The <see cref="EntityEntry" /> of an entity this navigation targets.
Expand Down
31 changes: 15 additions & 16 deletions efcore/src/EFCore/ChangeTracking/Internal/IdentityMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,9 @@ public virtual bool Contains(in ValueBuffer valueBuffer)
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual bool Contains(IForeignKey foreignKey, in ValueBuffer valueBuffer) =>
foreignKey.GetDependentKeyValueFactory<TKey>()!.TryCreateFromBuffer(
valueBuffer,
out var key
) && _identityMap.ContainsKey(key);
foreignKey
.GetDependentKeyValueFactory<TKey>()!
.TryCreateFromBuffer(valueBuffer, out var key) && _identityMap.ContainsKey(key);

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand Down Expand Up @@ -180,10 +179,10 @@ out bool hasNullKey
IForeignKey foreignKey,
InternalEntityEntry dependentEntry
) =>
foreignKey.GetDependentKeyValueFactory<TKey>()!.TryCreateFromCurrentValues(
dependentEntry,
out var key
) && _identityMap.TryGetValue(key, out var entry)
foreignKey
.GetDependentKeyValueFactory<TKey>()!
.TryCreateFromCurrentValues(dependentEntry, out var key)
&& _identityMap.TryGetValue(key, out var entry)
? entry
: null;

Expand All @@ -197,10 +196,10 @@ out var key
IForeignKey foreignKey,
InternalEntityEntry dependentEntry
) =>
foreignKey.GetDependentKeyValueFactory<TKey>()!.TryCreateFromPreStoreGeneratedCurrentValues(
dependentEntry,
out var key
) && _identityMap.TryGetValue(key, out var entry)
foreignKey
.GetDependentKeyValueFactory<TKey>()!
.TryCreateFromPreStoreGeneratedCurrentValues(dependentEntry, out var key)
&& _identityMap.TryGetValue(key, out var entry)
? entry
: null;

Expand All @@ -214,10 +213,10 @@ out var key
IForeignKey foreignKey,
InternalEntityEntry dependentEntry
) =>
foreignKey.GetDependentKeyValueFactory<TKey>()!.TryCreateFromRelationshipSnapshot(
dependentEntry,
out var key
) && _identityMap.TryGetValue(key, out var entry)
foreignKey
.GetDependentKeyValueFactory<TKey>()!
.TryCreateFromRelationshipSnapshot(dependentEntry, out var key)
&& _identityMap.TryGetValue(key, out var entry)
? entry
: null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1076,11 +1076,9 @@ bool forMaterialization
{
if (!navigationBase.IsShadowProperty())
{
return navigationBase.GetCollectionAccessor()!.Add(
Entity,
value.Entity,
forMaterialization
);
return navigationBase
.GetCollectionAccessor()!
.Add(Entity, value.Entity, forMaterialization);
}

var collection = GetOrCreateCollectionTyped(navigationBase);
Expand Down
6 changes: 3 additions & 3 deletions efcore/src/EFCore/Infrastructure/ModelValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -543,9 +543,9 @@ protected virtual void ValidateNoShadowKeys(
: "." + referencingFk.PrincipalToDependent.Name
),
referencingFk.Properties.Format(includeTypes: true),
entityType.FindPrimaryKey()!.Properties.Format(
includeTypes: true
)
entityType
.FindPrimaryKey()!
.Properties.Format(includeTypes: true)
)
);
}
Expand Down
Loading