Skip to content
Merged
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 @@ -52,7 +52,9 @@ public SnapshotModelProcessor(
/// </summary>
public virtual IModel? Process(IReadOnlyModel? model, bool resetVersion = false)
{
if (model == null)
if (model == null
|| model is not Model mutableModel
|| mutableModel.IsReadOnly)
{
return null;
}
Expand All @@ -79,13 +81,10 @@ public SnapshotModelProcessor(
}
}

if (model is IMutableModel mutableModel)
mutableModel.RemoveAnnotation("ChangeDetector.SkipDetectChanges");
if (resetVersion)
{
mutableModel.RemoveAnnotation("ChangeDetector.SkipDetectChanges");
if (resetVersion)
{
mutableModel.SetProductVersion(ProductInfo.GetVersion());
}
mutableModel.SetProductVersion(ProductInfo.GetVersion());
}

return _modelRuntimeInitializer.Initialize((IModel)model, designTime: true, validationLogger: null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public void Updates_provider_annotations_on_model()

var reporter = new TestOperationReporter();

new SnapshotModelProcessor(reporter, DummyModelRuntimeInitializer.Instance).Process(model);
var processor = new SnapshotModelProcessor(reporter, DummyModelRuntimeInitializer.Instance);
processor.Process(model);

AssertAnnotations(model);
AssertAnnotations(entityType);
Expand All @@ -54,6 +55,8 @@ public void Updates_provider_annotations_on_model()
AssertAnnotations(nav2);
AssertAnnotations(index);

Assert.Same(model, processor.Process(model));

Assert.Empty(reporter.Messages);
}

Expand Down