You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the C# function doesn't bind to the other and thrown an error
Microsoft.CSharp has several objects that are heavily used throughout the library that have circular dependencies on each other, as well as several other classes depending on them. Use of them hence requires either a field in each object that will use them, or to follow chains of such fields. Prior to #25191 it was necessary for them to be instances so that they could be replaced with new versions. This no longer being necessary it's possible to make them all static. At the same time, the related RuntimeBinder, ExpressionBinder and BindingContext classes are relatively heavy, mostly due to these dependencies. They are hence created once unless a cast must be attempted with a different BindingContext, and BindingContext's state is overwritten for each operation. Removing these dependencies makes these very light, allowing them to be readonly structs that are created for each operation. * Have TypeArray in charge of the empty TypeArray singleton * Make TypeArray allocation a static responsibility of TypeArray * Remove some orphaned members. Mostly BSYMMGR-returning members that had been used to allocate TypeArrays * Make members static where possible. Those that can already be easily made static. Includes removing some members that this makes no longer necessary. * Remove unused parameters Since some are of the types we'll be making static, and such parameters will have to go anyway. * Make TypeTable static And more conventional names within TypeTable. * More TypeManager state & methods to static * Make SYMTBL.Key an immutable struct. * SYMTBL completely static and renamed to SymbolStore More conventional name, and doesn't clash with other SymbolTable class. * GetWinRTCollectionIfacesAll to property. * SymFactory static class. * Remove PredefinedTypes._symbolManager field Only used in assertion. * Remove assert comparison with this in GetAggregate Assert is the only reason to not be static, allows a cascade of more changes to static. * Make InternalsVisibleTo check static. * Make cycle of instance methods static Take quite a large set of methods which must be instance because of cyclic instance dependencies, and make them all static. Removes dependency in AggregateSymbol and NullableType on TypeManager instances. * Replace GetAggTypeSym with virtual method on CType. Merged with existing GetAts on NullableType. Comment says this would be nice, and indeed it would, and its easy now. * Make those members that can now be static, static. * Remove orphaned members and fields. * PredefinedMembers entirely static. * Remove UserStringBuilder.m_buildingInProgress Only used in asserts, just assert on whether m_strBuilder is null or not. Also rename m_strBuilder to _strBuilder to be more conventional. * Favour returning over out in UserStringBuilder And favour clearing StringBuilder over creating another. * Make ErrorHandling completely static. Creating UserStringBuilder instances on demand. * TypeManager static. * Make CNullable methods static and merge directly into ExpressionBinder Don't cache method and property, as they're already cached. * Don't preload types. Either they'll be loaded soon anyway, or else it's a wasted effort. * Move CompareTypes into Better.cs * Remove BSYMMGR.LookupAggMember Just call into SymbolStore.LookupSym * Move LookupNextSym logic into Symbol * Remove BSYMMGR and GlobalSymbolContext No longer any use. * ExprFactory static * SymbolLoader static * CSemanticChecker static * Don't pre-emptively load System.Object Will be loaded as a base of the first type encountered anyway. * SymbolTable static * More methods can be made static * Remove orphaned method. * Move methods for getting MemberInfos from expressions into those expressions * Replace ExpressionTreeCallRewriter.GetObject with virtual property in Expr * TypeArray tidy-up. * Pass ExpressionBinder to operator delegates, and make them static. Allows array to be created once statically, rather than on each instance construction. * Create RuntimeBinder, ExpressionBinder and BindingContext per operation These are now very lightweight, so it's simpler to create them anew each time rather than overwriting the values in the BindingContext. * Make RuntimeBinder, ExpressionBinder and BindingContext structs No need to allocate on the heap. * Remove AggregateDeclaration We only ever care about the AggregateSymbol it relates to. (The two aren't really separate in dynamic code, where there aren't really declarations). * Remove IsChecked and CallingContext from C# binders. Now not used as they are passed to RuntimeBinder on construction, except for CallingContext remaining in CSharpInvokeMemberBinder for use in deferring. * Make RecordBinOpSigFromArgs static. A last member that can be made static. CC @VSadov@OmarTawfik
The text was updated successfully, but these errors were encountered:
the C# function doesn't bind to the other and thrown an error
Microsoft.CSharp has several objects that are heavily used throughout the library that have circular dependencies on each other, as well as several other classes depending on them. Use of them hence requires either a field in each object that will use them, or to follow chains of such fields. Prior to #25191 it was necessary for them to be instances so that they could be replaced with new versions. This no longer being necessary it's possible to make them all static. At the same time, the related
RuntimeBinder
,ExpressionBinder
andBindingContext
classes are relatively heavy, mostly due to these dependencies. They are hence created once unless a cast must be attempted with a differentBindingContext
, andBindingContext
's state is overwritten for each operation. Removing these dependencies makes these very light, allowing them to bereadonly struct
s that are created for each operation. * HaveTypeArray
in charge of the emptyTypeArray
singleton * MakeTypeArray
allocation a static responsibility ofTypeArray
* Remove some orphaned members. MostlyBSYMMGR
-returning members that had been used to allocateTypeArrays
* Make members static where possible. Those that can already be easily made static. Includes removing some members that this makes no longer necessary. * Remove unused parameters Since some are of the types we'll be making static, and such parameters will have to go anyway. * MakeTypeTable
static And more conventional names withinTypeTable
. * MoreTypeManager
state & methods to static * MakeSYMTBL.Key
an immutable struct. *SYMTBL
completely static and renamed toSymbolStore
More conventional name, and doesn't clash with otherSymbolTable
class. *GetWinRTCollectionIfacesAll
to property. *SymFactory
static class. * RemovePredefinedTypes._symbolManager
field Only used in assertion. * Remove assert comparison with this inGetAggregate
Assert is the only reason to not be static, allows a cascade of more changes to static. * MakeInternalsVisibleTo
check static. * Make cycle of instance methods static Take quite a large set of methods which must be instance because of cyclic instance dependencies, and make them all static. Removes dependency inAggregateSymbol
andNullableType
onTypeManager
instances. * ReplaceGetAggTypeSym
with virtual method onCType
. Merged with existingGetAts
onNullableType
. Comment says this would be nice, and indeed it would, and its easy now. * Make those members that can now be static, static. * Remove orphaned members and fields. *PredefinedMembers
entirely static. * RemoveUserStringBuilder.m_buildingInProgress
Only used in asserts, just assert on whetherm_strBuilder
is null or not. Also renamem_strBuilder
to_strBuilder
to be more conventional. * Favour returning over out inUserStringBuilder
And favour clearingStringBuilder
over creating another. * MakeErrorHandling
completely static. CreatingUserStringBuilder
instances on demand. *TypeManager
static. * MakeCNullable
methods static and merge directly intoExpressionBinder
Don't cache method and property, as they're already cached. * Don't preload types. Either they'll be loaded soon anyway, or else it's a wasted effort. * MoveCompareTypes
into Better.cs * RemoveBSYMMGR.LookupAggMember
Just call intoSymbolStore.LookupSym
* MoveLookupNextSym
logic intoSymbol
* RemoveBSYMMGR
andGlobalSymbolContext
No longer any use. *ExprFactory
static *SymbolLoader
static *CSemanticChecker
static * Don't pre-emptively loadSystem.Object
Will be loaded as a base of the first type encountered anyway. *SymbolTable
static * More methods can be made static * Remove orphaned method. * Move methods for gettingMemberInfo
s from expressions into those expressions * ReplaceExpressionTreeCallRewriter.GetObject
with virtual property inExpr
*TypeArray
tidy-up. * PassExpressionBinder
to operator delegates, and make them static. Allows array to be created once statically, rather than on each instance construction. * CreateRuntimeBinder
,ExpressionBinder
andBindingContext
per operation These are now very lightweight, so it's simpler to create them anew each time rather than overwriting the values in theBindingContext
. * MakeRuntimeBinder
,ExpressionBinder
andBindingContext
structs No need to allocate on the heap. * RemoveAggregateDeclaration
We only ever care about theAggregateSymbol
it relates to. (The two aren't really separate in dynamic code, where there aren't really declarations). * RemoveIsChecked
andCallingContext
from C# binders. Now not used as they are passed toRuntimeBinder
on construction, except forCallingContext
remaining inCSharpInvokeMemberBinder
for use in deferring. * MakeRecordBinOpSigFromArgs
static. A last member that can be made static. CC @VSadov @OmarTawfikThe text was updated successfully, but these errors were encountered: