in vsintegration/src/FSharp.ProjectSystem.PropertyPages/PropertyPages/PropPageUserControlBase.vb [1945:2222]
Protected Overridable Sub ApplyPageChanges()
Debug.Assert(Not Me.MultiProjectSelect, "Apply should not be occuring with multiple projects selected")
Debug.Assert(Not m_ProjectReloadedDuringCheckout)
Dim control As System.Windows.Forms.Control = Nothing
Dim Transaction As DesignerTransaction = Nothing
Dim Succeeded As Boolean = False
Dim ProjectReloadWasValid As Boolean = False
VerifyPropertiesWhichMayReloadProjectAreLast()
Dim BatchObjects() As Interop.ILangPropertyProvideBatchUpdate = Nothing
Dim vsProjectBuildSystem As IVsProjectBuildSystem = Nothing
Debug.Assert(Not m_fIsApplying)
m_fIsApplying = True
EnterProjectCheckoutSection()
Try
ValidatePageChanges(True)
CheckOutFilesForApply()
If m_ProjectReloadedDuringCheckout Then
Return
End If
Debug.Assert(ProjectHierarchy IsNot Nothing, "no hierarchy?")
vsProjectBuildSystem = TryCast(ProjectHierarchy, IVsProjectBuildSystem)
Debug.Assert(vsProjectBuildSystem IsNot Nothing, "hierarchy is not IVsProjectBuildSystem?")
Try
If (vsProjectBuildSystem IsNot Nothing) Then
vsProjectBuildSystem.StartBatchEdit()
End If
BatchObjects = New Interop.ILangPropertyProvideBatchUpdate(RawPropertiesObjectsOfAllProperties.Length - 1 + 1) {}
Dim i As Integer = 0
Dim BatchObject As Interop.ILangPropertyProvideBatchUpdate
BatchObject = TryCast(CommonPropertiesObject, Interop.ILangPropertyProvideBatchUpdate)
If BatchObject IsNot Nothing Then
Try
BatchObject.BeginBatch()
BatchObjects(i) = BatchObject
Catch ex As Exception When Not Common.IsUnrecoverable(ex)
Debug.Fail("ILangPropertyProvideBatchUpdate.BeginBatch() failed, ignoring: " & ex.ToString)
End Try
End If
i += 1
For Each Obj As Object In RawPropertiesObjectsOfAllProperties
BatchObject = TryCast(Obj, Interop.ILangPropertyProvideBatchUpdate)
If BatchObject IsNot Nothing Then
Try
BatchObject.BeginBatch()
BatchObjects(i) = BatchObject
Catch ex As Exception When Not Common.IsUnrecoverable(ex)
Debug.Fail("ILangPropertyProvideBatchUpdate.BeginBatch() failed, ignoring: " & ex.ToString)
End Try
End If
i += 1
Next
PreApplyPageChanges()
If m_ProjectReloadedDuringCheckout Then
Return
End If
Transaction = GetTransaction()
For Each _controlData As PropertyControlData In ControlData
Dim ProjectMayBeReloadedDuringPropertySet As Boolean = (0 <> (_controlData.GetFlags() And ControlDataFlags.ProjectMayBeReloadedDuringPropertySet))
control = _controlData.FormControl
Try
Debug.Assert(_controlData.DispId >= 0)
_controlData.ApplyChanges()
Catch ex As ProjectReloadedException
Debug.Assert(ProjectReloadedDuringCheckout, "This should already have been set")
m_ProjectReloadedDuringCheckout = True
If ProjectMayBeReloadedDuringPropertySet Then
ProjectReloadWasValid = True
End If
For Each cd As PropertyControlData In ControlData
If cd IsNot _controlData AndAlso cd.IsDirty Then
ShowErrorMessage(SR.GetString(SR.PPG_ProjectReloadedSomePropertiesMayNotHaveBeenSet))
Exit For
End If
Next
Throw
Catch ex As Exception When Not Common.IsUnrecoverable(ex)
If TypeOf ex Is System.Reflection.TargetInvocationException Then
ex = ex.InnerException
End If
Throw New ValidationException(ValidationResult.Failed, _controlData.DisplayPropertyName & ":" & vbCrLf & ex.Message, control, innerexception:=ex)
End Try
Next _controlData
control = Nothing
PostApplyPageChanges()
CommitTransaction(Transaction)
Succeeded = True
Catch ex As ProjectReloadedException
Return
Catch ex As Exception
If Transaction IsNot Nothing Then
Transaction.Cancel()
End If
Throw
Finally
m_fIsApplying = False
If m_ProjectReloadedDuringCheckout Then
Debug.Assert(ProjectReloadWasValid, "The project was reloaded during an attempt to change properties. This might" _
& " indicate that SCC updated the file during a checkout. But that implies that we didn't check out all necessary" _
& " files before trying to change the property. Please check that all PropertyControlData have the correct set of necessary" _
& " files. If setting this property can validly cause the project to get reloaded, such as is the case for the" _
& " TargetFramework property, then be sure the property's PropertyControlData has the ProjectMayBeReloadedDuringPropertySet" _
& " flag.")
Else
If BatchObjects IsNot Nothing Then
For Each BatchObject As Interop.ILangPropertyProvideBatchUpdate In BatchObjects
If BatchObject IsNot Nothing Then
Try
BatchObject.EndBatch()
Catch ex As Exception When Not Common.IsUnrecoverable(ex)
Trace.WriteLine("ILangPropertyProvideBatchUpdate.EndBatch failed, ignoring:" & vbCrLf & Common.DebugMessageFromException(ex))
End Try
End If
Next
End If
If vsProjectBuildSystem IsNot Nothing Then
Try
vsProjectBuildSystem.EndBatchEdit()
Catch ex As Exception When Not Common.IsUnrecoverable(ex)
Trace.WriteLine("IVsProjectBuildSystem.EndBatchEdit failed, ignoring:" & vbCrLf & Common.DebugMessageFromException(ex))
End Try
End If
If m_Site Is Nothing Then
Debug.Fail("How did the site get removed if not because of a dispose during apply?")
End If
If m_Site IsNot Nothing Then
If control IsNot Nothing Then
control.Focus()
End If
m_IsDirty = False
Dim ShouldBeDirty As Boolean = IsAnyPropertyDirty()
If Not Succeeded AndAlso Not m_Site.IsImmediateApply() Then
ShouldBeDirty = True
End If
IsDirty = ShouldBeDirty
CheckPlayCachedPropertyChanges()
End If
End If
End Try
Catch validateEx As ValidationException
If Not m_ProjectReloadedDuringCheckout AndAlso m_Site IsNot Nothing Then
If validateEx.InnerException IsNot Nothing _
AndAlso (Common.IsCheckoutCanceledException(validateEx.InnerException) OrElse TypeOf validateEx.InnerException Is CheckoutException) Then
If m_Site.IsImmediateApply Then
Try
RestoreInitialValues()
Catch ex As Exception When Not Common.IsUnrecoverable(ex)
Debug.Fail("Exception occurred trying to refresh all properties' UI: " & ex.ToString)
End Try
End If
End If
validateEx.RestoreFocus()
End If
Throw
Finally
m_fIsApplying = False
LeaveProjectCheckoutSection()
End Try
End Sub