Share via


IMetaDataEmit::GetSaveSize Method

Gets the estimated binary size of the assembly and its metadata in the current scope.

HRESULT GetSaveSize (
    [in]  CorSaveSize fSave,
    [out] DWORD       *pdwSaveSize
);

Parameters

Parameter Description

fSave

[in] A value of the CorSaveSize Enumeration enumeration that specifies whether to get an accurate or approximate size. Only three values are valid: cssAccurate, cssQuick, and cssDiscardTransientCAs:

  • cssAccurate returns the exact save size but takes longer to calculate.

  • cssQuick returns a size, padded for safety, but takes less time to calculate.

  • cssDiscardTransientCAs tells GetSaveSize that it can throw away discardable custom attributes.

pdwSaveSize

[out] A pointer to the size that is required to save the file.

Remarks

GetSaveSize calculates the space required, in bytes, to save the assembly and all its metadata in the current scope. (A call to the IMetaDataEmit::SaveToStream Method method would emit this number of bytes.)

If the caller implements the IMapToken Interface interface (through IMetaDataEmit::SetHandler Method or IMetaDataEmit::Merge Method), GetSaveSize will perform two passes over the metadata to optimize and compress it. Otherwise, no optimizations are performed.

If optimization is performed, the first pass simply sorts the metadata structures to tune the performance of import-time searches. This step typically results in moving records around, with the side effect that tokens retained by the tool for future reference are invalidated. The metadata does not inform the caller of these token changes until after the second pass, however. In the second pass, various optimizations are performed that are intended to reduce the overall size of the metadata, such as optimizing away (early binding) mdTypeRef and mdMemberRef tokens when the reference is to a type or member that is declared in the current metadata scope. In this pass, another round of token mapping occurs. After this pass, the metadata engine notifies the caller, through its IMapToken Interface interface, of any changed token values.

Requirements

Platforms: Windows 2000, Windows XP, Windows Server 2003 family

Header: Cor.h

Library: Used as a resource in Mscoree.dll

.NET Framework Version: 2.0, 1.1, 1.0

See Also

Reference

IMetaDataEmit Interface
IMetaDataEmit2 Interface