Skip to content

Commit

Permalink
Merge pull request #380 from itn3000/throw-error-metadata-null
Browse files Browse the repository at this point in the history
throw exception when getting attribute's metadata is failed.(#355)
  • Loading branch information
neuecc committed Feb 5, 2019
2 parents 893f1f2 + 37d8a12 commit 729a09a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
Expand Up @@ -20,14 +20,46 @@ public class ReferenceSymbols
public ReferenceSymbols(Compilation compilation)
{
TaskOfT = compilation.GetTypeByMetadataName("System.Threading.Tasks.Task`1");
if(TaskOfT == null)
{
throw new InvalidOperationException("failed to get metadata of System.Threading.Tasks.Task`1");
}
Task = compilation.GetTypeByMetadataName("System.Threading.Tasks.Task");
if (Task == null)
{
throw new InvalidOperationException("failed to get metadata of System.Threading.Tasks.Task");
}
MessagePackObjectAttribute = compilation.GetTypeByMetadataName("MessagePack.MessagePackObjectAttribute");
if (MessagePackObjectAttribute == null)
{
throw new InvalidOperationException("failed to get metadata of MessagePack.MessagePackObjectAttribute");
}
UnionAttribute = compilation.GetTypeByMetadataName("MessagePack.UnionAttribute");
if (UnionAttribute == null)
{
throw new InvalidOperationException("failed to get metadata of MessagePack.UnionAttribute");
}
SerializationConstructorAttribute = compilation.GetTypeByMetadataName("MessagePack.SerializationConstructorAttribute");
if (SerializationConstructorAttribute == null)
{
throw new InvalidOperationException("failed to get metadata of MessagePack.SerializationConstructorAttribute");
}
KeyAttribute = compilation.GetTypeByMetadataName("MessagePack.KeyAttribute");
if (KeyAttribute == null)
{
throw new InvalidOperationException("failed to get metadata of MessagePack.KeyAttribute");
}
IgnoreAttribute = compilation.GetTypeByMetadataName("MessagePack.IgnoreMemberAttribute");
if (IgnoreAttribute == null)
{
throw new InvalidOperationException("failed to get metadata of MessagePack.IgnoreMemberAttribute");
}
IgnoreDataMemberAttribute = compilation.GetTypeByMetadataName("System.Runtime.Serialization.IgnoreDataMemberAttribute");
IMessagePackSerializationCallbackReceiver = compilation.GetTypeByMetadataName("MessagePack.IMessagePackSerializationCallbackReceiver");
if (IMessagePackSerializationCallbackReceiver == null)
{
throw new InvalidOperationException("failed to get metadata of MessagePack.IMessagePackSerializationCallbackReceiver");
}
}
}

Expand Down
Expand Up @@ -25,7 +25,8 @@ internal static class RoslynExtensions
// https://github.com/daveaglick/Buildalyzer/blob/b42d2e3ba1b3673a8133fb41e72b507b01bce1d6/src/Buildalyzer/Environment/BuildEnvironment.cs#L86-L96
Dictionary<string, string> properties = new Dictionary<string, string>()
{
{"IntermediateOutputPath", tempPath},
// trailing '\' may cause unexpected escape
{"IntermediateOutputPath", tempPath + "/"},
{"ProviderCommandLineArgs", "true"},
{"GenerateResourceMSBuildArchitecture", "CurrentArchitecture"},
{"DesignTimeBuild", "true"},
Expand All @@ -40,7 +41,7 @@ internal static class RoslynExtensions
{"UseCommonOutputDirectory", "true"},
{"GeneratePackageOnBuild", "false"},
{"RunPostBuildEvent", "false"},
{"SolutionDir", new FileInfo(csprojPath).FullName}
{"SolutionDir", (new FileInfo(csprojPath).Directory.FullName) + "/"}
};
var propargs = string.Join(" ", properties.Select(kv => $"/p:{kv.Key}=\"{kv.Value}\""));
// how to determine whether command should be executed('dotnet msbuild' or 'msbuild')?
Expand Down

0 comments on commit 729a09a

Please sign in to comment.