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

Merge master into future #11331

Merged
merged 17 commits into from May 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 4 additions & 2 deletions docs/analyzers/Using Additional Files.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public class CheckTermsAnalyzer : DiagnosticAnalyzer
Converting a File to a Stream
-----------------------------

In cases where an additional file contains structured data (e.g., XML or JSON) the line-by-line access provided by the `SourceText` may not be desirable. This sample demonstrates how to convert a `SourceText` to a `Stream` for consumption by other libraries. The terms file is assumed to have the following format:
In cases where an additional file contains structured data (e.g., XML or JSON) the line-by-line access provided by the `SourceText` may not be desirable. One alternative is to convert a `SourceText` to a `string`, by calling `ToString()` on it. This sample demonstrates another alternative: converting a `SourceText` to a `Stream` for consumption by other libraries. The terms file is assumed to have the following format:

``` XML
<Terms>
Expand Down Expand Up @@ -207,10 +207,12 @@ public class CheckTermsXMLAnalyzer : DiagnosticAnalyzer
SourceText fileText = termsFile.GetText(compilationStartContext.CancellationToken);

MemoryStream stream = new MemoryStream();
using (StreamWriter writer = new StreamWriter(stream))
using (StreamWriter writer = new StreamWriter(stream, Encoding.UTF8, 1024, true))
{
fileText.Write(writer);
}

stream.Position = 0;

// Read all the <Term> elements to get the terms.
XDocument document = XDocument.Load(stream);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public abstract class AnalysisContext
public abstract void RegisterSemanticModelAction(Action<SemanticModelAnalysisContext> action);

/// <summary>
/// Register an action to be executed at completion of semantic analysis of an <see cref="ISymbol"/> with an appropriate Kind.>
/// Register an action to be executed at completion of semantic analysis of an <see cref="ISymbol"/> with an appropriate Kind.
/// A symbol action reports <see cref="Diagnostic"/>s about <see cref="ISymbol"/>s.
/// </summary>
/// <param name="action">Action to be executed for an <see cref="ISymbol"/>.</param>
Expand All @@ -75,7 +75,7 @@ public void RegisterSymbolAction(Action<SymbolAnalysisContext> action, params Sy
}

/// <summary>
/// Register an action to be executed at completion of semantic analysis of an <see cref="ISymbol"/> with an appropriate Kind.>
/// Register an action to be executed at completion of semantic analysis of an <see cref="ISymbol"/> with an appropriate Kind.
/// A symbol action reports <see cref="Diagnostic"/>s about <see cref="ISymbol"/>s.
/// </summary>
/// <param name="action">Action to be executed for an <see cref="ISymbol"/>.</param>
Expand Down Expand Up @@ -318,7 +318,7 @@ protected CompilationStartAnalysisContext(Compilation compilation, AnalyzerOptio
public abstract void RegisterSemanticModelAction(Action<SemanticModelAnalysisContext> action);

/// <summary>
/// Register an action to be executed at completion of semantic analysis of an <see cref="ISymbol"/> with an appropriate Kind.>
/// Register an action to be executed at completion of semantic analysis of an <see cref="ISymbol"/> with an appropriate Kind.
/// A symbol action reports <see cref="Diagnostic"/>s about <see cref="ISymbol"/>s.
/// </summary>
/// <param name="action">Action to be executed for an <see cref="ISymbol"/>.</param>
Expand All @@ -329,7 +329,7 @@ public void RegisterSymbolAction(Action<SymbolAnalysisContext> action, params Sy
}

/// <summary>
/// Register an action to be executed at completion of semantic analysis of an <see cref="ISymbol"/> with an appropriate Kind.>
/// Register an action to be executed at completion of semantic analysis of an <see cref="ISymbol"/> with an appropriate Kind.
/// A symbol action reports <see cref="Diagnostic"/>s about <see cref="ISymbol"/>s.
/// </summary>
/// <param name="action">Action to be executed for an <see cref="ISymbol"/>.</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,16 @@ public string GetNameForArgument(SyntaxNode argument)
{
throw new NotImplementedException();
}

public bool IsLeftSideOfDot(SyntaxNode node)
{
throw new NotImplementedException();
}

public SyntaxNode GetRightSideOfDot(SyntaxNode node)
{
throw new NotImplementedException();
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,29 @@ namespace System.Xaml { public class A { } }
public class Program { static void M() { MS.Internal.Xaml } }");
}

[WorkItem(11071, "https://github.com/dotnet/roslyn/issues/11071")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsFullyQualify)]
public async Task AmbiguousFixOrdering()
{
await TestAsync(
@"using n1;
using n2;

[[|Inner|].C]
class B { }

namespace n1 { namespace Inner { } }
namespace n2 { namespace Inner { class CAttribute { } } }",
@"using n1;
using n2;

[n2.Inner.C]
class B { }

namespace n1 { namespace Inner { } }
namespace n2 { namespace Inner { class CAttribute { } } }");
}

[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsFullyQualify)]
public async Task TupleTest()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -868,8 +868,25 @@ await TestAsync(
public async Task TestUnmentionableTypeParameter7()
{
await TestAsync(
@"class H < T > { void A ( T t1 ) { t1 = [|Foo < T >|] ( t1 ) ; } } ",
@"using System; class H < T > { void A ( T t1 ) { t1 = Foo < T > ( t1 ) ; } private T Foo < T1 > ( T t1 ) { throw new NotImplementedException ( ) ; } } ");
@"class H < T >
{
void A ( T t1 )
{
t1 = [|Foo < T >|] ( t1 ) ;
}
} ",
@"using System;
class H < T >
{
void A ( T t1 )
{
t1 = Foo < T > ( t1 ) ;
}
private T1 Foo < T1 > ( T1 t1 )
{
throw new NotImplementedException ( ) ;
}
} ");
}

[WorkItem(539593, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539593")]
Expand Down Expand Up @@ -1007,8 +1024,19 @@ await TestAsync(
public async Task TestLambdaReturnType()
{
await TestAsync(
@"using System ; class C < T , R > { private static Func < T , R > g = null ; private static Func < T , R > f = ( T ) => { return [|Foo < T , R >|] ( g ) ; } ; } ",
@"using System ; class C < T , R > { private static Func < T , R > g = null ; private static Func < T , R > f = ( T ) => { return Foo < T , R > ( g ) ; } ; private static R Foo < T1 , T2 > ( Func < T , R > g ) { throw new NotImplementedException ( ) ; } } ");
@"using System ;
class C < T , R >
{
private static Func < T , R > g = null ;
private static Func < T , R > f = ( T ) => { return [|Foo < T , R >|] ( g ) ; } ;
} ",
@"using System ;
class C < T , R >
{
private static Func < T , R > g = null ;
private static Func < T , R > f = ( T ) => { return Foo < T , R > ( g ) ; } ;
private static T2 Foo < T1 , T2 > ( Func < T1 , T2 > g ) { throw new NotImplementedException ( ) ; }
} ");
}

[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateMethod)]
Expand Down Expand Up @@ -2918,6 +2946,38 @@ public static T M1<T>(this T t) where T : C
}
}
");
}

[WorkItem(11141, "https://github.com/dotnet/roslyn/issues/11141")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateMethod)]
public async Task InferTypeParameters1()
{
await TestAsync(
@"using System;

class C
{
void M()
{
List<int> list = null;
int i = [|First<int>(list)|];
}
}",
@"using System;

class C
{
void M()
{
List<int> list = null;
int i = First<int>(list);
}

private T First<T>(List<T> list)
{
throw new NotImplementedException();
}
}");
}

[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateMethod)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,14 @@ End Class]]></a>.Value.NormalizeLineEndings()
Public Function GetNameForArgument(argument As SyntaxNode) As String Implements ISyntaxFactsService.GetNameForArgument
Throw New NotImplementedException()
End Function

Public Function IsLeftSideOfDot(node As SyntaxNode) As Boolean Implements ISyntaxFactsService.IsLeftSideOfDot
Throw New NotImplementedException()
End Function

Public Function GetRightSideOfDot(node As SyntaxNode) As SyntaxNode Implements ISyntaxFactsService.GetRightSideOfDot
Throw New NotImplementedException()
End Function
End Class
End Class
End Namespace
Original file line number Diff line number Diff line change
Expand Up @@ -1337,7 +1337,7 @@ Class M1
sub1(Of Integer, String)(New Integer() {1, 2, 3}, New String() {"a", "b"})
End Sub

Private Sub sub1(Of T1, T2)(v1() As Integer, v2() As String)
Private Sub sub1(Of T1, T2)(v1() As T1, v2() As T2)
Throw New NotImplementedException()
End Sub
End Class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,22 @@ protected override bool IsImplicitReferenceConversion(Compilation compilation, I
var conversion = compilation.ClassifyConversion(sourceType, targetType);
return conversion.IsImplicit && conversion.IsReference;
}

protected override IList<ITypeSymbol> DetermineTypeArguments(CancellationToken cancellationToken)
{
var result = new List<ITypeSymbol>();

if (State.SimpleNameOpt is GenericNameSyntax)
{
foreach (var typeArgument in ((GenericNameSyntax)State.SimpleNameOpt).TypeArgumentList.Arguments)
{
var type = this.Document.SemanticModel.GetTypeInfo(typeArgument, cancellationToken).Type;
result.Add(type);
}
}

return result;
}
}
}
}
Loading