Skip to content

Commit

Permalink
Improving "No functions found" error message to help users who might …
Browse files Browse the repository at this point in the history
…have forgotten to register extension bindings before using them.
  • Loading branch information
mathewc committed Nov 4, 2015
1 parent 0581fb1 commit abc7adc
Show file tree
Hide file tree
Showing 12 changed files with 232 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ public static async Task<JobHostContext> CreateAndLogHostStartedAsync(

if (descriptorsCount == 0)
{
trace.Warning("No functions found. Try making job classes and methods public.", TraceSource.Indexing);
trace.Warning(string.Format("No job functions found. Try making your job classes and methods public. {0}",
Resource.ExtensionInitializationMessage), TraceSource.Indexing);
}
else
{
Expand Down
14 changes: 7 additions & 7 deletions src/Microsoft.Azure.WebJobs.Host/Indexers/FunctionIndexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,22 +188,22 @@ internal async Task IndexMethodAsyncCore(MethodInfo method, IFunctionIndexCollec
{
if (triggerBinding != null && !hasNoAutomaticTriggerAttribute)
{
throw new InvalidOperationException(string.Format("Cannot bind parameter '{0}' when using this trigger.", parameter.Name));
throw new InvalidOperationException(
string.Format(Resource.UnableToBindParameterFormat,
parameter.Name, parameter.ParameterType.Name, Resource.ExtensionInitializationMessage));
}
else
{
// Host.Call-only parameter
string parameterName = parameter.Name;
Type parameterType = parameter.ParameterType;

binding = InvokeBinding.Create(parameterName, parameterType);

binding = InvokeBinding.Create(parameter.Name, parameter.ParameterType);
if (binding == null && invalidInvokeBindingException == null)
{
// This function might not have any attribute, in which case we shouldn't throw an
// exception when we can't bind it. Instead, save this exception for later once we determine
// whether or not it is an SDK function.
invalidInvokeBindingException = new InvalidOperationException(string.Format("Cannot bind parameter '{0}' to type {1}.", parameterName, parameterType.Name));
invalidInvokeBindingException = new InvalidOperationException(
string.Format(Resource.UnableToBindParameterFormat,
parameter.Name, parameter.ParameterType, Resource.ExtensionInitializationMessage));
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/Microsoft.Azure.WebJobs.Host/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
// Licensed under the MIT License. See License.txt in the project root for license information.

using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;

[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: NeutralResourcesLanguage("en-US")]

[assembly: InternalsVisibleTo("Dashboard.UnitTests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]
Expand Down
81 changes: 81 additions & 0 deletions src/Microsoft.Azure.WebJobs.Host/Resource.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

126 changes: 126 additions & 0 deletions src/Microsoft.Azure.WebJobs.Host/Resource.resx
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="ExtensionInitializationMessage" xml:space="preserve">
<value>If you're using binding extensions (e.g. ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. config.UseServiceBus(), config.UseTimers(), etc.).</value>
</data>
<data name="UnableToBindParameterFormat" xml:space="preserve">
<value>Cannot bind parameter '{0}' to type {1}. Make sure the parameter Type is supported by the binding. {2}</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ public ParameterLog GetStatus()
{
// periodically determine and log the current owner
Task<string> task = _singletonLock.GetOwnerAsync(CancellationToken.None);
task.Wait();
_log.LockOwner = task.Result;

_lastOwnerCheck = DateTime.UtcNow;
Expand Down
12 changes: 11 additions & 1 deletion src/Microsoft.Azure.WebJobs.Host/WebJobs.Host.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,11 @@
<Compile Include="Loggers\TraceWriterFunctionInstanceLogger.cs" />
<Compile Include="Queues\Bindings\StorageQueueArgumentBindingProvider.cs" />
<Compile Include="Queues\IQueueProcessorFactory.cs" />
<Compile Include="Resource.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resource.resx</DependentUpon>
</Compile>
<Compile Include="Singleton\SingletonListener.cs" />
<Compile Include="Queues\QueueProcessor.cs" />
<Compile Include="Queues\DefaultQueueProcessorFactory.cs" />
Expand Down Expand Up @@ -931,7 +936,12 @@
<SubType>Designer</SubType>
</CodeAnalysisDictionary>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<EmbeddedResource Include="Resource.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resource.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,7 @@ private static IServiceProvider CreateServiceProvider<TResult>(IStorageAccount s

IFunctionInstanceLoggerProvider functionInstanceLoggerProvider = new NullFunctionInstanceLoggerProvider();
IFunctionOutputLoggerProvider functionOutputLoggerProvider = new NullFunctionOutputLoggerProvider();
Task<IFunctionOutputLogger> task = functionOutputLoggerProvider.GetAsync(CancellationToken.None);
task.Wait();
IFunctionOutputLogger functionOutputLogger = task.Result;
IFunctionOutputLogger functionOutputLogger = functionOutputLoggerProvider.GetAsync(CancellationToken.None).Result;
FunctionExecutor executor = new FunctionExecutor(functionInstanceLogger, functionOutputLogger, backgroundExceptionDispatcher, new TestTraceWriter(TraceLevel.Verbose), null);

SingletonConfiguration singletonConfig = new SingletonConfiguration();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ public TestFixture()

DefaultStorageAccountProvider accountProvider = new DefaultStorageAccountProvider(services.Object);
var task = accountProvider.GetStorageAccountAsync(CancellationToken.None);
task.Wait();
IStorageQueueClient client = task.Result.CreateQueueClient();
QueueClient = client.SdkObject;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ public FakeQueueProcessorFactory(IStorageAccountProvider accountProvider)
{
CancellationToken token = new CancellationToken();
Task<IStorageAccount> task = accountProvider.GetStorageAccountAsync(token);
task.Wait();
_storageAccount = task.Result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ public static TestJobHost<TProgram> Create<TProgram>(CloudStorageAccount storage
SingletonManager singletonManager = new SingletonManager();

IFunctionOutputLoggerProvider outputLoggerProvider = new NullFunctionOutputLoggerProvider();
var task = outputLoggerProvider.GetAsync(CancellationToken.None);
task.Wait();
IFunctionOutputLogger outputLogger = task.Result;
IFunctionOutputLogger outputLogger = outputLoggerProvider.GetAsync(CancellationToken.None).Result;
IFunctionExecutor executor = new FunctionExecutor(new NullFunctionInstanceLogger(), outputLogger, BackgroundExceptionDispatcher.Instance, new TestTraceWriter(TraceLevel.Verbose), null);

var triggerBindingProvider = DefaultTriggerBindingProvider.Create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ public static FunctionIndexer Create(CloudStorageAccount account = null, INameRe
blobWrittenWatcherAccessor, new DefaultExtensionRegistry());

IFunctionOutputLoggerProvider outputLoggerProvider = new NullFunctionOutputLoggerProvider();
var task = outputLoggerProvider.GetAsync(CancellationToken.None);
task.Wait();
IFunctionOutputLogger outputLogger = task.Result;
IFunctionOutputLogger outputLogger = outputLoggerProvider.GetAsync(CancellationToken.None).Result;
IFunctionExecutor executor = new FunctionExecutor(new NullFunctionInstanceLogger(), outputLogger, BackgroundExceptionDispatcher.Instance, new TestTraceWriter(TraceLevel.Verbose), null);

if (extensionRegistry == null)
Expand Down

0 comments on commit abc7adc

Please sign in to comment.