Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FI #5

Merged
merged 51 commits into from
Jun 20, 2016
Merged

FI #5

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
d2df33f
Ignore VS Code-generated dirs in gitignore
jamesqo May 26, 2016
e6c653a
Remove VB specialization.
CyrusNajmabadi Jun 10, 2016
cc44b00
Update tests.
CyrusNajmabadi Jun 10, 2016
5e72883
Provide a way for completion providers to specify if they want to be …
CyrusNajmabadi Jun 10, 2016
0a606a4
Move code out of completion helper.
CyrusNajmabadi Jun 10, 2016
cd3fbfc
Merge branch 'master' into removeUnderscore
CyrusNajmabadi Jun 10, 2016
87f646c
Merge branch 'master' into removeUnderscore
CyrusNajmabadi Jun 12, 2016
6973808
Break out a base class for diagnostic taggers that want to show adorn…
CyrusNajmabadi Jun 13, 2016
10e9e6b
Add support for the new 'DiagnosticSeverity.Suggestion' category
CyrusNajmabadi Jun 14, 2016
9315a5a
Simplify code.
CyrusNajmabadi Jun 14, 2016
324cabe
Remove hardcoded values.
CyrusNajmabadi Jun 14, 2016
cc028e8
Fix rendering of suggestion line.
CyrusNajmabadi Jun 14, 2016
a90cb91
Switch to round dots. Fixup tests.
CyrusNajmabadi Jun 15, 2016
3fe2a5e
use an elipsis moniker for suggestions.
CyrusNajmabadi Jun 15, 2016
2df556e
PR feedback.
CyrusNajmabadi Jun 15, 2016
51fc6c9
PR feedback.
CyrusNajmabadi Jun 15, 2016
61d5d2c
Rename tag.
CyrusNajmabadi Jun 15, 2016
55502f8
PR feedback.
CyrusNajmabadi Jun 15, 2016
fe34ef9
Merge branch 'master' into suggestions
CyrusNajmabadi Jun 15, 2016
db571d7
Repurpose 'Info' for Suggestions.
CyrusNajmabadi Jun 15, 2016
99d62ba
Revert version.
CyrusNajmabadi Jun 16, 2016
93ebb39
Ensure experimental settings run against experimental features
jaredpar Jun 15, 2016
2f5df27
loose up a bit on what happens when build error report on us errors o…
heejaechang Jun 16, 2016
db3e3ca
Added initial support for explicit tuple conversions
VSadov Jun 16, 2016
d29375c
Revert "Start plumbing InvocationReasons through SolutionCrawler even…
drognanar Jun 17, 2016
50c22bc
Revert "Make use of InvocationReason in tests and analyzers"
drognanar Jun 17, 2016
fa78c0e
Merge pull request #12059 from heejaechang/errormissingfile2
heejaechang Jun 17, 2016
43cf3cb
Bump package versions to beta4
jasonmalinowski Jun 17, 2016
62b4751
Merge pull request #12040 from CyrusNajmabadi/suggestionsUsingInfo
CyrusNajmabadi Jun 17, 2016
cf87973
Merge pull request #12074 from drognanar/revertreasons
KevinH-MS Jun 17, 2016
cd39b88
Merge pull request #12039 from jaredpar/options
jaredpar Jun 17, 2016
754bf60
Remove supression of StyleCop bug
jasonmalinowski Jun 17, 2016
eef6afb
Make pure function static
jasonmalinowski Jun 17, 2016
b4e5f0a
Use the simpler methods for adding and removing references
jasonmalinowski Jun 17, 2016
5e9a9a4
Delete some dead helpers
jasonmalinowski Jun 17, 2016
0a86188
removed unnecessary usings.
VSadov Jun 17, 2016
e3283df
Allow languages to specify if they want to support completion on back…
CyrusNajmabadi Jun 18, 2016
da05dbe
Rename parameter.
CyrusNajmabadi Jun 18, 2016
ec6ac69
Merge pull request #12068 from VSadov/tupleConversions
VSadov Jun 18, 2016
15c647c
Make the VB deletion behavior the default for all languages.
CyrusNajmabadi Jun 18, 2016
13f87f1
Fixing the VsixVersion to be 42.42.42.42 for unofficial builds.
tannergooding Jun 18, 2016
7f45f2e
Merge pull request #12079 from jasonmalinowski/bump-nuget-version-to-…
jasonmalinowski Jun 18, 2016
932711e
Merge pull request #11595 from jamesqo/patch-1
Pilchie Jun 18, 2016
c4c25b9
Merge pull request #12087 from tannergooding/master
CyrusNajmabadi Jun 18, 2016
4333bf1
Merge pull request #11906 from CyrusNajmabadi/removeUnderscore
CyrusNajmabadi Jun 19, 2016
cf4072d
Merge branch 'master' into removeVBspecificDeletionCode
CyrusNajmabadi Jun 19, 2016
0e4d6a3
Make more deletion code non-VB specific.
CyrusNajmabadi Jun 19, 2016
403afb8
Remove unnecessary parameter.
CyrusNajmabadi Jun 19, 2016
ebc4ef3
Don't preselect softly selected items.
CyrusNajmabadi Jun 19, 2016
ac8f350
Merge pull request #12093 from CyrusNajmabadi/removeMoreVBCode
CyrusNajmabadi Jun 19, 2016
ca3f9ce
Merge pull request #12083 from jasonmalinowski/tweaks-while-investiga…
jasonmalinowski Jun 20, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,6 @@ $RECYCLE.BIN/

# Mac desktop service store files
.DS_Store

# Visual Studio Code
.vscode/
7 changes: 5 additions & 2 deletions build/Targets/VSL.Versions.targets
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@
day-to-day upgrades don't break assembly references to other installed apps. -->
<PropertyGroup>
<AssemblyVersion>$(RoslynSemanticVersion).0</AssemblyVersion>
<VsixVersion>$(RoslynSemanticVersion).$(BuildNumberPart1.Trim())$(BuildNumberPart2.Trim())</VsixVersion>
</PropertyGroup>
</When>

<When Condition="'$(OfficialBuild)' == 'true' OR '$(SignedBuild)' == 'true'">
<PropertyGroup>
<AssemblyVersion>$(RoslynSemanticVersion).0</AssemblyVersion>
<BuildVersion>$(RoslynSemanticVersion).0</BuildVersion>
<VsixVersion>$(RoslynSemanticVersion).$(BuildNumberPart1.Trim())$(BuildNumberPart2.Trim())</VsixVersion>
</PropertyGroup>
</When>

Expand All @@ -75,17 +77,18 @@
<PropertyGroup>
<AssemblyVersion>42.42.42.42</AssemblyVersion>
<BuildVersion>42.42.42.42</BuildVersion>
<VsixVersion>42.42.42.42</VsixVersion>
</PropertyGroup>
</Otherwise>
</Choose>

<!-- Returns the current build version. Used in .vsixmanifests to substitute our build version into them -->
<Target Name="GetBuildVersion" Outputs="$(RoslynSemanticVersion).$(BuildNumberPart1.Trim())$(BuildNumberPart2.Trim())" />
<Target Name="GetBuildVersion" Outputs="$(VsixVersion)" />

<!-- NuGet version -->
<PropertyGroup>
<NuGetReleaseVersion>$(RoslynSemanticVersion)</NuGetReleaseVersion>
<NuGetPreReleaseVersion>$(RoslynSemanticVersion)-beta3</NuGetPreReleaseVersion>
<NuGetPreReleaseVersion>$(RoslynSemanticVersion)-beta4</NuGetPreReleaseVersion>
<NuGetPerBuildPreReleaseVersion>$(NuGetPreReleaseVersion)-$(BuildNumberPart1.Trim())-$(BuildNumberPart2.Trim())</NuGetPerBuildPreReleaseVersion>

<!-- TODO: change to a fixed version once we move this component to a separate repo -->
Expand Down
15 changes: 14 additions & 1 deletion src/Compilers/CSharp/Portable/Binder/Binder_Conversions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,20 @@ private BoundExpression CreateTupleLiteralConversion(CSharpSyntaxNode syntax, Bo
{
var argument = arguments[i];
var destType = targetElementTypes[i];
convertedArguments.Add(CreateConversion(argument, destType, diagnostics));

HashSet<DiagnosticInfo> useSiteDiagnostics = null;
Conversion elementConversion;
if (isCast)
{
elementConversion = this.Conversions.ClassifyConversionForCast(argument, destType, ref useSiteDiagnostics);
}
else
{
elementConversion = this.Conversions.ClassifyConversionFromExpression(argument, destType, ref useSiteDiagnostics);
}

diagnostics.Add(syntax, useSiteDiagnostics);
convertedArguments.Add(CreateConversion(argument.Syntax, argument, elementConversion, isCast, destType, diagnostics));
}

BoundExpression result = new BoundConvertedTupleLiteral(
Expand Down
177 changes: 124 additions & 53 deletions src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1716,60 +1716,9 @@ private BoundExpression BindCastCore(ExpressionSyntax node, BoundExpression oper
HashSet<DiagnosticInfo> useSiteDiagnostics = null;
Conversion conversion = this.Conversions.ClassifyConversionForCast(operand, targetType, ref useSiteDiagnostics);
diagnostics.Add(node, useSiteDiagnostics);
bool targetTypeIsStatic = targetType.IsStatic;
if (operand.HasAnyErrors || targetType.IsErrorType() || !conversion.IsValid || targetTypeIsStatic)
if (operand.HasAnyErrors || targetType.IsErrorType() || !conversion.IsValid || targetType.IsStatic)
{
// Make sure that errors within the unbound lambda don't get lost.
if (operand.Kind == BoundKind.UnboundLambda)
{
GenerateAnonymousFunctionConversionError(diagnostics, operand.Syntax, (UnboundLambda)operand, targetType);
}
else if (operand.HasAnyErrors || targetType.IsErrorType())
{
// an error has already been reported elsewhere
}
else if (targetTypeIsStatic)
{
// The specification states in the section titled "Referencing Static
// Class Types" that it is always illegal to have a static class in a
// cast operator.
diagnostics.Add(ErrorCode.ERR_ConvertToStaticClass, node.Location, targetType);
}
else if (!targetType.IsReferenceType && !targetType.IsNullableType() && operand.IsLiteralNull())
{
diagnostics.Add(ErrorCode.ERR_ValueCantBeNull, node.Location, targetType);
}
else if (conversion.ResultKind == LookupResultKind.OverloadResolutionFailure)
{
Debug.Assert(conversion.IsUserDefined);

ImmutableArray<MethodSymbol> originalUserDefinedConversions = conversion.OriginalUserDefinedConversions;
if (originalUserDefinedConversions.Length > 1)
{
diagnostics.Add(ErrorCode.ERR_AmbigUDConv, node.Location, originalUserDefinedConversions[0], originalUserDefinedConversions[1], operand.Type, targetType);
}
else
{
Debug.Assert(originalUserDefinedConversions.Length == 0,
"How can there be exactly one applicable user-defined conversion if the conversion doesn't exist?");
SymbolDistinguisher distinguisher = new SymbolDistinguisher(this.Compilation, operand.Type, targetType);
diagnostics.Add(ErrorCode.ERR_NoExplicitConv, node.Location, distinguisher.First, distinguisher.Second);
}
}
else
{
// TODO: report more specific diagnostics here for failed method group conversions
if (operand.Kind == BoundKind.MethodGroup)
{
diagnostics.Add(ErrorCode.ERR_NoExplicitConv, node.Location, MessageID.IDS_SK_METHOD.Localize(), targetType);
}
else
{
Debug.Assert((object)operand.Type != null);
SymbolDistinguisher distinguisher = new SymbolDistinguisher(this.Compilation, operand.Type, targetType);
diagnostics.Add(ErrorCode.ERR_NoExplicitConv, node.Location, distinguisher.First, distinguisher.Second);
}
}
GenerateExplicitConversionErrors(diagnostics, node, conversion, operand, targetType);

return new BoundConversion(
node,
Expand All @@ -1785,6 +1734,128 @@ private BoundExpression BindCastCore(ExpressionSyntax node, BoundExpression oper
return CreateConversion(node, operand, conversion, isCast: true, wasCompilerGenerated: wasCompilerGenerated, destination: targetType, diagnostics: diagnostics);
}

private void GenerateExplicitConversionErrors(
DiagnosticBag diagnostics,
CSharpSyntaxNode syntax,
Conversion conversion,
BoundExpression operand,
TypeSymbol targetType)
{
// Make sure that errors within the unbound lambda don't get lost.
if (operand.Kind == BoundKind.UnboundLambda)
{
GenerateAnonymousFunctionConversionError(diagnostics, operand.Syntax, (UnboundLambda)operand, targetType);
return;
}

if (operand.HasAnyErrors || targetType.IsErrorType())
{
// an error has already been reported elsewhere
return;
}

if (targetType.IsStatic)
{
// The specification states in the section titled "Referencing Static
// Class Types" that it is always illegal to have a static class in a
// cast operator.
diagnostics.Add(ErrorCode.ERR_ConvertToStaticClass, syntax.Location, targetType);
return;
}

if (!targetType.IsReferenceType && !targetType.IsNullableType() && operand.IsLiteralNull())
{
diagnostics.Add(ErrorCode.ERR_ValueCantBeNull, syntax.Location, targetType);
return;
}

if (conversion.ResultKind == LookupResultKind.OverloadResolutionFailure)
{
Debug.Assert(conversion.IsUserDefined);

ImmutableArray<MethodSymbol> originalUserDefinedConversions = conversion.OriginalUserDefinedConversions;
if (originalUserDefinedConversions.Length > 1)
{
diagnostics.Add(ErrorCode.ERR_AmbigUDConv, syntax.Location, originalUserDefinedConversions[0], originalUserDefinedConversions[1], operand.Type, targetType);
}
else
{
Debug.Assert(originalUserDefinedConversions.Length == 0,
"How can there be exactly one applicable user-defined conversion if the conversion doesn't exist?");
SymbolDistinguisher distinguisher1 = new SymbolDistinguisher(this.Compilation, operand.Type, targetType);
diagnostics.Add(ErrorCode.ERR_NoExplicitConv, syntax.Location, distinguisher1.First, distinguisher1.Second);
}

return;
}

// TODO: report more specific diagnostics here for failed method group conversions
if (operand.Kind == BoundKind.MethodGroup)
{
diagnostics.Add(ErrorCode.ERR_NoExplicitConv, syntax.Location, MessageID.IDS_SK_METHOD.Localize(), targetType);
return;
}

if (operand.Kind == BoundKind.TupleLiteral)
{
var tuple = (BoundTupleLiteral)operand;
var targetElementTypes = default(ImmutableArray<TypeSymbol>);

// source does not have a type.
// Such conversions could only happen via explicit tuple literal conversions
// which are currently not supported.
// See: https://github.com/dotnet/roslyn/issues/11804
if ((object)tuple.Type == null)
{
Error(diagnostics, ErrorCode.ERR_NoExplicitConv, syntax, tuple.Display, targetType);
return;
}

// If target is a tuple or compatible type with the same number of elements,
// report errors for tuple arguments that failed to convert, which would be more useful.
if (targetType.TryGetElementTypesIfTupleOrCompatible(out targetElementTypes) &&
targetElementTypes.Length == tuple.Arguments.Length)
{
GenerateExplicitConversionErrorsForTupleLiteralArguments(diagnostics, syntax, tuple.Arguments, targetElementTypes);
return;
}

// Otherwise it is just a regular conversion failure from T1 to T2.
}

Debug.Assert((object)operand.Type != null);
SymbolDistinguisher distinguisher = new SymbolDistinguisher(this.Compilation, operand.Type, targetType);
diagnostics.Add(ErrorCode.ERR_NoExplicitConv, syntax.Location, distinguisher.First, distinguisher.Second);
}

private void GenerateExplicitConversionErrorsForTupleLiteralArguments(
DiagnosticBag diagnostics,
CSharpSyntaxNode syntax,
ImmutableArray<BoundExpression> tupleArguments,
ImmutableArray<TypeSymbol> targetElementTypes)
{
var argLength = tupleArguments.Length;

// report all leaf elements of the tuple literal that failed to convert
// NOTE: we are not responsible for reporting use site errors here, just the failed leaf conversions.
// By the time we get here we have done analysis and know we have failed the cast in general, and diagnostics collected in the process is already in the bag.
// The only thing left is to form a diagnostics about the actually failing conversion(s).
// This whole method does not itself collect any usesite diagnostics. Its only purpose is to produce an error better than "conversion failed here"
HashSet<DiagnosticInfo> usDiagsUnused = null;

for (int i = 0; i < targetElementTypes.Length; i++)
{
var argument = tupleArguments[i];
var targetElementType = targetElementTypes[i];

var elementConversion = Conversions.ClassifyConversionFromType(argument.Type, targetElementType, ref usDiagsUnused);
if (!elementConversion.IsValid)
{
GenerateExplicitConversionErrors(diagnostics, argument.Syntax, elementConversion, argument, targetElementType);
}
}
}

private BoundExpression BindOriginal(OriginalExpressionSyntax syntax, DiagnosticBag diagnostics)
{
var containingMethod = (MethodSymbol)this.ContainingMember();
Expand Down
32 changes: 18 additions & 14 deletions src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2646,31 +2646,35 @@ protected static void GenerateImplicitConversionError(DiagnosticBag diagnostics,
}
}

protected void GenerateImplicitConversionError(DiagnosticBag diagnostics, CSharpSyntaxNode syntax,
Conversion conversion, BoundExpression expression, TypeSymbol targetType)
protected void GenerateImplicitConversionError(
DiagnosticBag diagnostics,
CSharpSyntaxNode syntax,
Conversion conversion,
BoundExpression operand,
TypeSymbol targetType)
{
Debug.Assert(expression != null);
Debug.Assert(operand != null);
Debug.Assert((object)targetType != null);

if (targetType.TypeKind == TypeKind.Error)
{
return;
}

if (expression.Kind == BoundKind.BadExpression)
if (operand.Kind == BoundKind.BadExpression)
{
return;
}

if (expression.Kind == BoundKind.UnboundLambda)
if (operand.Kind == BoundKind.UnboundLambda)
{
GenerateAnonymousFunctionConversionError(diagnostics, syntax, (UnboundLambda)expression, targetType);
GenerateAnonymousFunctionConversionError(diagnostics, syntax, (UnboundLambda)operand, targetType);
return;
}

if (expression.Kind == BoundKind.TupleLiteral)
if (operand.Kind == BoundKind.TupleLiteral)
{
var tuple = (BoundTupleLiteral)expression;
var tuple = (BoundTupleLiteral)operand;
var targetElementTypes = default(ImmutableArray<TypeSymbol>);

// If target is a tuple or compatible type with the same number of elements,
Expand All @@ -2692,14 +2696,14 @@ protected void GenerateImplicitConversionError(DiagnosticBag diagnostics, CSharp
// Otherwise it is just a regular conversion failure from T1 to T2.
}

var sourceType = expression.Type;
var sourceType = operand.Type;
if ((object)sourceType != null)
{
GenerateImplicitConversionError(diagnostics, this.Compilation, syntax, conversion, sourceType, targetType, expression.ConstantValue);
GenerateImplicitConversionError(diagnostics, this.Compilation, syntax, conversion, sourceType, targetType, operand.ConstantValue);
return;
}

if (expression.IsLiteralNull())
if (operand.IsLiteralNull())
{
if (targetType.TypeKind == TypeKind.TypeParameter)
{
Expand All @@ -2713,9 +2717,9 @@ protected void GenerateImplicitConversionError(DiagnosticBag diagnostics, CSharp
}
}

if (expression.Kind == BoundKind.MethodGroup)
if (operand.Kind == BoundKind.MethodGroup)
{
var methodGroup = (BoundMethodGroup)expression;
var methodGroup = (BoundMethodGroup)operand;
if (!Conversions.ReportDelegateMethodGroupDiagnostics(this, methodGroup, targetType, diagnostics))
{
var nodeForSquiggle = syntax;
Expand Down Expand Up @@ -2744,7 +2748,7 @@ protected void GenerateImplicitConversionError(DiagnosticBag diagnostics, CSharp
return;
}

Debug.Assert(expression.HasAnyErrors && expression.Kind != BoundKind.UnboundLambda, "Missing a case in implicit conversion error reporting");
Debug.Assert(operand.HasAnyErrors && operand.Kind != BoundKind.UnboundLambda, "Missing a case in implicit conversion error reporting");
}

private void GenerateImplicitConversionErrorsForTupleLiteralArguments(
Expand Down
Loading