323 references to TryAdd
Aspire.Dashboard (3)
Components\Pages\ConsoleLogs.razor.cs (1)
190var added = _resourceByName.TryAdd(resource.Name, resource);
Components\Pages\Resources.razor.cs (1)
308added = _resourceByName.TryAdd(resource.Name, resource);
Model\ResourceOutgoingPeerResolver.cs (1)
36var added = _resourceByName.TryAdd(resource.Name, resource);
Aspire.Hosting (3)
Dcp\DcpExecutor.cs (1)
605map.TryAdd(resource.Metadata.Name, resource);
Dcp\DcpExecutorEvents.cs (1)
22var success = _eventSubscriptionListLookup.TryAdd(typeof(T), (obj) => callback((T)obj));
Eventing\DistributedApplicationEventing.cs (1)
91if (!_eventSubscriptionListLookup.TryAdd(typeof(T), new List<DistributedApplicationEventSubscription> { subscription }))
Aspire.Hosting.Analyzers (1)
AppHostAnalyzer.cs (1)
69modelNameOperations.TryAdd(ModelNameOperation.Create(invocation, modelTypes, token), value: default);
Aspire.Microsoft.Data.SqlClient (1)
src\Vendoring\OpenTelemetry.Instrumentation.SqlClient\SqlClientTraceInstrumentationOptions.cs (1)
268ConnectionDetailCache.TryAdd(dataSource, connectionDetails);
Aspire.Microsoft.EntityFrameworkCore.SqlServer (1)
src\Vendoring\OpenTelemetry.Instrumentation.SqlClient\SqlClientTraceInstrumentationOptions.cs (1)
268ConnectionDetailCache.TryAdd(dataSource, connectionDetails);
Aspire.StackExchange.Redis (1)
src\Vendoring\OpenTelemetry.Instrumentation.StackExchangeRedis\StackExchangeRedisConnectionInstrumentation.cs (1)
90this.Cache.TryAdd(cacheKey, session);
dotnet-svcutil-lib (1)
FrameworkFork\System.ServiceModel\Internals\System\Runtime\TimeoutHelper.cs (1)
305if (s_tokenCache.TryAdd(targetTime, tcs.Task))
Metrics (2)
src\RoslynAnalyzers\Utilities\Compiler\PooledObjects\PooledConcurrentDictionary.cs (1)
80var added = instance.TryAdd(kvp.Key, kvp.Value);
src\RoslynAnalyzers\Utilities\Compiler\PooledObjects\PooledConcurrentSet.cs (1)
68public bool Add(T value) => _dictionary.TryAdd(value, 0);
Metrics.Legacy (2)
src\RoslynAnalyzers\Utilities\Compiler\PooledObjects\PooledConcurrentDictionary.cs (1)
80var added = instance.TryAdd(kvp.Key, kvp.Value);
src\RoslynAnalyzers\Utilities\Compiler\PooledObjects\PooledConcurrentSet.cs (1)
68public bool Add(T value) => _dictionary.TryAdd(value, 0);
Microsoft.AspNetCore.App.Analyzers (1)
RouteHandlers\RouteHandlerAnalyzer.cs (1)
103mapOperations.TryAdd(MapOperation.Create(invocation, routeUsage), value: default);
Microsoft.AspNetCore.Components (7)
BindConverter.cs (2)
1797_cache.TryAdd(typeof(T), formatter); 2004_cache.TryAdd(typeof(T), parser);
ComponentFactory.cs (1)
43_cachedComponentTypeInfo.TryAdd(componentType, cacheEntry);
DefaultComponentActivator.cs (1)
37_cachedComponentTypeInfo.TryAdd(componentType, factory);
Reflection\ComponentProperties.cs (1)
379_referenceEqualityWritersCache.TryAdd(parameterName, writer);
Routing\RouteTableFactory.cs (1)
43_cache.TryAdd(routeKey, routeTable);
Routing\UrlValueConstraint.cs (1)
29_cachedInstances.TryAdd(targetType, result);
Microsoft.AspNetCore.Components.Endpoints (3)
src\Shared\PropertyHelper\PropertyHelper.cs (3)
436visiblePropertiesCache?.TryAdd(type, result); 478visiblePropertiesCache?.TryAdd(type, result); 516cache?.TryAdd(type, result);
Microsoft.AspNetCore.Components.Server (3)
Circuits\CircuitRegistry.cs (2)
76if (!ConnectedCircuits.TryAdd(circuitHost.CircuitId, circuitHost)) 249ConnectedCircuits.TryAdd(circuitId, disconnectedEntry.CircuitHost);
Circuits\RemoteJSRuntime.cs (1)
178if (!_pendingDotNetToJSStreams.TryAdd(streamId, cancelableStreamReference))
Microsoft.AspNetCore.Components.WebAssembly (1)
.packages\microsoft.dotnet.hotreload.agent\10.0.100-preview.6.25278.103\contentFiles\cs\netstandard2.1\HotReloadAgent.cs (1)
100if (_deltas.TryGetValue(moduleId.Value, out var updateDeltas) && _appliedAssemblies.TryAdd(loadedAssembly, loadedAssembly))
Microsoft.AspNetCore.DataProtection (1)
KeyManagement\XmlKeyManager.cs (1)
333if (!_knownKeyMap.TryAdd(key.KeyId, key))
Microsoft.AspNetCore.Http.Abstractions (5)
Routing\EndpointMetadataCollection.cs (1)
125_cache.TryAdd(typeof(T), results);
Routing\RouteValueDictionary.cs (1)
894_propertyCache.TryAdd(type, Properties);
src\Shared\PropertyHelper\PropertyHelper.cs (3)
436visiblePropertiesCache?.TryAdd(type, result); 478visiblePropertiesCache?.TryAdd(type, result); 516cache?.TryAdd(type, result);
Microsoft.AspNetCore.Http.Connections (1)
Internal\HttpConnectionManager.cs (1)
83_connections.TryAdd(connectionToken, connection);
Microsoft.AspNetCore.Mvc.Core (9)
ActionConstraints\ActionConstraintCache.cs (1)
89cache.Entries.TryAdd(action, entry);
Infrastructure\AsyncEnumerableReader.cs (2)
61_asyncEnumerableConverters.TryAdd(type, reader); 72_asyncEnumerableConverters.TryAdd(type, reader);
ModelBinding\ModelBinderFactory.cs (1)
184_cache.TryAdd(new Key(metadata, cacheToken), binder);
ModelBinding\Validation\ClientValidatorCache.cs (1)
71_cacheEntries.TryAdd(metadata, entry);
ModelBinding\Validation\ValidatorCache.cs (1)
61_cacheEntries.TryAdd(metadata, entry);
src\Shared\PropertyHelper\PropertyHelper.cs (3)
436visiblePropertiesCache?.TryAdd(type, result); 478visiblePropertiesCache?.TryAdd(type, result); 516cache?.TryAdd(type, result);
Microsoft.AspNetCore.Mvc.Formatters.Xml (4)
XmlDataContractSerializerInputFormatter.cs (1)
244_serializerCache.TryAdd(type, serializer);
XmlDataContractSerializerOutputFormatter.cs (1)
300_serializerCache.TryAdd(type, serializer);
XmlSerializerInputFormatter.cs (1)
249_serializerCache.TryAdd(type, serializer);
XmlSerializerOutputFormatter.cs (1)
289_serializerCache.TryAdd(type, serializer);
Microsoft.AspNetCore.Mvc.NewtonsoftJson (2)
src\Mvc\Mvc.Core\src\Infrastructure\AsyncEnumerableReader.cs (2)
61_asyncEnumerableConverters.TryAdd(type, reader); 72_asyncEnumerableConverters.TryAdd(type, reader);
Microsoft.AspNetCore.Mvc.TagHelpers (1)
Cache\DistributedCacheTagHelperService.cs (1)
79_workers.TryAdd(key, tcs.Task);
Microsoft.AspNetCore.Mvc.ViewFeatures (3)
ExpressionHelper.cs (2)
135expressionTextCache?.TryAdd(expression, string.Empty); 191expressionTextCache.TryAdd(expression, expressionText);
ViewComponents\ViewComponentInvokerCache.cs (1)
65cache.Entries.TryAdd(viewComponentDescriptor, executor);
Microsoft.AspNetCore.OpenApi (1)
Services\OpenApiDocumentService.cs (1)
285_operationTransformerContextCache.TryAdd(description.ActionDescriptor.Id, operationContext);
Microsoft.AspNetCore.OutputCaching (2)
DispatcherExtensions.cs (2)
26if (_workers.TryAdd(key, tcs.Task)) 65if (_workers.TryAdd(key, tcs.Task))
Microsoft.AspNetCore.Routing (3)
src\Shared\PropertyHelper\PropertyHelper.cs (3)
436visiblePropertiesCache?.TryAdd(type, result); 478visiblePropertiesCache?.TryAdd(type, result); 516cache?.TryAdd(type, result);
Microsoft.AspNetCore.Routing.Abstractions (3)
src\Shared\PropertyHelper\PropertyHelper.cs (3)
436visiblePropertiesCache?.TryAdd(type, result); 478visiblePropertiesCache?.TryAdd(type, result); 516cache?.TryAdd(type, result);
Microsoft.AspNetCore.Server.HttpSys (1)
RequestProcessing\TlsListener.cs (1)
57if (!_connectionTimestamps.TryAdd(connectionId, _timeProvider.GetUtcNow()))
Microsoft.AspNetCore.Server.Kestrel.Core (4)
Internal\Infrastructure\ConnectionManager.cs (1)
48if (!_connectionReferences.TryAdd(id, connectionReference))
Internal\Infrastructure\TransportConnectionManager.cs (1)
27if (!_connectionReferences.TryAdd(id, connectionReference))
Internal\WebTransport\WebTransportSession.cs (2)
135var success = _openStreams.TryAdd(stream.StreamId, stream); 153var addedToOpenStreams = _openStreams.TryAdd(stream.StreamId, stream);
Microsoft.AspNetCore.Shared.Tests (3)
src\Shared\PropertyHelper\PropertyHelper.cs (3)
436visiblePropertiesCache?.TryAdd(type, result); 478visiblePropertiesCache?.TryAdd(type, result); 516cache?.TryAdd(type, result);
Microsoft.AspNetCore.SignalR.Core (4)
HubConnectionStore.cs (1)
45_connections.TryAdd(connection.ConnectionId, connection);
Internal\DefaultHubDispatcher.cs (1)
529if (!connection.ActiveRequestCancellationSources.TryAdd(invocationId, streamCts))
src\SignalR\common\Shared\ClientResultsManager.cs (2)
21var result = _pendingInvocations.TryAdd(invocationId, (typeof(T), connectionId, tcs, static (state, completionMessage) => 43var result = _pendingInvocations.TryAdd(invocationId, invocationInfo);
Microsoft.AspNetCore.SignalR.StackExchangeRedis (2)
src\SignalR\common\Shared\ClientResultsManager.cs (2)
21var result = _pendingInvocations.TryAdd(invocationId, (typeof(T), connectionId, tcs, static (state, completionMessage) => 43var result = _pendingInvocations.TryAdd(invocationId, invocationInfo);
Microsoft.Build (75)
BackEnd\Components\Caching\ResultsCache.cs (1)
84if (!_resultsByConfiguration.TryAdd(result.ConfigurationId, result))
BackEnd\Components\Communications\NodeProviderOutOfProcBase.cs (2)
282_processesToIgnore.TryAdd(nodeLookupKey, default); 338_processesToIgnore.TryAdd(GetProcessesToIgnoreKey(hostHandshake, msbuildProcess.Id), default);
Evaluation\Evaluator.cs (1)
864BuildManager.ProjectCacheDescriptors.TryAdd(projectCacheItem, projectCacheItem);
Evaluation\SimpleProjectRootElementCache.cs (1)
83if (_cache.TryAdd(projectRootElement.FullPath, projectRootElement))
Graph\ParallelWorkSet.cs (1)
114if (!_inProgressOrCompletedWork.TryAdd(key, workItem))
RegisteredTaskObjectCacheBase.cs (1)
63dict?.TryAdd(key, obj);
Resources\Constants.cs (68)
201return s_availableStaticMethods.TryAdd(key, value); 213return s_availableStaticMethods.TryAdd(CreateQualifiedMethodName(typeFullName, simpleMethodName), typeInformation); 298availableStaticMethods.TryAdd("System.Environment::ExpandEnvironmentVariables", environmentType); 299availableStaticMethods.TryAdd("System.Environment::GetEnvironmentVariable", environmentType); 300availableStaticMethods.TryAdd("System.Environment::GetEnvironmentVariables", environmentType); 301availableStaticMethods.TryAdd("System.Environment::GetFolderPath", environmentType); 302availableStaticMethods.TryAdd("System.Environment::GetLogicalDrives", environmentType); 305availableStaticMethods.TryAdd("System.Environment::CommandLine", environmentType); 306availableStaticMethods.TryAdd("System.Environment::Is64BitOperatingSystem", environmentType); 307availableStaticMethods.TryAdd("System.Environment::Is64BitProcess", environmentType); 308availableStaticMethods.TryAdd("System.Environment::MachineName", environmentType); 309availableStaticMethods.TryAdd("System.Environment::NewLine", environmentType); 310availableStaticMethods.TryAdd("System.Environment::OSVersion", environmentType); 311availableStaticMethods.TryAdd("System.Environment::ProcessorCount", environmentType); 312availableStaticMethods.TryAdd("System.Environment::StackTrace", environmentType); 313availableStaticMethods.TryAdd("System.Environment::SystemDirectory", environmentType); 314availableStaticMethods.TryAdd("System.Environment::SystemPageSize", environmentType); 315availableStaticMethods.TryAdd("System.Environment::TickCount", environmentType); 316availableStaticMethods.TryAdd("System.Environment::UserDomainName", environmentType); 317availableStaticMethods.TryAdd("System.Environment::UserInteractive", environmentType); 318availableStaticMethods.TryAdd("System.Environment::UserName", environmentType); 319availableStaticMethods.TryAdd("System.Environment::Version", environmentType); 320availableStaticMethods.TryAdd("System.Environment::WorkingSet", environmentType); 322availableStaticMethods.TryAdd("System.IO.Directory::GetDirectories", directoryType); 323availableStaticMethods.TryAdd("System.IO.Directory::GetFiles", directoryType); 324availableStaticMethods.TryAdd("System.IO.Directory::GetLastAccessTime", directoryType); 325availableStaticMethods.TryAdd("System.IO.Directory::GetLastWriteTime", directoryType); 326availableStaticMethods.TryAdd("System.IO.Directory::GetParent", directoryType); 327availableStaticMethods.TryAdd("System.IO.File::Exists", fileType); 328availableStaticMethods.TryAdd("System.IO.File::GetCreationTime", fileType); 329availableStaticMethods.TryAdd("System.IO.File::GetAttributes", fileType); 330availableStaticMethods.TryAdd("System.IO.File::GetLastAccessTime", fileType); 331availableStaticMethods.TryAdd("System.IO.File::GetLastWriteTime", fileType); 332availableStaticMethods.TryAdd("System.IO.File::ReadAllText", fileType); 334availableStaticMethods.TryAdd("System.Globalization.CultureInfo::GetCultureInfo", new Tuple<string, Type>(null, typeof(CultureInfo))); // user request 335availableStaticMethods.TryAdd("System.Globalization.CultureInfo::new", new Tuple<string, Type>(null, typeof(CultureInfo))); // user request 336availableStaticMethods.TryAdd("System.Globalization.CultureInfo::CurrentUICulture", new Tuple<string, Type>(null, typeof(CultureInfo))); // user request 339availableStaticMethods.TryAdd("MSBuild", new Tuple<string, Type>(null, typeof(IntrinsicFunctions))); 340availableStaticMethods.TryAdd("System.Byte", new Tuple<string, Type>(null, typeof(Byte))); 341availableStaticMethods.TryAdd("System.Char", new Tuple<string, Type>(null, typeof(Char))); 342availableStaticMethods.TryAdd("System.Convert", new Tuple<string, Type>(null, typeof(Convert))); 343availableStaticMethods.TryAdd("System.DateTime", new Tuple<string, Type>(null, typeof(DateTime))); 344availableStaticMethods.TryAdd("System.DateTimeOffset", new Tuple<string, Type>(null, typeof(DateTimeOffset))); 345availableStaticMethods.TryAdd("System.Decimal", new Tuple<string, Type>(null, typeof(Decimal))); 346availableStaticMethods.TryAdd("System.Double", new Tuple<string, Type>(null, typeof(Double))); 347availableStaticMethods.TryAdd("System.Enum", new Tuple<string, Type>(null, typeof(Enum))); 348availableStaticMethods.TryAdd("System.Guid", new Tuple<string, Type>(null, typeof(Guid))); 349availableStaticMethods.TryAdd("System.Int16", new Tuple<string, Type>(null, typeof(Int16))); 350availableStaticMethods.TryAdd("System.Int32", new Tuple<string, Type>(null, typeof(Int32))); 351availableStaticMethods.TryAdd("System.Int64", new Tuple<string, Type>(null, typeof(Int64))); 352availableStaticMethods.TryAdd("System.IO.Path", new Tuple<string, Type>(null, typeof(Path))); 353availableStaticMethods.TryAdd("System.Math", new Tuple<string, Type>(null, typeof(Math))); 354availableStaticMethods.TryAdd("System.UInt16", new Tuple<string, Type>(null, typeof(UInt16))); 355availableStaticMethods.TryAdd("System.UInt32", new Tuple<string, Type>(null, typeof(UInt32))); 356availableStaticMethods.TryAdd("System.UInt64", new Tuple<string, Type>(null, typeof(UInt64))); 357availableStaticMethods.TryAdd("System.SByte", new Tuple<string, Type>(null, typeof(SByte))); 358availableStaticMethods.TryAdd("System.Single", new Tuple<string, Type>(null, typeof(Single))); 359availableStaticMethods.TryAdd("System.String", new Tuple<string, Type>(null, typeof(String))); 360availableStaticMethods.TryAdd("System.StringComparer", new Tuple<string, Type>(null, typeof(StringComparer))); 361availableStaticMethods.TryAdd("System.TimeSpan", new Tuple<string, Type>(null, typeof(TimeSpan))); 362availableStaticMethods.TryAdd("System.Text.RegularExpressions.Regex", new Tuple<string, Type>(null, typeof(Regex))); 363availableStaticMethods.TryAdd("System.UriBuilder", new Tuple<string, Type>(null, typeof(UriBuilder))); 364availableStaticMethods.TryAdd("System.Version", new Tuple<string, Type>(null, typeof(Version))); 365availableStaticMethods.TryAdd("Microsoft.Build.Utilities.ToolLocationHelper", new Tuple<string, Type>("Microsoft.Build.Utilities.ToolLocationHelper, Microsoft.Build.Utilities.Core, Version=" + MSBuildConstants.CurrentAssemblyVersion + ", Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", null)); 366availableStaticMethods.TryAdd("System.Runtime.InteropServices.RuntimeInformation", runtimeInformationType); 367availableStaticMethods.TryAdd("System.Runtime.InteropServices.OSPlatform", osPlatformType); 374availableStaticMethods.TryAdd("System.OperatingSystem", operatingSystemType); 375availableStaticMethods.TryAdd("Microsoft.Build.Framework.OperatingSystem", operatingSystemType);
Microsoft.Build.Framework (2)
FileClassifier.cs (1)
242if (_knownImmutableDirectories.TryAdd(d, d))
ImmutableFilesTimestampCache.cs (1)
33public void TryAdd(string fullPath, DateTime lastModified) => _cache.TryAdd(fullPath, lastModified);
Microsoft.Build.Tasks.Core (18)
AssemblyDependency\GlobalAssemblyCache.cs (5)
308fusionNameToResolvedPath?.TryAdd(strongName, null); 337fusionNameToResolvedPath?.TryAdd(strongName, location); 353fusionNameToResolvedPath?.TryAdd(strongName, location); 370fusionNameToResolvedPath?.TryAdd(strongName, location); 374fusionNameToResolvedPath?.TryAdd(strongName, null);
CodeTaskFactory.cs (1)
826s_compiledTaskCache.TryAdd(fullSpec, compilerResults.CompiledAssembly);
Copy.cs (1)
304_directoriesKnownToExist.TryAdd(destinationFolder, true);
GetSDKReferenceFiles.cs (6)
688_cacheFileForSDKs.TryAdd(sdkIdentity, info); 1034referencesByDirectory.TryAdd(group.Key, group.ToList()); 1037Parallel.ForEach(sdkManifestReferences, reference => { references.TryAdd(reference, GetSDKReferenceInfo(reference)); }); 1051referencesByDirectory.TryAdd(path, files); 1053Parallel.ForEach(files, filePath => { references.TryAdd(filePath, GetSDKReferenceInfo(filePath)); }); 1068redistFilesByDirectory.TryAdd(path, files);
RedistList.cs (4)
194_remappingCache.TryAdd(extensionToRemap, remappedExtension); 416_assemblyNameToUnifiedAssemblyName.TryAdd(assemblyName, unifiedEntry); 465_assemblyNameInRedist.TryAdd(assemblyName.CloneImmutable(), isAssemblyNameInRedist); 631_cachedDenyList.TryAdd(key, denyListOfAssemblyNames);
RoslynCodeTaskFactory\RoslynCodeTaskFactory.cs (1)
766CompiledAssemblyCache.TryAdd(taskInfo, assembly);
Microsoft.CodeAnalysis (8)
CodeGen\PrivateImplementationDetails.cs (2)
456return _synthesizedMethods.TryAdd(method.Name, method); 504return _synthesizedTopLevelTypes.TryAdd(type.Name, type);
CodeGen\TokenMap.cs (1)
64referenceAdded = _itemIdentityToToken.TryAdd(item, token);
DiagnosticAnalyzer\AnalyzerDriver.cs (2)
2304GeneratedCodeFilesMap.TryAdd(tree, isGenerated); 2351_lazyTreesWithHiddenRegionsMap.TryAdd(tree, hasHiddenRegions);
InternalUtilities\ConcurrentDictionaryExtensions.cs (1)
22if (!dict.TryAdd(key, value))
InternalUtilities\ConcurrentSet.cs (1)
84return _dictionary.TryAdd(value, 0);
MetadataReader\PEModule.cs (1)
2677_lazyTypeDefToTypeIdentifierMap.TryAdd(typeDef, new AttributeInfo(customAttribute, signatureIndex));
Microsoft.CodeAnalysis.Analyzers (4)
MetaAnalyzers\DiagnosticAnalyzerAPIUsageAnalyzer.cs (1)
105var added = namedTypesToAccessedTypesMap.TryAdd(namedType, usedTypes);
MetaAnalyzers\DiagnosticDescriptorCreationAnalyzer.cs (1)
295symbolToResourceMap.TryAdd(field, (nameOfLocalizableResource, resourceFileName));
src\RoslynAnalyzers\Utilities\Compiler\PooledObjects\PooledConcurrentDictionary.cs (1)
80var added = instance.TryAdd(kvp.Key, kvp.Value);
src\RoslynAnalyzers\Utilities\Compiler\PooledObjects\PooledConcurrentSet.cs (1)
68public bool Add(T value) => _dictionary.TryAdd(value, 0);
Microsoft.CodeAnalysis.AnalyzerUtilities (3)
src\RoslynAnalyzers\Utilities\Compiler\PooledObjects\PooledConcurrentDictionary.cs (1)
80var added = instance.TryAdd(kvp.Key, kvp.Value);
src\RoslynAnalyzers\Utilities\Compiler\PooledObjects\PooledConcurrentSet.cs (1)
68public bool Add(T value) => _dictionary.TryAdd(value, 0);
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\TaintedDataAnalysis\WebInputSources.cs (1)
105classCache.TryAdd(typeSymbol, isController);
Microsoft.CodeAnalysis.BannedApiAnalyzers (2)
src\RoslynAnalyzers\Utilities\Compiler\PooledObjects\PooledConcurrentDictionary.cs (1)
80var added = instance.TryAdd(kvp.Key, kvp.Value);
src\RoslynAnalyzers\Utilities\Compiler\PooledObjects\PooledConcurrentSet.cs (1)
68public bool Add(T value) => _dictionary.TryAdd(value, 0);
Microsoft.CodeAnalysis.CodeStyle (6)
src\Analyzers\Core\Analyzers\IDEDiagnosticIdToOptionMappingHelper.cs (2)
90map.TryAdd(diagnosticId, options); 102s_diagnosticIdToFadingOptionMap.TryAdd(diagnosticId, fadingOption);
src\Analyzers\Core\Analyzers\NamingStyle\NamingStyleDiagnosticAnalyzerBase.cs (1)
154cache.TryAdd(symbol.Name, failureReason);
src\Compilers\Core\Portable\InternalUtilities\ConcurrentDictionaryExtensions.cs (1)
22if (!dict.TryAdd(key, value))
src\Compilers\Core\Portable\InternalUtilities\ConcurrentSet.cs (1)
84return _dictionary.TryAdd(value, 0);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AliasSymbolCache.cs (1)
70treeMap.TryAdd(key, builder.ToImmutable());
Microsoft.CodeAnalysis.CSharp (12)
Compilation\CSharpCompilation.cs (1)
2777TryAdd(new ImportInfo(syntax.SyntaxTree, syntax.Kind(), syntax.Span), default);
Emitter\NoPia\EmbeddedTypesManager.cs (1)
331if (optTypeManager == null || optTypeManager._reportedSymbolsMap.TryAdd(symbol.OriginalDefinition, true))
FlowAnalysis\NullableWalker.cs (1)
1913state.TryAdd(key, new Data(_variables.GetTotalVariableCount(), requiredAnalysis));
Symbols\AnonymousTypes\AnonymousTypeManager.Templates.cs (1)
108_sourceLocationsSeen.TryAdd(location, true);
Symbols\Metadata\PE\PEModuleSymbol.cs (1)
490added = TypeHandleToTypeMap.TryAdd(type.Handle, type);
Symbols\MetadataOrSourceAssemblySymbol.cs (1)
260AssembliesToWhichInternalAccessHasBeenDetermined.TryAdd(potentialGiverOfAccess, result);
Symbols\Source\SourceAssemblySymbol.cs (5)
2166_optimisticallyGrantedInternalsAccess.TryAdd(potentialGiverOfAccess, true); 2330keys.TryAdd(identity.PublicKey, locationAndValue); 2335keys.TryAdd(identity.PublicKey, locationAndValue); 2336lazyInternalsVisibleToMap.TryAdd(identity.Name, keys); 2653_unassignedFieldsMap.TryAdd(field, isInternal);
Symbols\TypeSymbol.cs (1)
772map.TryAdd(interfaceMember, result);
Microsoft.CodeAnalysis.CSharp.CodeStyle (1)
src\Analyzers\CSharp\Analyzers\UsePrimaryConstructor\CSharpUsePrimaryConstructorDiagnosticAnalyzer.cs (1)
251namedTypeToAnalyzer.TryAdd(namedType, analyzer);
Microsoft.CodeAnalysis.CSharp.Features (1)
src\Analyzers\CSharp\Analyzers\UsePrimaryConstructor\CSharpUsePrimaryConstructorDiagnosticAnalyzer.cs (1)
251namedTypeToAnalyzer.TryAdd(namedType, analyzer);
Microsoft.CodeAnalysis.EditorFeatures (1)
Lightup\LightupHelpers.cs (1)
37wrappedObject.TryAdd(obj.GetType(), canCast);
Microsoft.CodeAnalysis.Features (4)
ExternalAccess\UnitTesting\SolutionCrawler\UnitTestingWorkCoordinator.UnitTestingNormalPriorityProcessor.cs (1)
91_higherPriorityDocumentsNotProcessed.TryAdd(id, /*unused*/null);
src\Analyzers\Core\Analyzers\IDEDiagnosticIdToOptionMappingHelper.cs (2)
90map.TryAdd(diagnosticId, options); 102s_diagnosticIdToFadingOptionMap.TryAdd(diagnosticId, fadingOption);
src\Analyzers\Core\Analyzers\NamingStyle\NamingStyleDiagnosticAnalyzerBase.cs (1)
154cache.TryAdd(symbol.Name, failureReason);
Microsoft.CodeAnalysis.LanguageServer.Protocol (3)
Handler\InlineCompletions\XmlSnippetParser.cs (1)
61_parsedSnippetsCache.TryAdd(matchingSnippetInfo.Title, parsedSnippet);
Protocol\Internal\Efficiency\OptimizedVSCompletionListJsonConverter.cs (1)
107IconRawJson.TryAdd(vsCompletionItem.Icon.ImageId, jsonString);
src\LanguageServer\Microsoft.CommonLanguageServerProtocol.Framework\RequestExecutionQueue.cs (1)
387if (!concurrentlyExecutingTasks.TryAdd(currentWorkTask, currentWorkCts))
Microsoft.CodeAnalysis.PublicApiAnalyzers (6)
DeclarePublicApiAnalyzer.Impl.cs (4)
229_visitedApiList.TryAdd(publicApiName.Name, default); 230_visitedApiList.TryAdd(WithObliviousMarker(publicApiName.Name), default); 231_visitedApiList.TryAdd(publicApiName.NameWithNullability, default); 232_visitedApiList.TryAdd(WithObliviousMarker(publicApiName.NameWithNullability), default);
src\RoslynAnalyzers\Utilities\Compiler\PooledObjects\PooledConcurrentDictionary.cs (1)
80var added = instance.TryAdd(kvp.Key, kvp.Value);
src\RoslynAnalyzers\Utilities\Compiler\PooledObjects\PooledConcurrentSet.cs (1)
68public bool Add(T value) => _dictionary.TryAdd(value, 0);
Microsoft.CodeAnalysis.Remote.Workspaces (2)
Serialization\MessagePackFormatters.cs (2)
83_projectIds.TryAdd(id, projectId); 115var serializeDebugName = _projectIds.TryAdd(value.Id, value);
Microsoft.CodeAnalysis.ResxSourceGenerator (2)
src\RoslynAnalyzers\Utilities\Compiler\PooledObjects\PooledConcurrentDictionary.cs (1)
80var added = instance.TryAdd(kvp.Key, kvp.Value);
src\RoslynAnalyzers\Utilities\Compiler\PooledObjects\PooledConcurrentSet.cs (1)
68public bool Add(T value) => _dictionary.TryAdd(value, 0);
Microsoft.CodeAnalysis.Test.Utilities (1)
TargetFrameworkUtil.cs (1)
433_ = s_dynamicReferenceMap.TryAdd(assemblyName, references);
Microsoft.CodeAnalysis.VisualBasic (8)
Compilation\VisualBasicCompilation.vb (1)
1823LazyInitializer.EnsureInitialized(_lazyImportClauseDependencies).TryAdd((syntaxTree, importsClausePosition), dependencies)
Emit\NoPia\EmbeddedTypesManager.vb (1)
279typeManagerOpt._reportedSymbolsMap.TryAdd(symbol.OriginalDefinition, True) Then
Symbols\AnonymousTypes\AnonymousTypeManager_Templates.vb (1)
39Me._sourceLocationsSeen.TryAdd(location, True)
Symbols\EmbeddedSymbols\EmbeddedSymbolManager.SymbolsCollection.vb (1)
318_symbols.TryAdd(symbol, True)
Symbols\Metadata\PE\PEModuleSymbol.vb (1)
280added = TypeHandleToTypeMap.TryAdd(t.Handle, t)
Symbols\Source\SourceAssemblySymbol.vb (2)
1010_lazyInternalsVisibleToMap.TryAdd(identity.Name, keys) 1660_optimisticallyGrantedInternalsAccess.TryAdd(potentialGiverOfAccess, True)
Symbols\TypeSymbol.vb (1)
664map.TryAdd(interfaceMember, result)
Microsoft.CodeAnalysis.Workspaces (7)
src\Compilers\Core\Portable\InternalUtilities\ConcurrentDictionaryExtensions.cs (1)
22if (!dict.TryAdd(key, value))
src\Compilers\Core\Portable\InternalUtilities\ConcurrentSet.cs (1)
84return _dictionary.TryAdd(value, 0);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AliasSymbolCache.cs (1)
70treeMap.TryAdd(key, builder.ToImmutable());
Storage\SQLite\v2\SQLitePersistentStorage_DocumentIds.cs (1)
47_documentIdToPrimaryKeyMap.TryAdd(documentKey.Id, existingId);
Storage\SQLite\v2\SQLitePersistentStorage_ProjectIds.cs (1)
48_projectIdToPrimaryKeyMap.TryAdd(projectKey.Id, existingId);
Storage\SQLite\v2\SQLitePersistentStorage_StringIds.cs (1)
185_stringToIdMap.TryAdd(value, id);
Storage\StorageDatabaseLogger.cs (1)
35if (_set.Count > 10 || !_set.TryAdd(ex.GetType(), ex))
Microsoft.CodeAnalysis.Workspaces.MSBuild (1)
Rpc\RpcClient.cs (1)
151while (!_outstandingRequests.TryAdd(requestId, (requestCompletionSource, expectedReturnType)));
Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost (3)
Rpc\RpcServer.cs (1)
51if (_rpcTargets.TryAdd(nextIndex, rpcTarget))
src\Compilers\Core\Portable\InternalUtilities\ConcurrentDictionaryExtensions.cs (1)
22if (!dict.TryAdd(key, value))
src\Compilers\Core\Portable\InternalUtilities\ConcurrentSet.cs (1)
84return _dictionary.TryAdd(value, 0);
Microsoft.CodeAnalysis.Workspaces.MSBuild.UnitTests (1)
src\Workspaces\MSBuild\BuildHost\Rpc\RpcServer.cs (1)
51if (_rpcTargets.TryAdd(nextIndex, rpcTarget))
Microsoft.CodeAnalysis.Workspaces.Test.Utilities (1)
Remote\TestSerializerService.cs (1)
88_sharedTestGeneratorReferences.TryAdd(generatorReference.Guid, generatorReference);
Microsoft.CommonLanguageServerProtocol.Framework.Package (1)
RequestExecutionQueue.cs (1)
387if (!concurrentlyExecutingTasks.TryAdd(currentWorkTask, currentWorkCts))
Microsoft.Extensions.AI.Evaluation.Safety (1)
ContentSafetyService.cs (1)
186_ = _serviceUrlCache.TryAdd(key, serviceUrl);
Microsoft.Extensions.Caching.Hybrid (4)
Internal\DefaultHybridCache.Stampede.cs (1)
32if (_currentOperations.TryAdd(stampedeKey, stampedeState))
Internal\DefaultHybridCache.TagInvalidation.cs (3)
120_ = _tagInvalidationTimes.TryAdd(tag, pending); 176_ = _tagInvalidationTimes.TryAdd(tag, pending); 238_ = _tagInvalidationTimes.TryAdd(tag, SafeReadTagInvalidationAsync(tag));
Microsoft.Extensions.Caching.Memory (2)
MemoryCache.cs (2)
747=> key is string s ? _stringEntries.TryAdd(s, entry) : _nonStringEntries.TryAdd(key, entry);
Microsoft.Extensions.Diagnostics.Testing (1)
Logging\FakeLogger.cs (1)
89public void ControlLevel(LogLevel logLevel, bool enabled) => _ = enabled ? _disabledLevels.TryRemove(logLevel, out _) : _disabledLevels.TryAdd(logLevel, false);
Microsoft.Extensions.FileProviders.Physical (2)
PhysicalFilesWatcher.cs (2)
195PollingChangeTokens.TryAdd(pollingChangeToken, pollingChangeToken); 232PollingChangeTokens.TryAdd(pollingChangeToken, pollingChangeToken);
Microsoft.Extensions.Localization (1)
ResourceManagerStringLocalizer.cs (1)
178_missingManifestCache.TryAdd(cacheKey, null);
Microsoft.Extensions.Logging.Console (4)
ConsoleLoggerProvider.cs (4)
109cd.TryAdd(formatter.Name, formatter); 116cd.TryAdd(ConsoleFormatterNames.Simple, new SimpleConsoleFormatter(new FormatterOptionsMonitor<SimpleConsoleFormatterOptions>(new SimpleConsoleFormatterOptions()))); 117cd.TryAdd(ConsoleFormatterNames.Systemd, new SystemdConsoleFormatter(new FormatterOptionsMonitor<ConsoleFormatterOptions>(new ConsoleFormatterOptions()))); 118cd.TryAdd(ConsoleFormatterNames.Json, new JsonConsoleFormatter(new FormatterOptionsMonitor<JsonConsoleFormatterOptions>(new JsonConsoleFormatterOptions())));
Microsoft.Extensions.Options (1)
OptionsCache.cs (1)
100return _cache.TryAdd(name ?? Options.DefaultName, new Lazy<TOptions>(
Microsoft.Maui (1)
Handlers\HybridWebView\HybridWebViewTaskManager.cs (1)
21 if (!_asyncTaskCallbacks.TryAdd(taskIdString, tcs))
Microsoft.ML.Core (3)
Data\Repository.cs (2)
324if (!PathMap.TryAdd(pathEnt, pathTemp)) 532if (!PathMap.TryAdd(pathLower, pathTemp))
Environment\HostEnvironmentBase.cs (1)
472&& !ListenerDict.TryAdd(typeof(TMessage), dispatcher = new Dispatcher<TMessage>()))
Microsoft.ML.Tokenizers (1)
Model\TiktokenTokenizer.cs (1)
1251_tiktokenCache.TryAdd(tiktokenConfiguration.VocabFile, cache);
Microsoft.NET.StringTools (2)
WeakStringCache.Concurrent.cs (2)
66if (_stringsByHashCode.TryAdd(hashCode, handle)) 118if (!removedHandle.IsUsed || !_stringsByHashCode.TryAdd(entry.Key, removedHandle))
Microsoft.VisualStudio.LanguageServices (2)
DesignerAttribute\VisualStudioDesignerAttributeService.cs (1)
289_cpsProjects.TryAdd(projectId, updateService);
Venus\ContainedDocument.cs (1)
125s_containedDocuments.TryAdd(documentId, this);
Microsoft.VisualStudio.LanguageServices.Xaml (1)
Implementation\XamlProjectService.cs (1)
87_documentIds.TryAdd(filePath, documentId);
MSBuild (1)
RegisteredTaskObjectCacheBase.cs (1)
63dict?.TryAdd(key, obj);
PresentationFramework (3)
System\Windows\Markup\Baml2006\WpfXamlType.cs (3)
278if (Members.TryAdd(name, xamlMember)) 359if (Members.TryAdd(xamlMember.Name, xamlMember)) 370if (AttachableMembers.TryAdd(xamlMember.Name, xamlMember))
Roslyn.Diagnostics.Analyzers (4)
src\RoslynAnalyzers\Utilities\Compiler\PooledObjects\PooledConcurrentDictionary.cs (1)
80var added = instance.TryAdd(kvp.Key, kvp.Value);
src\RoslynAnalyzers\Utilities\Compiler\PooledObjects\PooledConcurrentSet.cs (1)
68public bool Add(T value) => _dictionary.TryAdd(value, 0);
SymbolDeclaredEventMustBeGeneratedForSourceSymbols.cs (2)
141_typesWithSymbolDeclaredEventInvoked.TryAdd(namedType, default); 158_sourceSymbolsToCheck.TryAdd(namedType, default);
SignalRSamples (1)
ConnectionList.cs (1)
30_connections.TryAdd(connection.ConnectionId, connection);
SocialWeather (1)
ConnectionList.cs (1)
31_connections.TryAdd(connection.ConnectionId, connection);
System.Collections.Concurrent (1)
System\Collections\Concurrent\ConcurrentDictionary.cs (1)
1572if (!TryAdd(key, value))
System.ComponentModel.Annotations (3)
System\ComponentModel\DataAnnotations\AssociatedMetadataTypeTypeDescriptor.cs (3)
112s_validatedMetadataTypeCache.TryAdd(typeTuple, true); 130s_metadataTypeCache.TryAdd(type, associatedMetadataType); 194s_typeMemberCache.TryAdd(memberTuple, attributes);
System.ComponentModel.TypeConverter (2)
System\ComponentModel\TypeDescriptor.cs (2)
373s_defaultProviderInitialized.TryAdd(type, null); 1701s_providerTypeTable.TryAdd(searchType, node);
System.Data.Odbc (2)
src\libraries\Common\src\System\Data\ProviderBase\DbConnectionPoolGroup.cs (2)
180bool addResult = _poolCollection.TryAdd(currentIdentity, newPool); 261newPoolCollection.TryAdd(entry.Key, entry.Value);
System.Diagnostics.DiagnosticSource (1)
System\Diagnostics\Metrics\AggregationManager.cs (1)
351_instrumentStates.TryAdd(instrument, instrumentState);
System.Net.Http (1)
System\Net\Http\SocketsHttpHandler\HttpConnectionPoolManager.cs (1)
347if (_pools.TryAdd(key, pool))
System.Private.Windows.Core.TestUtilities (1)
NoAssertContext.cs (1)
73s_suppressedThreads.TryAdd(currentThread, --count);
System.Runtime.InteropServices (1)
System\Runtime\InteropServices\Marshalling\DefaultCaching.cs (1)
35return _cache.TryAdd(handle, info);
System.Security.Cryptography (2)
System\Security\Cryptography\OidLookup.cs (2)
47s_lateBoundOidToFriendlyName.TryAdd(oid, mappedName); 82s_lateBoundFriendlyNameToOid.TryAdd(friendlyName, mappedOid);
System.Text.Json (5)
System\Text\Json\Serialization\Converters\Value\EnumConverter.cs (4)
74_nameCacheForWriting.TryAdd(fieldInfo.Key, encodedName); 75_nameCacheForReading.TryAdd(fieldInfo.JsonName, fieldInfo.Key); 153_nameCacheForWriting.TryAdd(key, formatted); 214_nameCacheForWriting.TryAdd(key, formatted);
System\Text\Json\Serialization\Metadata\PolymorphicTypeResolver.cs (1)
48if (!_typeToDiscriminatorId.TryAdd(derivedType, derivedTypeInfoHolder))
System.Text.RegularExpressions (1)
System\Text\RegularExpressions\Regex.Cache.cs (1)
269s_cacheDictionary.TryAdd(key, node);
System.Windows.Forms (1)
System\Windows\Forms\Controls\PropertyGrid\PropertyGridInternal\CategoryGridEntry.cs (1)
21s_categoryStates.TryAdd(name, true);
System.Xaml (3)
System\Xaml\MS\Impl\XmlNsInfo.cs (1)
221result.TryAdd(nsDef.ClrNamespace, xmlNamespaceList);
System\Xaml\Schema\TypeReflector.cs (1)
382_aliasedProperties.TryAdd(directive, member);
System\Xaml\XamlSchemaContext.cs (1)
1217if (dictionary.TryAdd(key, value))
Templates.Blazor.Tests (1)
src\ProjectTemplates\Shared\ProjectFactoryFixture.cs (1)
34if (!_projects.TryAdd(projectKey, project))
Templates.Blazor.WebAssembly.Auth.Tests (1)
src\ProjectTemplates\Shared\ProjectFactoryFixture.cs (1)
34if (!_projects.TryAdd(projectKey, project))
Templates.Blazor.WebAssembly.Tests (1)
src\ProjectTemplates\Shared\ProjectFactoryFixture.cs (1)
34if (!_projects.TryAdd(projectKey, project))
Templates.Mvc.Tests (1)
src\ProjectTemplates\Shared\ProjectFactoryFixture.cs (1)
34if (!_projects.TryAdd(projectKey, project))
Templates.Tests (1)
src\ProjectTemplates\Shared\ProjectFactoryFixture.cs (1)
34if (!_projects.TryAdd(projectKey, project))
Test.Utilities (2)
src\RoslynAnalyzers\Utilities\Compiler\PooledObjects\PooledConcurrentDictionary.cs (1)
80var added = instance.TryAdd(kvp.Key, kvp.Value);
src\RoslynAnalyzers\Utilities\Compiler\PooledObjects\PooledConcurrentSet.cs (1)
68public bool Add(T value) => _dictionary.TryAdd(value, 0);
Text.Analyzers (2)
src\RoslynAnalyzers\Utilities\Compiler\PooledObjects\PooledConcurrentDictionary.cs (1)
80var added = instance.TryAdd(kvp.Key, kvp.Value);
src\RoslynAnalyzers\Utilities\Compiler\PooledObjects\PooledConcurrentSet.cs (1)
68public bool Add(T value) => _dictionary.TryAdd(value, 0);
xunit.console (2)
ConsoleRunner.cs (2)
384completionMessages.TryAdd(Path.GetFileName(assembly.AssemblyFilename), new ExecutionSummary()); 393IExecutionSink resultsSink = new DelegatingExecutionSummarySink(reporterMessageHandler, () => cancel, (path, summary) => completionMessages.TryAdd(path, summary));