提交 bffb08c0 编写于 作者: J Jared Parsons

MS.CA.CSharp uses framework nullable

上级 aaed1133
...@@ -1020,7 +1020,7 @@ internal override IEnumerable<ReferenceDirective> ReferenceDirectives ...@@ -1020,7 +1020,7 @@ internal override IEnumerable<ReferenceDirective> ReferenceDirectives
{ {
RoslynDebug.Assert(directive.SyntaxTree.FilePath is object); RoslynDebug.Assert(directive.SyntaxTree.FilePath is object);
MetadataReference reference; MetadataReference? reference;
return ReferenceDirectiveMap.TryGetValue((directive.SyntaxTree.FilePath, directive.File.ValueText), out reference) ? reference : null; return ReferenceDirectiveMap.TryGetValue((directive.SyntaxTree.FilePath, directive.File.ValueText), out reference) ? reference : null;
} }
...@@ -1268,13 +1268,13 @@ internal new NamespaceSymbol GlobalNamespace ...@@ -1268,13 +1268,13 @@ internal new NamespaceSymbol GlobalNamespace
return null; return null;
} }
private ConcurrentDictionary<string?, NamespaceSymbol>? _externAliasTargets; private ConcurrentDictionary<string, NamespaceSymbol>? _externAliasTargets;
internal bool GetExternAliasTarget(string? aliasName, out NamespaceSymbol? @namespace) internal bool GetExternAliasTarget(string aliasName, out NamespaceSymbol? @namespace)
{ {
if (_externAliasTargets == null) if (_externAliasTargets == null)
{ {
Interlocked.CompareExchange(ref _externAliasTargets, new ConcurrentDictionary<string?, NamespaceSymbol>(), null); Interlocked.CompareExchange(ref _externAliasTargets, new ConcurrentDictionary<string, NamespaceSymbol>(), null);
} }
else if (_externAliasTargets.TryGetValue(aliasName, out @namespace)) else if (_externAliasTargets.TryGetValue(aliasName, out @namespace))
{ {
...@@ -1443,7 +1443,7 @@ private static CSDiagnosticInfo CreateReflectionTypeNotFoundError(Type type) ...@@ -1443,7 +1443,7 @@ private static CSDiagnosticInfo CreateReflectionTypeNotFoundError(Type type)
// The type or namespace name '{0}' could not be found in the global namespace (are you missing an assembly reference?) // The type or namespace name '{0}' could not be found in the global namespace (are you missing an assembly reference?)
return new CSDiagnosticInfo( return new CSDiagnosticInfo(
ErrorCode.ERR_GlobalSingleTypeNameNotFound, ErrorCode.ERR_GlobalSingleTypeNameNotFound,
new object[] { type.AssemblyQualifiedName }, new object[] { type.AssemblyQualifiedName ?? "" },
ImmutableArray<Symbol>.Empty, ImmutableArray<Symbol>.Empty,
ImmutableArray<Location>.Empty ImmutableArray<Location>.Empty
); );
...@@ -2045,7 +2045,7 @@ internal BinderFactory GetBinderFactory(SyntaxTree syntaxTree) ...@@ -2045,7 +2045,7 @@ internal BinderFactory GetBinderFactory(SyntaxTree syntaxTree)
binderFactories = Interlocked.CompareExchange(ref _binderFactories, binderFactories, null) ?? binderFactories; binderFactories = Interlocked.CompareExchange(ref _binderFactories, binderFactories, null) ?? binderFactories;
} }
BinderFactory previousFactory; BinderFactory? previousFactory;
var previousWeakReference = binderFactories[treeNum]; var previousWeakReference = binderFactories[treeNum];
if (previousWeakReference != null && previousWeakReference.TryGetTarget(out previousFactory)) if (previousWeakReference != null && previousWeakReference.TryGetTarget(out previousFactory))
{ {
...@@ -2062,7 +2062,7 @@ private BinderFactory AddNewFactory(SyntaxTree syntaxTree, [NotNull] ref WeakRef ...@@ -2062,7 +2062,7 @@ private BinderFactory AddNewFactory(SyntaxTree syntaxTree, [NotNull] ref WeakRef
while (true) while (true)
{ {
BinderFactory previousFactory; BinderFactory? previousFactory;
WeakReference<BinderFactory>? previousWeakReference = slot; WeakReference<BinderFactory>? previousWeakReference = slot;
if (previousWeakReference != null && previousWeakReference.TryGetTarget(out previousFactory)) if (previousWeakReference != null && previousWeakReference.TryGetTarget(out previousFactory))
{ {
...@@ -3620,7 +3620,7 @@ public IEnumerable<Symbol> GetSymbolsWithName() ...@@ -3620,7 +3620,7 @@ public IEnumerable<Symbol> GetSymbolsWithName()
} }
private NamespaceOrTypeSymbol? GetCachedSymbol(MergedNamespaceOrTypeDeclaration declaration) private NamespaceOrTypeSymbol? GetCachedSymbol(MergedNamespaceOrTypeDeclaration declaration)
=> _cache.TryGetValue(declaration, out NamespaceOrTypeSymbol symbol) => _cache.TryGetValue(declaration, out NamespaceOrTypeSymbol? symbol)
? symbol ? symbol
: null; : null;
......
...@@ -15,10 +15,6 @@ ...@@ -15,10 +15,6 @@
<PackageDescription> <PackageDescription>
.NET Compiler Platform ("Roslyn") support for C#, Microsoft.CodeAnalysis.CSharp.dll. .NET Compiler Platform ("Roslyn") support for C#, Microsoft.CodeAnalysis.CSharp.dll.
</PackageDescription> </PackageDescription>
<!-- Disable the nullable warnings when compiling for netcoreapp3.1 during our transition period -->
<DisableNullableWarnings Condition="'$(TargetFramework)' == 'netcoreapp3.1'">true</DisableNullableWarnings>
<DisableNullableWarnings Condition="'$(TargetFramework)' == 'netstandard2.0'">false</DisableNullableWarnings>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\Core\Portable\Microsoft.CodeAnalysis.csproj" /> <ProjectReference Include="..\..\Core\Portable\Microsoft.CodeAnalysis.csproj" />
......
...@@ -828,7 +828,7 @@ private static void UpdateSymbolCacheNoLock(List<int> newSymbols, ImmutableArray ...@@ -828,7 +828,7 @@ private static void UpdateSymbolCacheNoLock(List<int> newSymbols, ImmutableArray
AssemblyIdentity assemblyIdentity, AssemblyIdentity assemblyIdentity,
ref Dictionary<AssemblyIdentity, MissingAssemblySymbol>? missingAssemblies) ref Dictionary<AssemblyIdentity, MissingAssemblySymbol>? missingAssemblies)
{ {
MissingAssemblySymbol missingAssembly; MissingAssemblySymbol? missingAssembly;
if (missingAssemblies == null) if (missingAssemblies == null)
{ {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册