-
-
Notifications
You must be signed in to change notification settings - Fork 746
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1029 from reactiveui/more-source-generator
Use Semantic model for generating sources
- Loading branch information
Showing
10 changed files
with
384 additions
and
816 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 0 additions & 90 deletions
90
InterfaceStubGenerator.Core/GeneratedInterfaceStubTemplate.mustache
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
using Microsoft.CodeAnalysis; | ||
|
||
namespace Refit.Generator | ||
{ | ||
static class ITypeSymbolExtensions | ||
{ | ||
public static IEnumerable<ITypeSymbol> GetBaseTypesAndThis(this ITypeSymbol? type) | ||
{ | ||
var current = type; | ||
while (current != null) | ||
{ | ||
yield return current; | ||
current = current.BaseType; | ||
} | ||
} | ||
|
||
// Determine if "type" inherits from "baseType", ignoring constructed types, optionally including interfaces, | ||
// dealing only with original types. | ||
public static bool InheritsFromOrEquals( | ||
this ITypeSymbol type, ITypeSymbol baseType, bool includeInterfaces) | ||
{ | ||
if (!includeInterfaces) | ||
{ | ||
return InheritsFromOrEquals(type, baseType); | ||
} | ||
|
||
return type.GetBaseTypesAndThis().Concat(type.AllInterfaces).Any(t => t.Equals(baseType, SymbolEqualityComparer.Default)); | ||
} | ||
|
||
|
||
// Determine if "type" inherits from "baseType", ignoring constructed types and interfaces, dealing | ||
// only with original types. | ||
public static bool InheritsFromOrEquals( | ||
this ITypeSymbol type, ITypeSymbol baseType) | ||
{ | ||
return type.GetBaseTypesAndThis().Any(t => t.Equals(baseType, SymbolEqualityComparer.Default)); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.